// JavaScript Document pour PURE Player

function detectBrowser() {
	var sUserAgent = navigator.userAgent;
	var fAppVersion = parseFloat(navigator.appVersion);

	var pos_s = sUserAgent.indexOf("Safari");
	if (pos_s>=0){
		var supported_browser = false;
	} else {
		var pos_o = sUserAgent.indexOf("Opera");
		if (pos_o>=0){
			var supported_browser = false;
		} else {
			var supported_browser = true;
		}
	}
	return supported_browser;
}


function HighlightText(){

if (document.selection) {
 var r1 = document.body.createTextRange();
 var r4 = document.body.createTextRange();
 r1.moveToElementText(document.getElementById('html_source'));
 r4.moveToElementText(document.getElementById('end'));
 r1.setEndPoint("EndToEnd", r4);
 r1.select();
} else {
 s = window.getSelection();
 var r1 = document.createRange();
 r1.setStartBefore(document.getElementById('html_source'));
 r1.setEndAfter(document.getElementById('end'));
 s.addRange(r1);
}
}

function validateInput() {
submit_disabled = false;
	
		var parsed_w = parseInt(document.getElementById('width').value);
		if(parsed_w > 50 && parsed_w < 3000) {
			var w_input = document.getElementById('width');
			document.getElementById('width').value = parsed_w;
			document.getElementById('width_validation').innerHTML = "<img src='img/yes.gif' border='0'>";
			document.getElementById('width_validation').style.display = "block";
			
			var parsed_w = parseInt(document.getElementById('height').value);
			if(parsed_w > 50 && parsed_w < 3000) {
				var w_input = document.getElementById('width');
				document.getElementById('height').value = parsed_w;
				document.getElementById('height_validation').innerHTML = "<img src='img/yes.gif' border='0'>";
				document.getElementById('height_validation').style.display = "block";
				submit_disabled = false;
			} else {
				var w_input = document.getElementById('height');
				document.getElementById('height').value = parsed_w;
				document.getElementById('height_validation').innerHTML = "<img src='img/no.gif' border='0'>&nbsp;Invalid input!";
				document.getElementById('height_validation').style.display = "block";
				submit_disabled = true;
			}
			
			//submit_disabled = false;
		} else {
			var w_input = document.getElementById('width');
			document.getElementById('width').value = parsed_w;
			document.getElementById('width_validation').innerHTML = "<img src='img/no.gif' border='0'>&nbsp;Invalid input!";
			document.getElementById('width_validation').style.display = "block";
			//document.getElementById('submit_size').disabled = true;
			//document.getElementById('width').focus();
			submit_disabled = true;
			w_input.focus();
			w_input.select();
		}

document.getElementById('submit_size').disabled = submit_disabled;
}


function init(width, height, ivp){
	var e = document.getElementById("PUREPlayer");
	e.innerHTML	= "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" +
					"id='PurePlayer' width='" + width + "' height='" + height + "'" +
					"codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=9,0,0,0'>" +
					"<param name='movie' value='PurePlayer.swf' />" +
					"<param name='allowScriptAccess' value='sameDomain' />" +
					"<param name='allowFullScreen' value='true' />" +
					"<param name='flashvars' value='panorama=" + ivp + "' />" +
						"<embed src='PurePlayer.swf' " +
							"width='" + width + "' height='" + height + "' name='PurePlayer' align='middle'" + 
							"play='true'" +
							"loop='false'" +
							"quality='high'" +
							"allowScriptAccess='sameDomain'" +
							"allowFullScreen='true'" +
							"type='application/x-shockwave-flash'" +
							"flashvars='panorama=" + ivp + "'" +
							"pluginspage='http://www.adobe.com/go/getflashplayer'>" +
						"</embed>" +
					"</object>";		  		  
}

function displayHTML( ivp ) {
	var oForm = document.forms[0];
	//oForm.submit();
	var width = oForm.elements['width'].value;
	var height = oForm.elements['height'].value;

	var inst = document.getElementById("instruction");
	var html = document.getElementById("html_source");
	
	html.innerHTML = "&lt;object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000<br>" +
					 "id='PurePlayer' width='<div class='value'>" + width + "</div>' height='<div class='value'>" + height + "</div>'<br>" +
					 "codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=9,0,0,0'&gt;<br>" +
					 "&lt;param name='movie' value='PurePlayer.swf' /&gt;<br>" +
					 "&lt;param name='>allowScriptAccess' value='sameDomain' /&gt;<br>" +
					 "&lt;param name='allowFullScreen' value='true' /&gt;<br>" +
					 "&lt;param name='<div class='keyword'>flashvars</div>' value='<div class='value'>panorama=" + ivp + "</div>' /&gt;<br>" +
					   	 "&nbsp;&nbsp;&nbsp;&lt;embed src='<div class='keyword'>PurePlayer.swf</div>' <br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width='<div class='value'>" + width + "</div>' height='<div class='value'>" + height + "</div>' name='<div class='value'>PurePlayer</div>' align='middle'<br>" + 
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;play='true'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop='false'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;quality='high'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allowScriptAccess='sameDomain'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allowFullScreen='true'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type='application/x-shockwave-flash'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div class='keyword'>flashvars</div>='<div class='value'>panorama=" + ivp + "</div>'<br>" +
							 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pluginspage='http://www.adobe.com/go/getflashplayer'&gt;<br>" +
						 "&nbsp;&nbsp;&nbsp;&lt;/embed&gt;<br>" +
					 "&lt;/object&gt;<br>";
					 
	init(width, height, ivp );
	
	inst.style.display = "block";
	html.style.display = "block";
	if( detectBrowser()) {
		var element = document.getElementById("highlight");
		element.style.display = "block";
	}	
}

