﻿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;
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){
        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);
   }
   else{

   document.getElementById(_pageDiv).innerHTML=unescape("no message");
}
}
}
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
		{
				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);
    } 
}
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(currentLangName == "")
    {
        if(redirectUrl.indexOf("?") == -1)
        {
            redirectUrl += "?" + replaceUrlLangName;
        }else{
            redirectUrl += "&" + replaceUrlLangName;
        }
    }else{
        redirectUrl = redirectUrl.replace(lastUrlLangName,replaceUrlLangName);
    }
    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;
   }
   
   function ResizeImage(img, mWidth, mHeight){
    var image=new Image();
    image.src=img.src;
   
  var oldW = image.width;
  var oldH = image.height;
    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;
            }
        }
    }
   
}
function showDropDown(value) {
	if (value)
	{
	    for (f = 0; f < document.forms.length; f++)
	    {
	        var elements = document.forms[f].elements;
	        for (e = 0; e < elements.length; e++)
	        {
	            if (elements[e].type == "select-one")
	            {
	                elements[e].style.visibility = 'visible';
	            }
	        }
	    }			
	} else {
	    for (f = 0; f < document.forms.length; f++)
	    {
	        var elements = document.forms[f].elements;
	        for (e = 0; e < elements.length; e++)
	        {
	            if (elements[e].type == "select-one")
	            {
	                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;
}
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";
}
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;
    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;
    }
        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);
    }
    menuObject.onmouseover =function(){
       showMenuV2(menuObjectID,"show",TimeOut);
    }

    
    if(state =="hide"){
       menuTimerv2 =setTimeout("hiddenmenu('"+ menuObjectID +"')", TimeOut);
       if(menuObject.parentNode)
        {
            menuObject.parentNode.style.zIndex=0;
        }
       
    }else
    {
         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)
        {
        }
      
    }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);
   loadpage(_pageDiv,url);
}

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';
    }
}

var TimeArrary=new Array();
function GetLatestUpdateFormat(postDate)
{
	var postTime = Date.parse(postDate);
	var serverTime = Date.parse(ServerDateV1);//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)
    {
    }
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;
}
function CopyInnerHtml(parentObject,childObject)
{
    
    var parent=document.getElementById(parentObject);  
    var child=document.getElementById(childObject);  
    if(parent!=null)
    {
        if(child!=null)
        {
            child.innerHTML=parent.innerHTML;
        }
    }
}
function insertItV2(iframe, div) {
    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);
    }

}

// asyn ad onload show 
var myAdManArray = new Array();
var isH = false;
var idx1 = 0;
function LoadAdMan(adSrc,objShow,idx){
    var oldDocumentWrite = document.write;
    var contactScripts = "";
    document.write = function(param){
        if(!document.all){
            if(isH){
                idx1++;
                isH = false;
            }
            myAdManArray[idx1] += param;
        }else{
            contactScripts += param;
        }
    }
//    var callBackFunction = function(){
//        if(scriptTag.attachEvent){
//            var currentTarget = window.event.srcElement;
//            if(currentTarget.readyState == "loaded"){
//                objShow.innerHTML = contactScripts;
//                document.write = oldDocumentWrite;
//            }
//        }else{
//            alert(objShow.id +","+idx+","+myAdManArray[idx]);
//            objShow.innerHTML = myAdManArray[idx];
//			isH=true;
//			if(idx == myAdManArray.length -1){
//				//document.write = oldDocumentWrite;
//			}
//        }
//	};
    var scriptTag = document.createElement("script");
    scriptTag.src = adSrc;
    if(scriptTag.addEventListener){
        scriptTag.addEventListener("load",function(){
                objShow.innerHTML = myAdManArray[idx];
                isH = true;
                if(idx == myAdManArray.length - 1){
                    document.wirte = oldDocumentWrite;
                }
                //document.write = oldDocumentWrite;
            }
        ,false);
    }else if(scriptTag.attachEvent){
        scriptTag.attachEvent("onreadystatechange",function(){
                var currentTarget = window.event.srcElement;
                if(currentTarget.readyState == "loaded"){
                    objShow.innerHTML = contactScripts;
                    document.write = oldDocumentWrite;
                }
            }
        );
    }
    objShow.appendChild(scriptTag);
}

/*
var pageAdManArrary = new Array();
function parseAdManJsonArray(){
    //var AdManJson = {divId:"",urlAddr:""};
    if(pageAdManArrary == "undefined" || pageAdManArrary == null){
        return;
    }
    for(var adMan in pageAdManArrary){
        var obj_div = document.getElementById(adMan.divId);
        var scriptBlock = document.createElement("script");
        scriptBlock.src = adMan.urlAddr;
        obj_div.appendChild(scriptBlock);
    }
}*/