var requiredVersion = 7;
var useRedirect = false;
var maxVersion = 9;             // highest version we can actually detect
actualVersion = 0;          // version the user really has
var flashVersion=0;
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows

jsVersion = 1.1;

if(isIE && isWin){
	try{
		var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
		if (axo != null)  flashVersion = axo.getVariable("$version").split(" ")[1].split(",")[0];
	} catch(e) {flashVersion=0}
}



function detectFlash() {  
	if (!(isIE && isWin)) {
		if (navigator.plugins) {
			if (navigator.plugins["Shockwave Flash 2.0"]|| navigator.plugins["Shockwave Flash"]) {
				var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
				flashVersion = parseInt(flashDescription.substring(16));
			}
		} else {
			if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  
		}
	}
	
} // end detectFlash

detectFlash();
function writeFlash(width, height, flash, html, PromptForUpgrade,color, id, minVersion,parameters){
	if(!useRedirect){
			if(flashVersion>=minVersion){
			var oeTags = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + minVersion + ',0,0,0" width="' + width + '" height="' + height + '" id="' + id + '" align="middle">\n'
			+ '<param name="allowScriptAccess" value="sameDomain" />\n'
			+ '<param name="FlashVars" value="' + parameters + '" />\n'
			+ '<param name="scale" value="noscale" />\n'
			+ '<param name="movie" value="' + flash + '" />\n'
			+ '<param name="quality" value="high" />\n'
			+ '<param name="bgcolor" value="' + color + '" />\n'
			+ '<embed FlashVars="' + parameters + '" src="' + flash + '" quality="high" scale="noscale" bgcolor="' + color +'" width="' + width + '" height="' + height +'" name="' + id + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'
			+ '<\/object>\n';
			//alert(oeTags);
			document.write(oeTags);
		} else {
			if(!getCookie("flashupgrade")) {
				if(PromptForUpgrade)  requestUpgrade()
				setCookie("flashupgrade","persession")
			}
				document.write(html)
			}
	}
}

function writeTransFlash(width, height, flash, html, color, id, parameters){
	if(!useRedirect){
		if(hasRightVersion){
			var oeTags = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id=somename" align="middle">\n'
			+ '<param name="allowScriptAccess" value="sameDomain" />\n'
			+ '<param name="FlashVars" value="' + parameters + '" />\n'
			+ '<param name="scale" value="noscale" />\n'
			+ '<param name="movie" value="' + flash + '" />\n'
			+ '<param name="quality" value="high" />\n'
			+ '<param name="wmode" value="transparent" />\n'
			+ '<embed FlashVars="' + parameters + '" src="' + flash + '" quality="high" scale="noscale" wmode="transparent" width="' + width + '" height="' + height +'" name="elux" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'
			+ '<\/object>\n';
			
			document.write(oeTags);
		}
		else{
			document.write(html);
		}
	}
}


// GENERAL FUNCTIONS

function showMedia(page, url, description, media, mediaid){
	window.open(page + '?media=' + media + '&url=' + url + '&title=' + description + '&id=' + mediaid, 'Window','toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=1,scrollbars=0');
}

function popup2(url,pwidth,pheight){
    window.open(url,null,'toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=0,scrollbars=1,HEIGHT='+pheight+',WIDTH='+pwidth);
}

function setFocus(formname,fieldname){
    if(eval("document."+formname)) eval("document."+searchForm+"."+fieldname+".focus()");
}

function imgSwap(imgName, newImgSource){
	if(document.getElementById(imgName)){
		eval("document.getElementById('" + imgName + "').src = " + newImgSource + ".src");
	}
}

function preload(imgObj,imgSrc){
	if(document.images){
		eval(imgObj+' = new Image()');
		eval(imgObj+'.src = "'+imgSrc+'"');
	}
}


function doPrint(){
	if ((window.print) && (document.all)){
		window.print();
		//window.close();
	} else if (window.print) {
		window.print();
	} else if ((document.all) && !(navigator.userAgent.indexOf("Mac") != -1)) {			
		var printWindowObject = "<object id='printWindowObject1' width=0 height=0 classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></"+"object>";
		document.body.insertAdjacentHTML("BeforeEnd",printWindowObject);
		window.document.printWindowObject1.ExecWB(6,1);
		//ID=window.setTimeout("window.close();",100);
	}
}

function requestUpgrade() {
if(confirm("You do not appear to have the correct version of Flash to properly view this page.Would you like to upgrade to the later version of Flash?\nPress Ok to upgrade.")) {
var newwin=window.open('','getFlash',"width=600,height=400,scrollbars,toolbar,statusbar")
newwin.document.writeln("<html>")
newwin.document.writeln('<body onunload="opener.location.reload(true)" onbeforeunload="opener.location.reload(true)">')
newwin.document.writeln('<iframe border="0" width="100%" height="100%" scrolling="auto" src="http:\/\/www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"></iframe>')
newwin.document.writeln("</body>")
newwin.document.writeln("</html>")
}


}


function setCookie (name, value, lifespan, access_path) {
      
  var cookietext = name + "=" + escape(value)  
    if (lifespan != null) {  
      var today=new Date()     
      var expiredate = new Date()      
      expiredate.setTime(today.getTime() + 1000*60*60*24*lifespan)
      cookietext += "; expires=" + expiredate.toGMTString()
    }
    if (access_path != null) { 
      cookietext += "; PATH="+access_path 
    }
   document.cookie = cookietext 
   return null  
}

function getCookie(Name) {
  var search = Name + "="                       
  var CookieString = document.cookie            
  var result = null                               
  if (CookieString.length > 0) {                
    offset = CookieString.indexOf(search)       
    if (offset != -1) {                         
      offset += search.length                   
      end = CookieString.indexOf(";", offset)   
      if (end == -1)                            
        end = CookieString.length               
      result = unescape(CookieString.substring(offset, end))         
                                                
      } 
    }
   return result                                
}


