﻿<!--
/*
* מחלקה להדבקת שיתחי פלאש בזמן ריצה
* SWFObject
*/

/*
* דוגמא לשימוש
* var my_swf = new SWFObject(my.swf, 100, 100);
* my_swf.quality = "LOW";
* my_swf.transparent = true;
* my_swf.applyIn("my_div");
*/

/* הערות
* אין להתחל שום מאפיין לאחר הדבקת הפלאש השינוי לא יתבצע
* remove מה שניתן לעשות זה להשתמש בשיטה 
* שמוחקת את תוכן הדיו שמחזיק אותו
*/



//סטטי
//alert(navigator.appVersion);
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;
var isMac = (navigator.appVersion.toLowerCase().indexOf("macintosh") != -1) ? true : false;

var SWFObjectCounter = 0;

var FlashDetection = new Object();
FlashDetection.controlVersion = function()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
    
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

FlashDetection.getSwfVer = function()
{
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	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;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// 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;
	else if ( isIE && isWin && !isOpera ) flashVer = this.controlVersion();

	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
FlashDetection.DetectFlashVer = function(reqMajorVer, reqMinorVer, reqRevision)
{

	versionStr = this.getSwfVer();
	
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}


//בנאי
/*
* @Param    get_url     נתיב לקובץ הפלאש
* @Param    get_width     גובה הפלאש בדף
* @Param    get_height     רוחב הפלאש בדף
*/
function SWFObject(get_url, get_width, get_height) {
    //מאפיינים
    this.id = SWFObjectCounter;
    this.url = get_url;
    this.width = get_width;
    this.height = get_height;
    
    this.quality = "high";
    this.transparent = false;
    this.allowScriptAccess = "always";
    this.swliveconnect = "true";
 
    this.holderID = null;
    this.object_str = null;	
    this.object_tag = null;
    this.embed_tag = null;
    
    this.detectFlashVersion = true;
    this.requiredFlashVersion = new Object();
    this.requiredFlashVersion.majorVersion = 9;
    this.requiredFlashVersion.minorVersion = 0;
    this.requiredFlashVersion.revision = 45;


    this.setRequiredFlashVersion = function(majorVersion, minorVersion, revision) {
        this.requiredFlashVersion.majorVersion = majorVersion;
        this.requiredFlashVersion.minorVersion = minorVersion;
        this.requiredFlashVersion.revision = revision;
    }

    /*
    ***  שיטה פנימית ליצירת תג param
    * @Param    get_url     נתיב לקובץ הפלאש
    * @Param    get_width     גובה הפלאש בדף
    * @Param    get_height     רוחב הפלאש בדף
    */
    //שיטות
     this.createNewParam = function(param, value) {
		return "<param id=\""+param+"_prm\" name=\""+param+"\" value=\""+value+"\" />";
	}
	
	/*
    ***  שיטה פנימית ליצירת תג הOBJECT
    */
	this.buidObjectTag = function() {
	    this.object_str = "<object ";
        this.object_str += "classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";        
        this.object_str += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+this.requiredFlashVersion.majorVersion+","+this.requiredFlashVersion.minorVersion+","+this.requiredFlashVersion.revision+",0\" ";
        this.object_str += "width=\""+this.width+"\" ";
        this.object_str += "height=\""+this.height+"\" ";
        this.object_str += "id=\"swf"+SWFObjectCounter+"_obj\" ";
        this.object_str += ">";
        
	    this.object_str += this.createNewParam("movie", this.url);
	    this.object_str += this.createNewParam("quality", this.quality);
	    this.object_str += this.createNewParam("allowScriptAccess", this.allowScriptAccess);
	    if(this.transparent) this.object_str += this.createNewParam('wmode', 'transparent');
    	
	    this.object_str += "<embed ";
	    this.object_str += "src=\""+this.url+"\" ";
	    this.object_str += "quality=\""+this.quality+"\" ";
	    if(this.transparent) this.object_str += "wmode=\"transparent\" ";
	    this.object_str += "allowScriptAccess=\""+this.allowScriptAccess+"\" ";
	    this.object_str += "swliveconnect="+this.swliveconnect+" ";
	    this.object_str += "width=\""+this.width+"\" ";
	    this.object_str += "height=\""+this.height+"\" ";
		//this.object_str += "id=\"swf"+SWFObjectCounter+"_obj\" ";
	    this.object_str += "name=\"swf"+SWFObjectCounter+"_obj\" ";
	    this.object_str += "type=\"application/x-shockwave-flash\" ";
	    this.object_str += "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
	    this.object_str += "/></object>";
	    
	    SWFObjectCounter++;
	    
	    return this.object_str;
	}
	
	/*
    ***  שיטה להצגת קובץ הפלאש לתוך הדף בdiv
    * @Param    get_holderID     הID של הDIV
    */
    this.applyIn = function(get_holderID) {
        var hasProductInstall = FlashDetection.DetectFlashVer(6, 0, 65);
        var hasRequestedVersion = FlashDetection.DetectFlashVer(this.requiredFlashVersion.majorVersion, this.requiredFlashVersion.minorVersion, this.requiredFlashVersion.revision);

        if ( hasProductInstall && !hasRequestedVersion && !isMac && this.detectFlashVersion) 
        {
            //התקנת פלאש דרך הפלאש
            var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
	        var MMredirectURL = window.location;
            document.title = document.title.slice(0, 47) + " - Flash Player Installation";
            var MMdoctitle = document.title;
            
            var object_str = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
            object_str += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab\" ";
            object_str += "width=\"400\" height=\"320\" id=\"FPI\" >";
            object_str += this.createNewParam("movie", "playerProductInstall/playerProductInstall.swf");
            object_str += this.createNewParam("FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"");
	        object_str += this.createNewParam("quality", "high");
	        object_str += this.createNewParam("allowScriptAccess", this.allowScriptAccess);
	        object_str += this.createNewParam('wmode', 'transparent');
	        object_str += "<embed src=\"playerProductInstall/playerProductInstall.swf\" ";
	        object_str += "quality=\"high\" wmode=\"transparent\" allowScriptAccess=\""+this.allowScriptAccess+"\" ";
	        object_str += "swliveconnect=true width=\"400\" height=\"320\" ";
            object_str += "name=\"FPI\" type=\"application/x-shockwave-flash\" ";
	        object_str += "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
	        object_str += "/></object>";
            
            var contentDiv_style = "direction:ltr;width:400px;height:320px;border:solid 1px #cccccc;background-color:#ffffff;text-align:right;padding:0px;";
            
            var div_style = "height:100%;width:100%;text-align:center;";
            div_style += "z-index:9999;position:absolute;left:0px;top:0px;";
            
            var content_div = "<div style=\""+contentDiv_style+"\">";
            //content_div += "<h2>עדכון נגן פלאש</h2>";
            //content_div += "<font style=\"font:arial;font-size:12px;\">טקסט טקסט טקסט טקסט טקסט";
            //content_div += "<br />טקסט טקסט טקסט טקסט טקסט";
            //content_div += "</font><br /><br />";
            content_div += object_str;
            content_div += "</div>";
            
            var div_str = "<div style=\""+div_style+"\"><br /><br /><br /><center>"+content_div+"</center></div>";
            
            document.write(div_str);
        }
        else if( hasRequestedVersion || !this.detectFlashVersion)
        {
            //הגירסה מותקנת
            this.holderID = document.getElementById(get_holderID);
            this.holderID.innerHTML = this.buidObjectTag();
            this.object_tag = document.getElementById("swf"+this.id+"_obj");
            this.embed_tag = document["swf"+this.id+"_obj"];
        }
        else
        {
            //לא מצליח לזהות התקנה כלשהיא
            var object_str = "<table cellpadding=\"0\" cellspacing=\"0\" >";
            object_str += "<tr><td colspan=\"3\"><img alt=\"\" src=\"playerProductInstall/f_top.jpg\" /></td></tr>";
            object_str += "<tr><td><img alt=\"\" src=\"playerProductInstall/f_left.jpg\" /></td>";
            object_str += "<td><a href=\"playerProductInstall/getFlashPlayer.htm?redirect="+window.location.href+"\">";
            object_str += "<img alt=\"\" src=\"playerProductInstall/f_button.jpg\" border=\"0\" /></a></td>";
            object_str += "<td><img alt=\"\" src=\"playerProductInstall/f_right.jpg\" /></td></tr>";
            object_str += "<tr><td colspan=\"3\"><img alt=\"\" src=\"playerProductInstall/f_bottom.jpg\" /></td></tr>";
            object_str += "</table>";
            
            //http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\
            var contentDiv_style = "direction:ltr;width:400px;height:320px;border:solid 1px #cccccc;background-color:#ffffff;text-align:right;padding:0px;";
            
            var div_style = "height:100%;width:100%;text-align:center;";
            div_style += "z-index:9999;position:absolute;left:0px;top:0px;";
            
            var content_div = "<div style=\""+contentDiv_style+"\">";
            content_div += object_str;
            content_div += "</div>";
            
            var div_str = "<div style=\""+div_style+"\"><br /><br /><br /><center>"+content_div+"</center></div>";
            
            document.write(div_str);
        }
    
    
        
    }
    
    /*
    ***  שיטה המוחקת את תוכן הפלאש מהdiv
    */
    this.remove = function() {
        this.holderID.innerHTML = "";
    }
    
    /*
    ***  שינוי גודל שטח הפלאש
    * @Param    get_width     גובה 
    * @Param    get_height     רוחב 
    */
    this.resize = function(get_width, get_height) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            window["swf"+this.id+"_obj"].width = get_width;
            window["swf"+this.id+"_obj"].height = get_height;
        } else {
            if(window["swf"+this.id+"_obj"])
            {
                window["swf"+this.id+"_obj"].width = get_width;
                window["swf"+this.id+"_obj"].height = get_height;
            }
            document["swf"+this.id+"_obj"].width = get_width;
            document["swf"+this.id+"_obj"].height = get_height;     
        }
    }
    
    /*
    ***  מחזיר את הסרט - יעיל בשימוש אם ExternalInterface
    */
    this.movie = function() {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window["swf"+this.id+"_obj"];
        } else {
            return document["swf"+this.id+"_obj"];
        }
    }
}
/*
* מחלקה להדבקת שיתחי פלאש בזמן ריצה
* SWFObject
*/
//-->
