// system requirements functions
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
function JSGetSwfVer(i) {
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	return flashVer;
} 
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			versionString     = versionMajor + "." + versionRevision;
			versionNum        = parseFloat(versionString);
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}

function buildSysReqString() {
    var requiredMajorVersion = 8;
    var requiredMinorVersion = 0;
    var requiredRevision = 0;
    var jsVersion = 1.0;
    var javaCheck = "0";
    var resCheck  = "0";
    var ieCheck   = "0";
    var puCheck   = "0";
	var goodSWFversion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    var allvars = new Array();
    allvars[allvars.length] = (checkIeVersion(6))        ? "1" : "0";
    allvars[allvars.length] = (checkPopup())             ? "1" : '0';
	allvars[allvars.length] = (goodSWFversion)           ? "1" : "0";
	allvars[allvars.length] = 1;//dummy for java
	allvars[allvars.length] = 1;//dummy for java memory
    allvars[allvars.length] = (checkResolution(800,600)) ? "1" : "0";

    var varstr = "";
    for (var i in allvars) {
        varstr += allvars[i];
    }

    return varstr;
}

function getSWVersion () {

	var tVersionString = "";

	if (navigator.mimeTypes && navigator.mimeTypes["application/x-director"] && navigator.mimeTypes["application/x-director"].enabledPlugin) {
		if (navigator.plugins && navigator.plugins["Shockwave for Director"] && (tVersionIndex = navigator.plugins["Shockwave for Director"].description.indexOf(".")) != - 1) {	
			var tVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex-2, tVersionIndex+2);
		}
	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 )) {
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('set tSWControl = CreateObject("SWCtl.SWCtl") \n');
		document.write('if IsObject(tSWControl) then \n');
		document.write('tVersionString = tSWControl.ShockwaveVersion("") \n');
		document.write('end if');
		document.write('</SCRIPT\> \n');
	}
	
	return tVersionString;
	
}
function checkShockwave() {
    var tMajorVersion = 10;
    var tMinorVersion = 1;
    var tShockwaveFound = 0;
    if (navigator.mimeTypes && navigator.mimeTypes["application/x-director"] && navigator.mimeTypes["application/x-director"].enabledPlugin) {
      if (navigator.plugins && navigator.plugins["Shockwave for Director"] && (tVersionIndex = navigator.plugins["Shockwave for Director"].description.indexOf(".")) != - 1) {
        var tMajorVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex-2, tVersionIndex);
       var tMinorVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex+1, tVersionIndex+2);
       if (parseInt(tMajorVersionString) >= tMajorVersion) {
         if (tMinorVersion > 0) {
           if (parseInt(tMinorVersionString) >= tMinorVersion) {
             tShockwaveFound = 1;
        }
         } else {
           tShockwaveFound = 1;
         }
        }
      }
    } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 )) {
      var tVersionString = "";
      document.write('<SCRIPT LANGUAGE=VBScript\> \n');
      document.write('on error resume next \n');
      document.write('set tSWControl = CreateObject("SWCtl.SWCtl") \n');
      document.write('if IsObject(tSWControl) then \n');
      document.write('tVersionString = tSWControl.ShockwaveVersion("") \n');
      document.write('end if');
      document.write('</SCRIPT\> \n');
      if (tVersionString != "") {
        tVersionIndex = tVersionString.indexOf(".")
       var tMajorVersionString = tVersionString.substring(tVersionIndex-2, tVersionIndex);
       var tMinorVersionString = tVersionString.substring(tVersionIndex+1, tVersionIndex+2);
       if (parseInt(tMajorVersionString) >= tMajorVersion) {
         if (tMinorVersion > 0) {
           if (parseInt(tMinorVersionString) >= tMinorVersion) {
             tShockwaveFound = 1;
           }
         } else {
           tShockwaveFound = 1;
         }
       }
      }
    }
    if ( tShockwaveFound ) {
      document.write('<OBJECT classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"');
      document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,1,0,11"');
      document.write(' ID=$TI WIDTH=$WI HEIGHT=$HE>');
      document.write('<PARAM NAME=src VALUE="$MO">');
      document.write('<PARAM NAME=swStretchStyle VALUE=$SS>');
      document.write('<PARAM NAME=swRemote VALUE="');
      document.write("$PR");
      document.write('">\n');
      document.write('<EMBED SRC="$MO"');
      document.write(' $PE WIDTH=$WI HEIGHT=$HE swStretchStyle=$SS ');
      document.write('swRemote="');
      document.write("$PR");
      document.write('"');
      document.write(' TYPE="application/x-director" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveDirector">');
      document.write('</EMBED>');
      document.write('</OBJECT>');
    } else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
      document.write('A newer version of Shockwave must be installed to display this content. Please update your Shockwave installation.');
    }
}
function checkIeVersion(min) {
    var str;
    var browser = "notie";
    var version = "-1";
    if (navigator.userAgent) {
        str = navigator.userAgent;
        str = str.replace(/^\s+|\s+$/);
        str = str.split(";");
        str = str[1];
        str = str.replace(/^\s+|\s+$/,"");
        str = str.split(" ");
        browser = str[0];
        version = str[1];
        if (parseFloat(version) >= min) {
            return true;
        }
    }
    return false;
}
function checkScreenWidth(min) {
    return screen.width >= parseFloat(min);
}
function checkScreenHeight(min) {
    return screen.height >= parseFloat(min);
}
function checkResolution(w,h) {
    return checkScreenWidth(w) && checkScreenHeight(h);
}
function checkPopup() {
    var child=window.open("popup.html");
    if (child) {
        child.close();
        return true;
    }
    return false;
}
function checkJavaPlugin() {
    try {
        var vendor = document.applets[0].getProp("java.vendor");
        var version = document.applets[0].getProp("java.version");
        return (vendor.substring(0,3) == "Sun" && parseFloat(version) >= 1.5 );
    }
    catch (e) { return false; }
}
function checkJavaMem() {
    try {
        var mm = document.applets[0].getMaxMem();
        return (mm >= 128000000);
    }
    catch (e) { return false; }
}
function getFlashObject(id) {
    //if (window.document[id]) {
    //    alert("A");
    //    return window.document[id];
    //}
    if (navigator.appName.indexOf("Microsoft Internet")==-1) {
        if (document.embeds && document.embeds[id]) {
            return document.embeds[id]; 
        }
    }
    else { // if (navigator.appName.indexOf("Microsoft Internet")!=-1) 
       return document.getElementById(id);
    }
}
// end system reqs page

// load a div with a flash object
function loadDiv(flashItem,divID,id,newWidth,newHeight,bgcolor,flashVARS){
	var theHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='100%' height='100%' id='"+id+"' align='left'>";
	theHTML += "<param name='allowScriptAccess' value='sameDomain' />";
	theHTML += "<param name='movie' value='"+flashItem+"' />";
	theHTML += "<param name='quality' value='high' />";
	theHTML += "<param name='scale' value='noscale' />";
	theHTML += "<param name='bgcolor' value='#"+bgcolor+"' />";
	//theHTML += "<param name='id' value='#"+id+"' />";
	if(flashVARS== undefined){
        flashVARS = "";
		//
	}else{
		theHTML += "<param name='FLASHVARS' value='"+flashVARS+"' />";	
	}
	theHTML += "<embed name='"+id+"' swliveconnect='true' src='"+flashItem+"' flashvars='"+flashVARS+"' quality='high' bgcolor='#"+bgcolor+"' width='100%' height='100%' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	theHTML += "</object>";
	var d = document.getElementById(divID);
	d.innerHTML = theHTML;
}
