﻿// JScript File
var emailNotVerifiedCaption = 'Email Not Verified';
var pleaseVerifyEmailCaption = 'You have not verified your email. Please<br/> verify email before you can login.';
var resendVerifyEmailCaption = 'Resend Verify Email';
var canelCaption = 'Canel';
var isMasterDisabled = 0;
var dropDown_HiddenObjs = new Array();

function loadpage(_pageDiv,url){
//初始化，指定处理函数，发送请求的函数
var jsCache = new Array();
if(jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}
var http_request=false;
http_request=false;

//开始初始化XMLHttpRequest对象

if(window.XMLHttpRequest){

//Mozilla浏览器


   http_request=new XMLHttpRequest();
   if(http_request.overrideMimeType){

//设置MIME类别

     http_request.overrideMimeType("text/xml");
   }
}

else if(window.ActiveXObject){
//IE浏览器


   try{
    http_request=new ActiveXObject("Msxml2.XMLHttp");
   }catch(e){
    try{
    http_request=new ActiveXobject("Microsoft.XMLHttp");
    }catch(e){}
   }
     }

if(!http_request){
//异常，创建对象实例失败
   //window.alert("创建XMLHttp对象失败！");
   return false;
}

http_request.onreadystatechange=function(){
if(http_request.readyState==4){//判断对象状态
    if(http_request.status==200){//信息已成功返回，开始处理信息
   // weather.innerHTML=unescape(http_request.responseText);
   
        //modify by antain v=8021B
        var errorFlag = "Looking for something at 88DB?";
        var flagIndex = http_request.responseText.indexOf(errorFlag);
        if (flagIndex < 0) {
            document.getElementById(_pageDiv).innerHTML=http_request.responseText;   
        } else {
            document.getElementById(_pageDiv).innerHTML = "";
        }
      jsCache[url]=  http_request.responseText;
      var targetObj = document.getElementById(_pageDiv);
      ajax_parseJs(targetObj);
//      alert( document.getElementById(_pageDiv).innerHTML);
   }
   else{//页面不正常

   document.getElementById(_pageDiv).innerHTML=unescape("no message");
}
}
}
//确定发送请求方式，URL，及是否同步执行下段代码
     http_request.open("GET",url,true);
http_request.send(null);
   }
   function ajax_parseJs(obj)
{

	var scriptTags = obj.getElementsByTagName('SCRIPT');
	var string = '';
	var jsCode = '';
	for(var no=0;no<scriptTags.length;no++){	
		if(scriptTags[no].src){
	        var head = document.getElementsByTagName("head")[0];
	        var scriptObj = document.createElement("script");
	
	        scriptObj.setAttribute("type", "text/javascript");
	        scriptObj.setAttribute("src", scriptTags[no].src);  	
		}else{
		try
		{
			//if(DHTMLSuite != null && DHTMLSuite.clientInfoObj.isOpera){
				//jsCode = jsCode + scriptTags[no].text + '\n';
			//}
			//else
				jsCode = jsCode + scriptTags[no].innerHTML;	
	    }
	    catch(e){}
		}
		
	}

	if(jsCode)ajax_installScript(jsCode);
}

function ajax_installScript(script)
{		
    if (!script)
        return;		
    if (window.execScript){        	
    	window.execScript(script);
    }else if(window.jQuery && jQuery.browser.safari){ // safari detection in jQuery
        window.setTimeout(script,0);
    }else{        	
        window.setTimeout(script,0);
    } 
}

//Change language id
function ChangeUrlLang(redirectUrlPath,defaultLanguageName,replaceLanguageName)
{
    var url = window.location.href;
    var currentPath = window.location.pathname + window.location.search;
    var redirectUrl = currentPath;
    while(redirectUrl.substr(redirectUrl.length - 1,1) == "#")
    {
        redirectUrl = redirectUrl.substr(0,redirectUrl.length - 1)
    }
    
    var currentLangName = GetPathName();
    
    var lastUrlLangName = "lang=" + currentLangName;
    var replaceUrlLangName = "lang=" + replaceLanguageName;
    /*if(defaultLanguageName == replaceLanguageName)
    {
        //do not show "?lang=" or "&lang="
        if(currentLangName != "")
        {
            if(redirectUrl.indexOf("?" + lastUrlLangName) != -1){
                redirectUrl = redirectUrl.replace("?" + lastUrlLangName,"");
            }else{
                redirectUrl = redirectUrl.replace("&" + lastUrlLangName,"");
            }
        }
    }else{
        //show "?lang=" or "&lang="
        if(currentLangName == "")
        {
            if(redirectUrl.indexOf("?") == -1)
            {
                redirectUrl += "?" + replaceUrlLangName;
            }else{
                redirectUrl += "&" + replaceUrlLangName;
            }
        }else{
            redirectUrl = redirectUrl.replace(lastUrlLangName,replaceUrlLangName);
        }
    }*/
    if(currentLangName == "")
    {
        if(redirectUrl.indexOf("?") == -1)
        {
            redirectUrl += "?" + replaceUrlLangName;
        }else{
            redirectUrl += "&" + replaceUrlLangName;
        }
    }else{
        redirectUrl = redirectUrl.replace(lastUrlLangName,replaceUrlLangName);
    }
    /*if(url != redirectUrl)
    {
        window.location.href = redirectUrl;
    }*/
    redirectUrl = redirectUrlPath + redirectUrl;
    window.location.href = redirectUrl;
}

function GetContainLangUrl(url)
   {
        var reurl = ""
        if(GetPathName() != "")
        {
            if(url.indexOf("?") != -1 && url.length > (url.indexOf("?") + 1))
            {
                reurl = url + "&lang=" + GetPathName();
            }
            else if(url.indexOf("?") != -1 && url.length == (url.indexOf("?") + 1))
            {
                reurl = url + "lang=" + GetPathName();
            }
            else
            {
                reurl = url + "?lang=" + GetPathName();
            }
        }
        else
        {
            reurl = url;
        }
        return reurl;
}	

    function GetPathName()
    {
        var link=window.location.href.toString().toLowerCase();
  
        var langindex=-1;
        var lang = '';
      
        langindex = link.indexOf("lang=");
        if(langindex != -1)
        {
            lang=link.substr((langindex + 5),5);
        }
        return lang;
        //return Pathlang;
   }
   
   function ResizeImage(img, mWidth, mHeight){
    var image=new Image();
    image.src=img.src;
   
  var oldW = image.width;
  var oldH = image.height;
 // alert("oldwide:"+oldW+"oldHieght:"+oldH);
    
    if(image.width > 0 && image.height > 0){
        if(image.width/image.height >= mWidth/mHeight){
            if(image.width > mWidth){ 
         //   alert("1");
                img.width = mWidth;
                img.height = (image.height * mWidth)/image.width;
            }else{
         //   alert("2");
                img.width=image.width; 
                img.height=image.height;
            }
        }else{
            if(image.height>mHeight){
          //  alert("3"); 
                img.height = mHeight;
                img.width = (image.width * mHeight)/image.height; 
            }else{
          //  alert("4");
                img.width=image.width; 
                img.height = image.height;
            }
        }
    }
   
}

function showDropDown(value) {
	if (value)
	{
	    // looping through all forms on the page
	    for (f = 0; f < document.forms.length; f++)
	    {
	        var elements = document.forms[f].elements;
	        // looping through all elements on certain form
	        for (e = 0; e < elements.length; e++)
	        {
	            if (elements[e].type == "select-one")
	            {
	                elements[e].style.visibility = 'visible';
	            }
	        }
	    }			
	} else {
	    // looping through all forms on the page
	    for (f = 0; f < document.forms.length; f++)
	    {
	        var elements = document.forms[f].elements;
	        // looping through all elements on certain form
	        for (e = 0; e < elements.length; e++)
	        {
	            if (elements[e].type == "select-one")
	            {
	            // alert(elements[e].id); 
	                elements[e].style.visibility = 'hidden';
	            }
	        }
	    }			
	}
}

function showObj(objName) {
  var obj = document.getElementById(objName);
  obj.style.visibility='visible';
  obj.style.display='block';
}

function resizeOverlay(){          
	var frame = document.getElementById("overlay");  
	if( window.innerHeight && window.scrollMaxY ) {
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight ) 
	{
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else 
	{ 
		pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop; 
	 }     
	frame.style.width = pageWidth;   
	frame.style.height = pageHeight;
} 
function insertIt(iframe, div) {
    if(iframe.contentWindow.document.body.innerHTML!="false")
    if(IsIE6())
    {
        var width = parseInt(div.offsetWidth);
        if(width == 300)
        {
            div.style.width = "301px";
        }
    }
	div.innerHTML = iframe.contentWindow.document.body.innerHTML;
}
/* Commented By Antain V=8011 */

function IsIE6()
{
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=b_version.split(";");
    var trim_Version=version[1].replace(/[ ]/g,"");
    if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0")
    {
        return true;
    } 
    return false;
}

function resizeImageV3(img, mWidth, mHeight){    
    img.style.visibility = "hidden";
    img.style.display = "none";

    var image=new Image();
    image.src=img.src;  

    if(image.width > 0 && image.height > 0){
        if(image.width/image.height >= mWidth/mHeight){
            if(image.width > mWidth){      
                img.width = mWidth;
                img.height = (image.height * mWidth)/image.width;
            }else{  
                img.width=image.width; 
                img.height=image.height;
            }
        }else{
            if(image.height>mHeight){      
                img.height = mHeight;
                img.width = (image.width * mHeight)/image.height; 
            }else{      
                img.width=image.width; 
                img.height = image.height;
            }
        }
    }   
    
    img.style.visibility = "visible";
    img.style.display = "block";
}


/*<!--add by candu-->*/
var DefautmenuID="Defaut";
var menuTimer =null;
var publicObj = null;
var publicLocation = null;
var publicTimeout = 0;
function showmenu(obj1,obj2,state,location,timeout){ 

    publicObj = obj1;
    publicLocation = location;
    publicTimeout = timeout;
    
    if(DefautmenuID!="Defaut"&&DefautmenuID!=obj2)
    {
         hiddenmenu(DefautmenuID);    
    }
    DefautmenuID=obj2;

    var btn=document.getElementById(obj1);
    var obj=document.getElementById(obj2);
    var h=btn.offsetHeight;
    var w=btn.offsetWidth;
    var x=btn.offsetLeft;
    var y=btn.offsetTop;
    /*if(state == "show"){
        obj.onmouseover =function(){
            showmenu(obj1,obj2,'show',location);
        }
        obj.onmouseout =function(){
            showmenu(obj1,obj2,'hide',location);
        }
    }*/
    
    while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;}
    
    var hh=obj.offsetHeight;
    var ww=obj.offsetWidth;
    var xx=obj.offsetLeft;//style.left;
    var yy=obj.offsetTop;//style.top;
    var obj2state=state.toLowerCase();
    var obj2location=location.toLowerCase();
    
    var showx,showy;

    if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"||obj2location=="bottomleft"||obj2location=="bl"
    ||obj2location=="bottomcenter"||obj2location=="bc"||obj2location=="bottomright"||obj2location=="br"){
        if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
        if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=x;showy=y-hh;}
        if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
        if(obj2location=="bottom" || obj2location=="b"){showx=x;showy=y+h;}
        if(obj2location=="bottomleft"||obj2location=="bl"){showx=x;showy=y+h;}
        if(obj2location=="bottomcenter"||obj2location=="bc"){if(ww>=w){showx=x-(ww-w)/2;}else{showx=x-(w-ww)/2;}showy=y+h;}
        if(obj2location=="bottomright"||obj2location=="br"){showx=x-ww+w;showy=y+h;}
    }else{ 
        showx=xx;showy=yy;
    }
    //if(obj2=="ChCon")//Add By Ben
    //{
       //obj.style.left=(showx-5)+"px"; 
    //}
    //else
    //{
        obj.style.left=showx+"px";
    //}
    obj.style.top=showy+"px";
    if(state =="hide"){
        menuTimer =setTimeout("hiddenmenu('"+ obj2 +"')", timeout);
        if(obj.parentNode)
        {
            obj.parentNode.style.zIndex=0;
        }
    }else{
        clearTimeout(menuTimer);
        menuTimer = null;
        obj.style.visibility ="visible";
        obj.style.display ="block";
        obj.style.zIndex=12;
        if(obj.parentNode)
        {
            obj.parentNode.style.zIndex=12;
        }
    }
}
function hiddenmenu(psObjId){
    document.getElementById(psObjId).style.visibility ="hidden";
    document.getElementById(psObjId).style.display ="none";
    if(psObjId == "divCountryBox")
    {
        document.getElementById('otherRegionImg').src = '../images/icon_arrow_r.gif';
    }
} 


var  menuTimerv2 =null;
function showMenuV2(menuObjectID,state,TimeOut)
{
    if(DefautmenuID!="Defaut"&&DefautmenuID!=menuObjectID)
    {
         hiddenmenu(DefautmenuID);    
    }
    DefautmenuID=menuObjectID;
    var menuObject=document.getElementById(menuObjectID);
        menuObject.onmouseout =function(){
        showMenuV2(menuObjectID,"hide",TimeOut);
        //alert('hidden');
    }
    menuObject.onmouseover =function(){
       showMenuV2(menuObjectID,"show",TimeOut);
       //alert("show");
    }

    
    if(state =="hide"){
       menuTimerv2 =setTimeout("hiddenmenu('"+ menuObjectID +"')", TimeOut);
       if(menuObject.parentNode)
        {
            menuObject.parentNode.style.zIndex=0;
        }
       
    }else
    {
    //alert('clear');
         clearTimeout(menuTimerv2);
         menuObject.style.visibility ="visible";
         menuObject.style.display ="block";
         menuObject.style.zIndex=12;
         if(menuObject.parentNode)
        {
            menuObject.parentNode.style.zIndex=12;
        }
    }
   
    
}
var  menuTimerv3 =null;
function showMenuV3(menuObjectID,state,TimeOut)
{
    if(DefautmenuID!="Defaut"&&DefautmenuID!=menuObjectID)
    {
         hiddenmenu(DefautmenuID);    
    }
    DefautmenuID=menuObjectID;
    var menuObject=document.getElementById(menuObjectID);
    if(state =="hide"){
       menuTimerv3 =setTimeout("hiddenmenu('"+ menuObjectID +"')", TimeOut);
       if(menuObject.parentNode)
        {
            //menuObject.parentNode.style.zIndex=0;
        }
      
    }else
    {   
         clearTimeout(menuTimerv3);
         menuObject.style.visibility ="visible";
         menuObject.style.display ="block";
         menuObject.style.zIndex=12;
         if(menuObject.parentNode)
        {
            menuObject.parentNode.style.zIndex=12;
        }
    }
}

function KeepObj(obj,state)
{
    showmenu(publicObj,obj,state,publicLocation,publicTimeout);
}

function GetPagehtml(_pageDiv,url,timeout)
{    
   var obj_html= document.getElementById(_pageDiv);
   showMenuV2(_pageDiv,"show",timeout);
  // obj_html.innerHTML ="";
    loadpage(_pageDiv,url);
   //  if(document.all)
    
//    <iframe   src="javascript:false"   style="position:absolute;   visibility:inherit;   top:0px;   left:0px;   width:346px;   height:200px;   z-index:-1;   filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';"></iframe> 
}

function GetChHtml(parentObject,chdiv,state,location,timeout)
{
    
    var chdivobj=document.getElementById(chdiv);  
    var chdivobjContent=document.getElementById(parentObject+"contend");  
    if(chdivobjContent)
    {
     document.getElementById("ChCon").style.width=document.getElementById(parentObject+"contend").style.width;
     chdivobj.innerHTML=chdivobjContent.innerHTML;
     chdivobj.style.zIndex=12;
     showmenu(parentObject,chdiv,state,location,timeout);
    }
    else
    {
        chdivobj.style.display='none';
    }
}
/*
function ResetChConLeftValue()
{
    var leftPos = document.getElementById("ChCon").style.left;
    var indexOfPx=leftPos.indexOf("px");
    var leftValue=leftPos.substring(0,indexOfPx);
    leftValue-=5;
    leftPos=leftValue+"px";
    document.getElementById("ChCon").style.left=leftPos;

}
*/
var TimeArrary=new Array();
function GetLatestUpdateFormat(postDate)
{
	var postTime = Date.parse(postDate);
	var serverTime = Date.parse(serverDate);//serverDate defined in Views\master\TopLoginBarV2.aspx.cs
	var hh = (serverTime - postTime)/3600000;
	hh = Math.ceil(hh);
	if(hh <= 0)
    {
        hh = 1;
    }
    
    var d = hh/24;    
    if(d>=1)
	{
	    if(d>5)
	    {
	        var TempPostDate = new Date(postDate);
	        var DD = TempPostDate.getDate();
	        if(DD<10)DD = "0" + DD;
	        var MM = TempPostDate.getMonth();
	        var MonthArr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
	        var YY = TempPostDate.getFullYear();
	        YY = YY.toString();
	        YY = YY.substring(2);
	       return DD + " " + MonthArr[MM] + " " + YY;
	    }
	    else
	    {
	        return knowDateFormat.replace(/\{0\}/g,Math.ceil(d));
	    }
	}
	else
	{
	    return knowTimeFormat.replace(/\{0\}/g,hh);
	}
    
}
function changeimg(theimage,imgPath)
{   
    
    if(theimage.getAttribute('enableviewstate')=="true")
    {
        
        theimage.setAttribute('enableviewstate','false');
        theimage.src=imgPath;
        theimage.onload=null;
     } 
}
function CheckBrowserIsIE(s){
    var browser=navigator.appName;
    if ((browser=="Netscape"))
    {
        return false;
    }
    else if(browser=="Microsoft Internet Explorer")
    {
        return true;
    }
    else
    {
        return false;
    }
}

function ConverDivBackgroundColorForIE6(div,backgroundColor)
    {
//        if (navigator.appVersion.indexOf('MSIE 6.0') != -1) 
//        {
//            div.style.backgroundColor = backgroundColor;
//        }

    }

//Ben Start

//For Navigator Default Channel Start
var NavigatorDefaultChannel="notID";
function NavigatorSetCurrentChannelColor() 
{
    var Host = window.location.host;
    var HostIndex = window.location.href.indexOf(Host);
    var StartIndex = HostIndex + Host.length;
    StartIndex += 1;
    var ChannelName = window.location.href.substr(StartIndex);
    var EndIndex = ChannelName.indexOf("/");
    ChannelName = ChannelName.substr(0,EndIndex);
    var ObjectToSetColor = document.getElementById("c"+ ChannelName);
    if(ObjectToSetColor)
    {
        ObjectToSetColor.childNodes[1].style.color = "#f27900";
        ObjectToSetColor.style.backgroundImage = "url('../images/bg_nav_on.gif')";
        NavigatorDefaultChannel = "c" + ChannelName; 
    }
    return;
}

if (window.addEventListener)
{
    window.addEventListener("load", NavigatorSetCurrentChannelColor, false);
}
else if (window.attachEvent)
{
    window.attachEvent("onload", NavigatorSetCurrentChannelColor);
}
else
{
    window.onload=NavigatorSetCurrentChannelColor;
}
//For Navigator Default Channel End

//CopyInnerHtml Start
function CopyInnerHtml(parentObject,childObject)
{
    
    var parent=document.getElementById(parentObject);  
    var child=document.getElementById(childObject);  
    if(parent!=null)
    {
        if(child!=null)
        {
            child.innerHTML=parent.innerHTML;
        }
    }
}
//CopyInnerHtml End


//Ben End


function insertItV2(iframe, div) {
    //alert("oNload" + iframe.contentWindow.document.body.innerHTML);
   //alert(iframe.id);
    if (iframe.contentWindow.document.body.innerHTML != "false")
                                div.innerHTML = iframe.contentWindow.document.body.innerHTML;

}

function getAdmanFriendlyName(catName) { 
                catName=catName.replace(/\W+/g, "_");
                catName=catName.replace(/_+/g, "_");
                return catName.replace(/(^\_)|(\_$)/g, ""); 
}

function getQuerystring(key, default_) {
                if (default_==null) default_=""; 
                key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
                var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
                var qs = regex.exec(window.location.href);
                if (qs == null)
                                return default_;
                else
                                return qs[1];

}

function AjaxPage(url,Id,handler)
{
    var http_request=false;
    http_request=false;
    if(window.XMLHttpRequest){
        http_request=new XMLHttpRequest();
        if(http_request.overrideMimeType){
            http_request.overrideMimeType("text/xml");
        }
    }
    else if(window.ActiveXObject){
        try{
            http_request=new ActiveXObject("Msxml2.XMLHttp");
        }catch(e){
            try{
                http_request=new ActiveXobject("Microsoft.XMLHttp");
            }catch(e){}
        }
    }

    if(!http_request){
        return false;
    }
    http_request.onreadystatechange = function(){
        if(http_request.readyState==4){
            if(http_request.status==200){
                if(handler && handler.success){
                    handler.success.apply(handler.success,[http_request.responseText]);
                }
            }else{
                if(handler && handler.failed){
                    handler.failed.apply(handler.failed,[]);
                }
            }
        }
    }
    http_request.open("GET",url,true);
    http_request.send(null);
}


function OtherRegionClick(timeout)
{
    var divCountryBox = document.getElementById("divCountryBox");
    clearTimeout(menuTimerv3);
    if(divCountryBox.style.display=="block")
    {
        document.getElementById('otherRegionImg').src = '../images/icon_arrow_r.gif';
        divCountryBox.style.display="none";
        divCountryBox.style.visibility ="hidden";
    }
    else
    {
        document.getElementById('otherRegionImg').src = '../images/icon_arrow_d.gif';
        divCountryBox.style.display="block";
        divCountryBox.style.visibility ="visible";
        showMenuV3("divCountryBox","hide",timeout);
    }

}

/*<!--build 9004-->*/