// JavaScript Document
/*

Made on July 17, 2009 by Frank

	-	From Preload7.js
	-	This is our preload... to be used by the framework
	-	function getFileType added ...
	-	function rectangle added...
*/

function embedFlash(src, scndPath){
	
	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);
}
 

function getFileType(filename) {

	var index, s, fileExtension;

    s=filename;
    index=s.lastIndexOf(".");
        // We have the last "."
    if (index!=-1) {
		s=s.substr(index);
        return s.toLowerCase();
    }
    else
		return "unknown";
}

function rectangle() {
        // This function returns a rectangle object
        // It supports all the common elements of an HTML object
        // A DIV element does not seem to work, because of an apparent minimum height requirement
        // This means we use a trick which requires the "Empty.gif" picture
        var rect;

        rect=new Image();
        rect.src="images/empty.gif";
        rect.style.position="absolute";
        return rect;
}