﻿// JScript File

function RenderSwfObject(objContainer, paramStr, strObjectName, swfWidth, swfHeight, NotifyIfNoFlashInstalled, isUCp) {
    
    if(objContainer==undefined || objContainer==null) return;
    if (DetectFlashPluginVerstion() < 8) {
        if (NotifyIfNoFlashInstalled == true) {
            objContainer.innerHTML = '<div id="divNoFlash">This page requires Flash player 8 or above - Download it here: <a href="http://www.adobe.com/go/getflashplayer">http://www.adobe.com/go/getflashplayer</a></div>';
        }
    }
    else {
        if (objContainer.id == "divBattleFlashContainer") {
            if(isUCp == "yes"){
                swfWidth = 477;
            }
            objContainer.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + swfWidth + '" height="' + swfHeight + '" id="' + strObjectName + '" align="middle"><param name="base" value="/"/><PARAM NAME="FlashVars" VALUE="isUCP=' + isUCp + '"><param name="allowScriptAccess" value="always" /><param name="movie" value="' + paramStr + '"/><param name="quality" value="high" /><param name="menu" value="false"/><PARAM NAME="WMode" VALUE="Transparent"><embed src="' + paramStr + '" quality="high"  width="' + swfWidth + '" height="' + swfHeight + '" name="' + strObjectName + '" align="middle" base="/" menu="false" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" WMode="Transparent" flashvars="isUCP=' + isUCp + '" /></object>';
        }
        else {
            objContainer.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + swfWidth + '" height="' + swfHeight + '" id="' + strObjectName + '" align="middle"><param name="base" value="/"/><param name="allowScriptAccess" value="always" /><param name="movie" value="' + paramStr + '"/><param name="quality" value="high" /><param name="menu" value="false"/><PARAM NAME="WMode" VALUE="Transparent"><embed src="' + paramStr + '" quality="high"  width="' + swfWidth + '" height="' + swfHeight + '" name="' + strObjectName + '" align="middle" base="/" menu="false" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" WMode="Transparent" /></object>';
        }

    }    
}


function getFlashMovie(movieName) {

    var isIE = navigator.appName.indexOf("Microsoft") != -1;    
    return (isIE) ? window[movieName] : document[movieName];
} 

//function $(strId)
//{
//    return window.document.getElementById(strId);
//}

function GetObjectById(strId) 
{
    return window.document.getElementById(strId);
}

function CheckUserWebBrowser()
{
	var userAgent = window.navigator.userAgent;
	
	if (userAgent.indexOf('MSIE 8.0') > -1)
	{
	    return 'IE 8';
	}
	if(userAgent.indexOf('MSIE 7.0') > -1)
	{
		 return 'IE 7';
	}
	if(userAgent.indexOf('MSIE 6.0') > -1)
	{
		return 'IE 6';
	}
	if(userAgent.indexOf('Firefox') > -1)
	{
		return 'Mozilla';
	}
	if(window.opera!=null)
	{
	    return "Opera";
	}
	return 'unknow';
}
if(CheckUserWebBrowser().substr(0,2)!="IE") //Add DOM Node methods to not IE browsers
{
    Node.prototype.replaceNode=function(node){

        this.parentNode.replaceChild(node,this);

    }

    Node.prototype.removeNode=function(removeChildren){

        if(removeChildren)

            return this.parentNode.removeChild(this);

        else{

            var range=document.createRange();

            range.selectNodeContents(this);

            return this.parentNode.replaceChild(range.extractContents(),this);

        }

    }

    Node.prototype.swapNode=function(node){

        var nextSibling=this.nextSibling;

        var parentNode=this.parentNode;

        node.parentNode.replaceChild(this,node);

        parentNode.insertBefore(node,nextSibling);

        }

   }
function DetectFlashPluginVerstion()
{
    var i_flash = false;
    var v_flash = 0;
    if(CheckUserWebBrowser().indexOf("IE")!=-1)
    {
        try
        {
            var testFlashObj=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.9")
            i_flash=true;
            v_flash=9;
        }
        catch(e)
        {
            i_flash=false
            
             try
            {
                var testFlashObj=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8")
                i_flash=true;
                v_flash=8;
            }
            catch(e)
            {
                i_flash=false
                try
                {
                    var testFlashObj=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
                    i_flash=true;
                    v_flash=7;
                }
                catch(e)
                {
                    i_flash=false
                }
                
            }
        }
       
       
    }
    if (navigator.plugins && navigator.plugins.length>0)
    {
        for (var i=0; i < navigator.plugins.length; i++) 
        {
            if (navigator.plugins[i].name.toLowerCase().indexOf("shockwave flash") >= 0) 
            {
                i_flash = true;
                //v_flash = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase().lastIndexOf("flash ") + 6, navigator.plugins[i].description.length).substr(0,1);
                pattern = '[0-9]+';
                str = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase());
                flashVersion = str.match(pattern);
                v_flash=flashVersion;
            }
        }
    }
    if(!i_flash)
    {
        return 0;
    }
    else
    {
        return v_flash;
    }
    
}