﻿// JScript File

function RenderSwfObject(objContainer,paramStr,strObjectName,swfWidth,swfHeight,NotifyIfNoFlashInstalled,baseUrl)
{
    
    if(objContainer==undefined || objContainer==null) return;
    if(!baseUrl)
    {
        baseUrl="./";
    }
    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
    {
        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="'+baseUrl+'"/><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="'+baseUrl+'" menu="false" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" WMode="Transparent" /></object>';
        //objContainer.innerHTML='<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+swfWidth+'" height="'+swfHeight+'"" align="middle" id="'+strObjectName+'" name="'+strObjectName+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ><param name="base" value="'+baseUrl+'"/><param name="movie" value="'+paramStr+'" /> <param name="quality" value="high" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="scale" value="showall" /> <param name="wmode" value="Transparent" /> <param name="devicefont" value="false" /> <param name="bgcolor" value="#ffffff" /> <param name="menu" value="false" /> <param name="allowFullScreen" value="false" /> <param name="allowScriptAccess" value="always" /> <param name="salign" value="" /> </object>';
    }
   
}
function $(strId)
{
    return window.document.getElementById(strId);
}
function CheckUserWebBrowser()
{
	var userAgent = window.navigator.userAgent;
	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);
            }
        }
    }
    if(!i_flash)
    {
        return 0;
    }
    else
    {
        return v_flash;
    }
    
}
function getCurrentPageUrl()
{
    var url=window.location.href;
    var questionMarkId=url.indexOf("?");
    var pureUrl;
    if(questionMarkId==-1)
    {
        pureUrl=url;
    }
    else
    {
        pureUrl=url.substr(0,questionMarkId);
    }
    
    return pureUrl;
}
function setAdsDisplayStatus(isShow)
{
    var divAds=document.getElementById("dap300x250");
    if(divAds)
    {
        if(isShow==false)
        {
            divAds.style.display="none";
        }
        else
        {
            divAds.style.display="block";
        }
    }
}

function searchHint(keywords)
{
    window.open("http://search.live.com/results.aspx?q="+escape(keywords)+"&adlt=STRICT&FORM="+document.getElementById("formCode").value,"searchForm");
}

function fixFlashFocusForIE()
{
    if(CheckUserWebBrowser().substr(0,2)=="IE")
    {return true;}
    else{return false;}
}
function frmLiveSearch_OnFocus()
{
    if(fixFlashFocusForIE()){document.getElementById('divHover').style.display='block';}
}

/*=======For cookie=========*/
function createCookie()
{

    SetCookie("FlashCookie","1");
}

function getCookie()
{
    return GetCookieValue("FlashCookie");
}

// the cookie will expires immediately when the window be closed.
function SetCookie(sName, sValue)
{
document.cookie = sName + "=" + escape(sValue) +";";
}

function GetCookieValue(sName)
{
    // cookies are separated by semicolons
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        // a name/value pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
        {
            return unescape(aCrumb[1]);
        }
    }
    return null;
}


/*==========================*/