/*#####################################################################################################################################################
file:			overlay.js
author:			The video tour people.
description:	Overlay function to place applet overlay on the media center.
changes:		2006.09.07 - strange@tol.com - Kevin Strange -- Initial code
				2007.01.22 - strange@de.com - Kevin Strange -- UPdated to remove specific IE function that was cause an error.

Sample usage of this function

Put this in the head of the HTML document.
<script language="JavaScript" type="text/javascript" src="overlay.js"></script>

The body tag must contain the onload function.
<body onload="activecontentHider('layerid');">

Calling the function in HTML:
Note: Some URL's have trailing slashes for example the path to the movies has a trailing slash, but the code_base has no trailing slash.
<a href="#" onmousedown="showDiv('testLYR', '320', '240', '50', '50', '320', '240', 'StarWars320', 'http://www.eviewsales.com/vms/evod/members/1074/', 'starwars320', 'http://www.eviewsales.com/vms/evod', 'true', 'false', 'true', 'http://www.espresolutions.com/');">Click Me</a>
Layer ID | Layer Width | Layer Height | Layer X Position | Layer Y Position | Video Width | Video Height | Video Path | Video Name | Video URL | Applet Codebase | Auto Play | Loop | Scriptable | Redirect URL

Calling the function in Flash:
Note: Some URL's have trailing slashes for example the path to the movies has a trailing slash, but the code_base has no trailing slash.
cliporButtonName.onRelease = function(){
	getURL("javascript:showDiv('testLYR', '320', '240', '50', '50', '320', '240', 'StarWars320', 'http://www.eviewsales.com/vms/evod/members/1074/', 'starwars320', 'http://www.eviewsales.com/vms/evod', 'true', 'false', 'true', 'http://www.espresolutions.com/');";
}
Layer ID | Layer Width | Layer Height | Layer X Position | Layer Y Position | Video Width | Video Height | Video Path | Video Name | Video URL | Applet Codebase | Auto Play | Loop | Scriptable | Redirect URL

#####################################################################################################################################################*/

ie		= (document.all && !window.opera);
dom 	= (document.getElementById && !window.opera);
opera 	= (window.opera);


function hideDiv(id){
	if (ie) {
		document.getElementById(id).style.visibility = "hidden";
		document.getElementById(id).innerHTML="";
	} else if (dom) {
		document.getElementById(id).style.visibility="hidden";
		document.getElementById(id).innerHTML="";
	} else if (opera) {
		document.getElementById(id).style.visibility="hidden";
		document.getElementById(id).innerHTML="";
	}
}

function showDiv(id, lwidth, lheight, layerx, layery, vwidth, vheight, vname, vpath, vurl, code_base, auto_play, vloop, vscript, vredirect){

//window.alert('The Video Is Loaded!');
// HTML Code for generating the Espre Java Applet
	reval  = "";
	reval += "<OBJECT id=\"" + vname + "\" classid = \"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" codebase = \"http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,3,1,0\" WIDTH = \"" + vwidth + "\" HEIGHT = \"" + vheight + "\" NAME = \"" + vname + "\">";
	reval += "<PARAM NAME = \"codebase\" VALUE = \"" + code_base + "\">";
	reval += "<PARAM NAME = \"CODE\" VALUE = \"es/TopApplet.class\">";
	reval += "<PARAM NAME = \"backgroundColor\" VALUE = \"black\">";
	reval += "<PARAM NAME = \"ARCHIVE\" VALUE = \"evp.jar,evmResources.jar\" >";
	reval += "<PARAM NAME = \"NAME\" VALUE = \"" + vname + "\" >";
	reval += "<PARAM NAME = \"type\" VALUE = \"application/x-java-applet;version=1.3.1\">";
	reval += "<PARAM NAME = \"scriptable\" VALUE = \"" + vscript + "\">";
	reval += "<PARAM NAME = \"url\" VALUE=\"" + vpath + vurl + "\">";
	reval += "<PARAM NAME = \"urlAudio\" VALUE=\"" + vpath + vurl + "-audio\">";
	reval += "<PARAM NAME = \"autoplay\" VALUE = \"" + auto_play + "\">";
	reval += "<PARAM name = \"controlsVisible\" value = \"false\">";
	reval += "<PARAM name = \"gestures\" value = \"true\">";
	reval += "<PARAM name = \"loop\" value = \"" + vloop + "\">";
	reval += "<PARAM name = \"autoMute\" value = \"false\">";
	reval += "<PARAM name = \"mouseHelp\" value = \"false\">";
	reval += "<PARAM name = \"pels\" value = \"" + vwidth + "\">";
	reval += "<PARAM name = \"lines\" value = \"" + vheight + "\">";
	reval += "<PARAM name = \"redirectUrl\" value = \"" + vredirect + "\">";
	reval += "<EMBED id=\"" + vname + "\"CODEBASE=\"" + code_base + "\" type = \"application/x-java-applet;version=1.3\" CODE = \"es/TopApplet.class\" ARCHIVE = \"evp.jar,evmResources.jar\" NAME = \"" + vname + "\" WIDTH = \""+ vwidth + "\" HEIGHT=\"" + vheight + "\" backgroundColor=\"black\" url=\"" + vpath + vurl + "\" urlAudio=\"" + vpath + vurl + "-audio\" autoplay = \"" + auto_play + "\" scriptable = \"" + vscript + "\" pluginspage = \"http://java.sun.com/products/plugin/index.html#download\" controlsVisible = \"false\" gestures = \"true\" loop = \"" + vloop + "\" autoMute = \"false\" mouseHelp = \"false\" pels = \"" + vwidth + "\" lines = \"" + vheight + "\" redirectUrl = \"" + vredirect + "\"></EMBED>";
	reval += "</OBJECT>";
	
	if (ie) {
		document.getElementById(id).style.visibility="visible";
		document.getElementById(id).style.left=layerx;
		document.getElementById(id).style.top=layery;
		document.getElementById(id).style.width=lwidth;
		document.getElementById(id).style.height=lheight;
		document.getElementById(id).innerHTML=reval;
		
	} else if (dom) {
		document.getElementById(id).style.visibility="visible";
		document.getElementById(id).style.left=layerx;
		document.getElementById(id).style.top=layery;
		document.getElementById(id).style.width=lwidth;
		document.getElementById(id).style.height=lheight;
		document.getElementById(id).innerHTML=reval;
		
	} else if (opera) {
		document.getElementById(id).style.visibility="visible";
		document.getElementById(id).style.left=layerx;
		document.getElementById(id).style.top=layery;
		document.getElementById(id).style.width=lwidth;
		document.getElementById(id).style.height=lheight;
		document.getElementById(id).innerHTML=reval;
		
	}
}

function controlPlayer(pname, vurl, vname){
	if(navigator.userAgent.indexOf("MSIE") != -1){
		if(!document.getElementById(pname) || document.getElementById(pname) == ""  || document.getElementById(pname) == "undefined"){
		} else {
			document.getElementById(pname).ep_setNextVideoUrl(vurl + vname);
			document.getElementById(pname).ep_setNextAudioUrl(vurl + vname + "-audio");
			document.getElementById(pname).ep_forceRestart();
		}
	} else {
		if(!document.embeds[pname] || document.embeds[pname] == "" || document.embeds[pname] == "undefined"){
		} else {
			document.embeds[pname].ep_setNextVideoUrl(vurl + vname);
			document.embeds[pname].ep_setNextAudioUrl(vurl + vname + "-audio");
			document.embeds[pname].ep_forceRestart();
		}
	}
}