<!--
//3 Nov 2006 -- adds support for Firefox, removed version cookie 
var agt=navigator.userAgent.toLowerCase(); 

var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_XP = (window.navigator.userAgent.indexOf("NT 5.1")!= -1); 
var is_XPsp2 = is_XP && (window.navigator.userAgent.indexOf("SV1")!= -1); 

var is_major = parseInt(navigator.appVersion);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie4up  = (is_ie && (is_major >= 4));
var is_opera = (agt.indexOf("opera") != -1);

var is_nav = (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape")!=-1);
var is_firefox = (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Firefox")!=-1);

//alert( 'navigator.appName:' + navigator.appName + ',  navigator.userAgent:' + navigator.userAgent );
//if (is_nav) alert( 'Netscape or Firefox detected');
//if (is_firefox) alert( 'Firefox detected');
//if (is_ie) alert( 'IE detected');

var version;
try { version = ESPlugin.Version; }
catch(e) 	{ //alert ('activeX not loaded - error msg: ' + e); 
			}
//alert( 'ES client version is ' + version );	


 if(is_nav || is_firefox)
{
	try
	{
		if ("createEvent" in document) 
		{ 
		  var element = document.createElement("EdgeStreamDataElement"); 
		  document.documentElement.appendChild(element); 
		  var ev = document.createEvent("Events"); 
		  ev.initEvent("EdgeStreamEvent", true, false); 
		  element.dispatchEvent(ev);
		  if(element.getAttribute("ESC_Version"))
		  {
				version = element.getAttribute("ESC_Version");
				//alert("EdgeStreamClient Version = " + element.getAttribute("ESC_Version") + ", version=" + version );
		  }

		} 
	}
	catch(err)
	{
		alert(err.description);
	}
}

var sURL = unescape(window.location.pathname);	//save URL for refreshing the page
var RefrLoopCnt = readCookie('RefrLoopCnt');
var RefrTime;


function window_onload(playlink) {
	var link = "EdgeStreamClient.exe";

//alert ('.is_ie4up:' + is_ie4up +  ', is_nav:' + is_nav + ', is_firefox:' + is_firefox + ', version: ' +version  );

	if ( is_ie4up) 
	{
		version = ESPlugin.Version;
		if(version == null ) version=0;
	}
	else if ( is_firefox) 
	{
		version = element.getAttribute("ESC_Version");
	}
		
	if ( is_ie4up || is_firefox ) 
	{
		if(( version >= 1) && (version <= 2199))
		{
			if (getInfo('upgradeMust')==true) { document.location=playlink;return;} //he upgraded, so play
			else { 	alert('You must install a new version of the EdgeStream Client Software to play this video.'); }
		}
		else if(( version >= 2200) && (version < 2250))
		{
			getInfo('upgradeShould');
			return;
		}
		else if( version >=2250)
		{ 
			//alert(playlink);
			eraseCookie('InstallProgress');	
			document.location=playlink;
			return;	//play, version is >=2250
		}  
		else //version==0 or null
		{ 
			getInfo('newInstall')
		}
	}
	else //it's not IE nor firefox
	{ 
		if(version == 0 || version == null)
		{
			alert('If not already installed, just click on the "Get EdgeStream Software" button at the top of the page to download the EdgeStream vdeo client software.'); 
			return false;
			
		}
	}
}


function getInfo(type) {
	if (type=='upgradeMust') 
	{
		doyou = confirm("A new version of the EdgeStream Client software must be installed. Click OK to install."); 
		if (doyou == true)
		{
		   if(is_IE)
		   {
			ESPlugin.Url = "esClient";
			var ESinst = ESPlugin.DownLoadAndExecute();
			for (cnt=1; cnt<=100; cnt=cnt+1) 
			{
				version = ESPlugin.Version;
				pause(50);
				if ( version > 0 ) { pause(500); return true;}
			}
			return true; //timed out
		   }
		   else
		   {
		   	if (readCookie('InstallProgress') == 'NotComplete')
			{
			alert('The EdgeStream software installation may have been blocked.\n Please turn off any pop-up blockers until the installation is complete,\n or click on the blue "Get EdgeStream Software" button');
			}
			createCookie('InstallProgress', 'NotComplete', 1);	

			dl();	//do client download
			return true; //timed out
		   }
		}
		else {return false;}//didn't agree to install
	}
	else if (type=='upgradeShould') {
		doyou = confirm("A new version of the EdgeStream Client software is available. Install now?"); 
if (doyou == true)
		{
		   if(is_ie)
		   {
			ESPlugin.Url = "esClient";
			var ESinst = ESPlugin.DownLoadAndExecute();
			for (cnt=1; cnt<=100; cnt=cnt+1) 
			{
				version = ESPlugin.Version;
				pause(50);
				if ( version > 0 ) { pause(500); return true;}
			}
			return true; //timed out
		   }
		   else
		   {
		   	if (readCookie('InstallProgress') == 'NotComplete')
			{
			alert('The EdgeStream software installation may have been blocked.\n Please turn off any pop-up blockers until the installation is complete,\n or click on the blue "Get EdgeStream Software" button');
			}
			createCookie('InstallProgress', 'NotComplete', 1);	
			dl();	//do client download
			return true; //timed out
		   }
		}
		else {return false;}//didn't agree to install
	}
	else {	//newinstall
			
		if (readCookie('InstallProgress') == 'NotComplete')
		{
			alert('The EdgeStream software installation may have been blocked.\n Please turn off any pop-up blockers until the installation is complete,\n or click on the blue "Get EdgeStream Software" button');
		}
		createCookie('InstallProgress', 'NotComplete', 1);	
		
		doyou = confirm("The free EdgeStream client software installs in seconds and\n provides premium video delivery quality for Internet Explorer \n and for Firefox. Install it now?"); 
		if (doyou == true)
		{
		dl();	//do client download
		return true; //timed out
		}
		else {return false;}//didn't agree to install
	}
}
    
     
function pause(numberMillis) 
{
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) 
	{
		now = new Date();
		if (now.getTime() > exitTime ) return;
	}
}


function createCookie(name,value,hours)
{
	if (hours)
	{
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function eraseCookie(name)
{
	createCookie(name,"",-1);
}


function dl() 
{
 //if (window.navigator.userAgent.indexOf("SV1") != -1 || window.navigator.userAgent.indexOf("MSIE 7.0") != -1)
   {
    var dlfile = 'http://www.edgestream.com/software/release/edgestreamclient.exe';
    window.open(dlfile,'securewin','toolbar=0,location=no,directories=0,status=0,scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
    window.focus();
  }
  	RefrLoopCnt = 5;	//do up to 5 page refreshes while file is downloaded and executed
	createCookie('RefrLoopCnt', RefrLoopCnt,1);	
	doLoadRefr(8);	//initial refresh time is 8 seconds
}


function doLoadRefr(RefrTime)
{
    setTimeout( "refresh()", RefrTime * 1000 );
}

function refresh()
{
    window.location.href = sURL;
}


function RefreshLoop()
{
		RefrLoopCnt = readCookie('RefrLoopCnt');
		var version = ESPlugin.Version;
		if (version > 0)
		{
			RefrLoopCnt = 0;
			createCookie('RefrLoopCnt',RefrLoopCnt,1);
			eraseCookie('InstallProgress');	
		}
		else if (RefrLoopCnt > 0 ) 
		{
			RefrLoopCnt = RefrLoopCnt - 1; 
			createCookie('RefrLoopCnt',RefrLoopCnt,1);
			RefrTime = 5;
			doLoadRefr(RefrTime); 
		}
}
//-->