﻿// JavaScript Document

/* some changes by: DexterT

function loadScript : changed, the last loadScript isn't working on other browser
					: now its working on safari, mozilla, netscape, ie6 and ie7 havent fully tried on the opera but it seems to be working

function f2 : deleted because loadScript function is not using/calling this anymore
function mozLoad : deleted because its not used
function clearBody : deleted because its not used
function preload : deleted because it not properly working, still finding a way to revise it
function checkStatus : deleted together with preload
funciton checkLoadObjectStatus : deleted together with checkStatus
function objectReady2 : deleted together with checkLoadObjectStatus
function clearBody : deleted because its not used
function firstObject : deleted because its not used (dont know what function will call this)
function stopPreloading : deleted because its not used (and it doesnt have a code inside still finding some codes to fit in to it)

*/

function embedFlash(src, scndPath){
	// Originally made by Robert. Needs to be enhanced with new flash detection
	var myFlash, param, objectNode, tmpImage, hasFlash, str, len , i ;
		
		//check for the file type if we support 
		if(getFileType(src)!=".swf"){
			alert("File type not supported");
			return null;
		}
		hasFlash=detectFlash();
		if(!hasFlash){
			window.alert("This website shows better if you have Macromedia Flashplayer installed");
			if(typeof(scndPath)!="undefined"){	
				tmpImage = new Image();
				tmpImage.src=scndPath;
				tmpImage.style.position="absolute";				
				return tmpImage;
			}
			else{
				tmpImage = rectangle();
				return tmpImage;
			}
		}
        myFlash=document.createElement("embed");
        myFlash.style.position="absolute";
        myFlash.src=src;
        myFlash.setAttribute("menu","false");
        if (navigator.appName!="Microsoft Internet Explorer") {
                 //this is for mozilla browser it is required to put into append the paramnode to the object node
            	myFlash.pluginspage="http://www.macromedia.com/go/getflashplayer";
	            myFlash.type="application/x-shockwave-flash";
	            objectNode=document.createElement("object");
    	        objectNode.setAttribute("data", src);  //use the data preoperty than src in order to use the movie param
        	    //   objectNode.setAttribute("type", 'application/x-shockwave-flash');
	            //  objectNode.setAttribute ("menu", "false");
    	        objectNode.style.position="absolute";
        	    paramNode=document.createElement("param");
            	paramNode.setAttribute("movie", src);
	            paramNode.setAttribute ("menu", "false");     
    	        objectNode.appendChild(paramNode);
				objectNode.myFlash=true;
            	return objectNode;
         }
	//myFlash.setAttribute("wmode", "transparent");
        myFlash.setAttribute("menu", "false");
        myFlash.myFlash=true;
        return myFlash;
}


// Next from Flash support site
function JSGetSwfVer(i){ // Just rename to avoid confusion with the one in the functions file
	// We can leave it here and remove from the functions file
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	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;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// End from Flash support site 
 
function detectFlash() {
	if (navigator.userAgent.indexOf("MSIE")>=0) {
		flashVersion=VBGetSwfVer(1); 
	}
	else
		flashVersion=JSGetSwfVer();
	return (flashVersion!=-1);
}
 
//changed by dexterT
function loadScript(src, type, charset, onloadFunc) {
	var scr;

	if (typeof(src)!="string")
		return null;

	scr=document.createElement("script");
	scr.check=false;
	scr.src=src;
	scr.defer=true;
	scr.type=type;
	scr.charset=charset;
	scr.onreadystatechange = function() { //this one is for MSIE
			if ((scr.readyState=="complete")||(scr.readyState=="loaded"))
				if(typeof(onloadFunc) == "function") {
					if(!scr.check) {
						scr.check = true;
						window.setTimeout(onloadFunc, 0);
					}
				}
		}
	scr.onload = function () { //this one is for FireFox, Safari Netscape
			if(typeof(onloadFunc) == "function")
				if(!scr.check) {
					scr.check = true;
					window.setTimeout(onloadFunc, 0);
				}
		}
	
	if ((scr.readyState=="complete")||(scr.readyState=="loaded"))
		if(typeof(onloadFunc) == "function") 
			if(!scr.check) {
				scr.check = true;
				window.setTimeout(onloadFunc, 0);
			}
	
	document.getElementById("headId").appendChild(scr);
	return scr;
}