var flashVersion = 0;
var flashVersion_DONTKNOW = -1;
var acrobatVersion_DONTKNOW = -1;
var isPrinterFriendly = false;

function getShockVersion() {
	// this function returns a floating point value which should be the version of the Shockwave control or 0.0
	var agent = navigator.userAgent.toLowerCase();
	//alert("agent shock wave from navigator"+agent);
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		thearray = navigator.plugins;
		arraylen = thearray.length;
       
		for (i=0; i < arraylen; i++) {
  			theplugin = thearray[i];
			thename   = theplugin.name;
			thedesc   = theplugin.description;
			// If the plugin is Shockwave...
			if (thename.indexOf("Shockwave") != -1 && thename.indexOf("Director") != -1) {
				// ...extract the version information
				versionString = thedesc.substring(thedesc.indexOf("version ") + 8);
				alert("versionString" + versionString);
				if (versionString.indexOf(".") > 0) {
					versionMajor = versionString.substring(0,versionString.indexOf("."));
					versionMinor = versionString.substring(versionString.indexOf(".") + 1);
					if (versionMinor.indexOf(".") > 0)
						versionMinor = versionMinor.substring(0,versionString.indexOf(".")) + versionMinor.substring(versionMinor.indexOf(".") + 1);   
					versionString = parseInt(versionMajor) + "." + versionMinor;
				}
			    return (parseFloat(versionString));
			}
		} 
		return (0.0);
	}
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
    	//alert("agent shock wave from navigator"+agent);
    	document.write('<scr' + 'ipt language="VBScript"\> \n');
    	document.write('Function VBGetShockwaveVer(i) \n');
    	document.write('on error resume next \n');
    	document.write('Dim  swControl, swVersion \n');
    	document.write('swVersion = "0.0" \n');
    	document.write('set swControl = CreateObject("SWCtl.SWCtl." + CStr(i)) \n');
    	document.write('if (swControl is null) then \n');
    	document.write('set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i)) \n');
    	document.write('end if \n');
    	document.write('if (IsObject(swControl)) then \n');
    	document.write('swVersion = CStr(i) + ".0" \n');
    	document.write('swVersion = CStr(swControl.ShockwaveVersion("")) \n');
    	document.write('end if \n');
    	document.write('VBGetShockwaveVer = swVersion \n');
    	document.write('End Function \n');
		document.write('</scr' + 'ipt\> \n');
		
		for (i=8; i>0; i--) {
		 		versionString = VBGetShockwaveVer(i);
			if (versionString != "0.0") {
	       		// if we get 1.0 we assume it is actually 6.0
	       		versionNum = (versionString == "1.0" ? 6.0 : parseFloat(versionString))
	        	return (versionNum);
	      	}
    	}	
	}
	
	return (0.0);
}

//alert("getShockVersion(): " + getShockVersion());

function getFlashVersion() {
	
	var flashVer = -1;
	
  	with(navigator){
   		var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    	var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    	if (!isIE || !isWin){  
      		
      		if (plugins && plugins.length > 0){
        		var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        		desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        		if (desc == "") {
        			flashVer = -1;
        		}
        		else {
          			var descArr = desc.split(" ");
          			var tempArrMajor = descArr[2].split(".");
          			var verMajor = tempArrMajor[0];
          			var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          			var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          			flashVer =  parseFloat(verMajor + "." + verMinor);
        		}
      		}
    	  	// WebTV has Flash Player 4 or lower -- too low for all our stuff
	      	else if (userAgent.toLowerCase().indexOf("webtv") != -1) {
	      		flashVer = 4.0;
	      	}
    	}
    	else if (isIE) {
    		for(var i=9; i>0; i--){
				try{
					var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
					flashVer = i;
					break;
				}
				catch(e){}
			}
    	}
  	} 
	
	//alert("your version of flash is " + flashVer);
	return flashVer;
	}

var flashVersion = getFlashVersion();
//MHL 11/28/07 
//added minFlashVersion so it's not hard coded everywhere.
//currently, this is only being used by writeFlashMovieWithTransparency,
//which i just added.
var minFlashVersion = 8;

//MHL 11/28/07 
//added this method, which is similar to writeFlashMovie.  i've just added the
//wmode/transparent attribute to allow divs be layered on top of an SWF.
//i did start working on a flash JS object that's more robust, but i
//decided doing it this way for was less risky under the given
//circumstances.
function writeFlashMovieWithTransparency(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	if (flashVersion >= minFlashVersion) {
		document.write("<OBJECT tabindex=\"1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
		document.write("WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"><PARAM NAME=\"movie\" VALUE=\"" + movieName + "\"><PARAM ");
		document.write("NAME=\"quality\" VALUE=\"high\"><param name=\"wmode\" value=\"transparent\" /><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\"><EMBED ");
		document.write("src=\"" + movieName + "\" quality=\"high\" bgcolor=\"" + movieColor + "\"  WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\"></EMBED></OBJECT>");
	} else {
		if (movieAlt == "") {
			document.write("You need Flash " + minFlashVersion + " or higher in order to use this tool. <a href=\"/help/help.html?c=reqs\">Read our Site Requirements for more information.</a>");
		}
		document.write(movieAlt);
	}
}

function writeFlashMovieWithTransparencyToElement(theTagName, movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	var output = "";
	if (flashVersion >= minFlashVersion) {
		output+="<OBJECT tabindex=\"1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
		output+="WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"><PARAM NAME=\"movie\" VALUE=\"" + movieName + "\"><PARAM ";
		output+="NAME=\"quality\" VALUE=\"high\"><param name=\"wmode\" value=\"transparent\" /><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\"><EMBED ";
		output+="src=\"" + movieName + "\" quality=\"high\" bgcolor=\"" + movieColor + "\"  WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\"></EMBED></OBJECT>";
	} else {
		if (movieAlt == "") {
			output+="You need Flash " + minFlashVersion + " or higher in order to use this tool. <a href=\"/help/help.html?c=reqs\">Read our Site Requirements for more information.</a>";
		}
		output+=movieAlt;
	}
		
	document.getElementById(theTagName).innerHTML=output;
}

function writeFlashMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	var swfVars = (arguments[5] != 'undefined' && arguments[5] != null) ? arguments[5] : '';
	
	// This is so we don't have to change, recompile, and rejar WebCore.java every time there's a dimension change
	var overrideWidth = (arguments[6] != 'undefined' && arguments[6] != null) ? arguments[6] : false;
	if (overrideWidth) {
		movieWidth = overrideWidth;
	}
	// This is so we don't have to change, recompile, and rejar WebCore.java every time there's a dimension change
	var overrideHeight = (arguments[7] != 'undefined' && arguments[7] != null) ? arguments[7] : false;
	if (overrideHeight) {
		movieHeight = overrideHeight;
	}
	var objID = (arguments[8] != 'undefined' && arguments[8] != null) ? arguments[8] : false;
	
	//alert("your version of flash is " + flashVersion); 
	if (flashVersion >=8) {
		document.write("<OBJECT tabindex=\"1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
		if (objID) {
			document.write(" id=\"" + objID + "\" ");
		}
		//document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
		document.write("WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"><PARAM NAME=\"movie\" VALUE=\"" + movieName + "\"><PARAM ");
		document.write("NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\"><EMBED ");
		document.write("src=\"" + movieName + "\" quality=\"high\" bgcolor=\"" + movieColor + "\"  WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">");
		document.write("<NOEMBED>");
		if( movieAlt != "") {
			document.write(movieAlt);
		}else{
			document.write("Sorry, this browser is not configured to display video.");
		}
		document.write("</NOEMBED>");
		document.write("</EMBED>");
		document.write("</OBJECT>");
	}
	
	else {
		document.write("<p>The content intended for this section requires Flash 8 or higher. Please read our <a href=\"/help/help.html?c=reqs\">Site Requirements</a> for more information.</p>");
		if (movieAlt != "") {
			document.write(movieAlt);
		}
		
	}
	
	//document.write("your flash version: " + flashVersion);
	//flashVersion = 0;
}

function writeFlashMovieWithText(movieName, movieWidth, movieHeight, movieAlt, movieColor, introText) {
	var useAltForPrinterFriendly = (arguments[6] != 'undefined' && arguments[6] != null && arguments[6] == 'true') ? true : false;
	if (flashVersion >=8 && !(useAltForPrinterFriendly && isPrinterFriendly)) {
		document.write(introText);
		writeFlashMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor);
	}
	
	else {

		document.write("<p>The content intended for this section requires Flash 8 or higher. Please read our <a href=\"/help/help.html?c=reqs\">Site Requirements</a> for more information.</p>");

		if (movieAlt != "") {
			document.write(movieAlt);
		}
	}
}

function getFlashMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	var retVal = "";
	if (flashVersion >= 7) {
		retVal += "<OBJECT tabindex=\"1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
		retVal += " WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"><PARAM NAME=\"movie\" VALUE=\"" + movieName + "\"><PARAM ";
		retVal += " NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\"><EMBED ";
		retVal += " src=\"" + movieName + "\" quality=\"high\" bgcolor=\"" + movieColor + "\"  WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>";
		retVal += "</OBJECT>";
	}
	
	else {
		if (movieAlt == "") {
			retVal += "You need Flash 7 or higher in order to use this tool. <a href=\"/help/help.html?c=reqs\">Read our Site Requirements for more information.</a>";
		}
		retVal += movieAlt;
	}
	return retVal;
}

function writeShockMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
    //alert("your version of shcok is " + getShockVersion()); 
	if (getShockVersion() >= 7) {
		document.write("<object tabindex=\"1\" classid=\"clsid:166B1BCA-3F9C-11CF-8075-444553540000\"");
		//document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,0,0\"");
		document.write("WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\">");
		document.write("<param name=\"src\" value=\"" + movieName + "\"><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\">");
		document.write("<embed src=\"" + movieName + "\" bgcolor=\"" + movieColor + "\" pluginspage=\"http://www.macromedia.com/shockwave/download/\" WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"></embed>");
		document.write("</object>");
	}
	
	else {
		if (movieAlt == "") {
			document.write("You need Shockwave 7 or higher in order to use this tool. <a href=\"/help/help.html?c=reqs\">Read our Site Requirements for more information.</a>");
		}
		document.write(movieAlt);
	}
}



function getAcrobatVersion() {
	var agent = navigator.userAgent.toLowerCase(); 
	var acrobatVersion = 0;
	
	// NS3+, Opera3+, IE5+ Mac, Safari (support plugin array):  check for Acrobat plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
      for (i=0; i < navigator.plugins.length; i++ ) {
         var plugin = navigator.plugins[i];
         if (plugin.name.indexOf("Adobe Acrobat") > -1) {
            acrobatVersion = parseFloat(plugin.description.substring(30));
         }
      }
	}
   
	// IE4+ Win32:  write out an activex object and query it
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	 	document.write("<object id=\"Pdf1\" tabindex=\"1\" classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" width=\"0\" height=\"0\"></object>");
		// Call the ActiveX Object and get the Version Information
		var versionData = Pdf1.GetVersions();
		
		// Create an Array of all of the Plugin Names
		var versionDataArray = versionData.split(",");
	
		if(versionData.indexOf("7.0") != -1) {
			acrobatVersion = 7;
		}
		else if(versionData.indexOf("6.0") != -1) {
			acrobatVersion = 6;
		}
		else if(versionData.indexOf("5.0") != -1) {
			acrobatVersion = 5;
		}
	}

	// Can't detect in all other cases
	else {
		acrobatVersion = acrobatVersion_DONTKNOW;
	}
	
	return acrobatVersion;
}




function getElement(elementid) {
if(elementid!=null){
	//alert('changing ' + elementid + ' to ' + classname);
	// Level 1 DOM code	
	if (document.getElementById!=null) {
	    	return document.getElementById(elementid);
    	
	}
	// Microsoft DOM code
	else if (document.all!=null) {
		return document.all[elementid];
		
	}
	
    }
}	
//-----------------------------------------------
//changeAllNames 
//changes all DIV tags with the provided names with the passed in class name
//parameters:
//String aElementName - a name 
//String aClassName - a CSS class name
//-----------------------------------------------
function changeAllNames(aElementName, aClassName){
	elementArray = document.getElementsByTagName('DIV');
	for(increment = 0; increment<elementArray.length;increment++){
		if(elementArray[increment].name==aElementName){
			elementArray[increment].className=aClassName;
		}
	}
}//end changeAllNames

//-----------------------------------------------
//changeIDClass
//changes the id provided with the passed in class name
//parameters:
//String aID - a ID name 
//String aClassName - a CSS class name
//-----------------------------------------------
function changeIDClass(aID, aClassName){
if(getElement(aID)!=null){
	getElement(aID).className=aClassName;
	}
		}
function changeIDClassEmail(aID, aClassName){
if(getElement(aID)!=null){
	getElement(aID).className=aClassName;
	for(i=1;i<=5;i++)
	{
	if(i!=aID)
	{
	getElement(i).className="hidden";
	}
	}
	}
}//end changeIDClassEmail



