function resizeuseubox(){
//    $("a.centerbutton>img").load(function(){
//   $("a.centerbutton>img").bind('load', function() {
        if ($("div").hasClass("S_pic"))
        { 
            $("div.S_pic").css("min-height","0");
            $("p.S_pic_1").css("min-height","0");
            $("p.S_pic_11").css("min-height","0"); 
            var spicheight2=$("p.S_pic_1").height();
            var spicheight3=$("p.S_pic_11").height();
            var currentheight;

            spicheight2>spicheight3 ? currentheight=spicheight2 : currentheight=spicheight3;   
            $("div.S_pic").height(currentheight);
            $("p.S_pic_1").height(currentheight);
            $("p.S_pic_11").height(currentheight);
            $("p.S_pic_11").css("position","relative");
            $("p.S_pic_1").css("position","relative");
            var cssObj = {
              'position' :'absolute',
              'top' :currentheight-30,
              'left':'40%'
            }
           $("p.S_pic_11 > a.centerbutton > img").css(cssObj);
           $("p.S_pic_1 > a.centerbutton > img").css(cssObj);
            var rightheight=$("div#d3_right").height();
            var leftheight=$("div#d3_left").height();
            var minheight=$("div#d3_left").height()-$("div.biaoti").height()-$("div.S_pic").height()-$("div.zb_right>h2").height()-30;
            var minheight=leftheight-rightheight+$("div.S_game_news").height()-10;
            if (rightheight<leftheight)
            {
                 $("div.S_game_news").css("height",minheight);
            }
         }
//   }); 
  } 
$(document).ready(function(){  
    //alert($.browser.version.length);
    if ($.browser.version.length<=3)
    {
        resizeuseubox();
    }
    else
    {
         $("a.centerbutton>img").bind('load', function() {
             resizeuseubox();
         }); 
    }
});
//end format
  
var $serverJson=null;
var preElement;
var isgold=true;
function serverkey(father){
    $(father).bind("click",function(e){
        if(e.target.type=="text/asa"){
            $("#serverkeyf ul li a").css({color:"#c3c4c4"});
            e.target.style.color="#ffa200";
            var html="";
            var hrefUrl="";
            var curUrl=document.URL;
          curUrl.indexOf("/gold/us")>"-1" ? curUrl=curUrl.replace("/gold/us","") :  curUrl=curUrl.replace("/gold/eu","");
            if($serverJson==null)return;
            $.each($serverJson.servers,function(i,item){
                if((item.JName.substring(0,1).toUpperCase()==$(e.target).html().toUpperCase())||$(e.target).html().toUpperCase()=="ALL"){
                    if(isgold)
                    {
//                        hrefUrl=item.PreGoldUrl+'-'+item.JSName+'-'+item.ServerID+'-'+item.GameID+'.aspx';
                            hrefUrl=item.PreGoldUrl+'-'+item.JSName+'-'+item.ServerID+'-'+item.GameID;
                     }
                    else
                    {
                        hrefUrl=item.PreGoldUrl+'-'+item.JSName+'-accounts.'+item.ServerID+'.aspx';
                     }
                    // alert(document.domain+"/"+hrefUrl.toLowerCase());
                    html+="<li><a href=\"http://"+document.domain+"/"+hrefUrl.toLowerCase().replace("\"","'")+"\">"+item.JName.replace("\"","'")+"</a></li>"
                   // html+="<li><a href=\"/"+curUrl+"/"+hrefUrl.toLowerCase()+"\">"+"ffff"+item.JName+"</a></li>"
                }
            })
            $("#servers").html(html);
        }
    })
}


function getServerData(gameid){
    if(gameid==""||typeof gameid=="undefined")return;
        $('#serverwait').css('display','inline');
            $.ajax({
                url : '/goldData.aspx',
                type :'get',
                data : 'operate=serverlist&gameID='+gameid,
                dataType : "json",
                success : function(json){
                    $serverJson=json;
                    $("#serverkeyf ul li a:eq(0)").click();
                    $('#serverwait').css('display','none');
                }
          });
}

function topcurrency(obj)
{
    var info=obj.id.split("_");
    setcurrency(info[1]=="usd"?"0":info[1]=="eur"?"2":"1");
}


function setcurrency(val)
{
       $.ajax({
            url : '/common.ashx',
            type :'get',
            data : 'req=0&par=w&v='+val+"&m="+Math.random(),
            success:function(){
                callpagecurrency(val);
            }
        });  
}

function readcurrency()
{
       $.ajax({
            url : '/common.ashx',
            type :'get',
            data : 'req=0&par=r&m='+Math.random(),
            dataType : 'html',
            success : function(data){
               callpagecurrency(data);
            }
        });
} 

function callpagecurrency(currency)
{
    try{
        loadBlockListByCurType(currency);
    }
    catch(err){}
    try{
        setquickcur(currency);
    }
    catch(err){}
    try{
        setplcur(currency);
    }
    catch(err){}
    if($("#ddlMoney").size()>0)
        $("#ddlMoney").val(currency);
}

function settype(val)
{
    isgold=val;
}


function usphonejump(obj,target)
{
    if(obj.val().length>=parseInt(obj.attr("maxlength")))
        target.focus();
}

function showtitle()
{
    $(window).load(function(){
        var $tt;
        var $ttpos;
        var $tc;
        var timeO;
        var maxWidth=400;
        $(document).mousemove(function(event){
            if(timeO)clearTimeout(timeO),$tc.css({display:"none"});
            $tt=$(event.target);
            if($tt.attr("bktitle")||$tt.attr("title"))
            {
                //create div to show info
                if(!$tc)
                {
                    document.body.appendChild($("<div id=\"showtitle\" class=\"showtitle\"></div>")[0]);
                    $tc=$("#showtitle");
                }
                if($tt.attr("title"))$tt.attr("bktitle",$tt.attr("title")).removeAttr("title");
                $tc.html($tt.attr("bktitle"));
                $tc.css({left:document.body.scrollLeft+event.clientX+"px",top:document.body.scrollTop+event.clientY+20+"px",width:$tc.width()>maxWidth?maxWidth+"px":"auto"});
                timeO=setTimeout(function(){
                    $tc.css({display:'block'});
                },500)
            }
        }).mouseout(function(event){
            clearTimeout(timeO);
            $tc.css({display:"none"});
        })
    })
}

function entherrun(target,e,event)
{
    if((event.keyCode ? event.keyCode : event.which ? event.which : event.charCode)==13)eval("$(\"#"+target+"\")."+e+"()");
}




function TimeZone()
{
    timeSpanContainer=null;//显示time列表的容器
    timeResultElement=null;//将结果装载到的element
    dataURL="timezone.aspx?Act=TimeSpan&Code=" + document.getElementById("ctl00_ContentPlaceHolder1_Powerlevelingorder1_drpTimeZone").value + "&Day=8";//获取数据地址
    
    
    this.doGetTimeSpan=function()
    {
        var ns4 = (document.layers) ? true : false;
        var ie4 = (document.all) ? true : false;
        
    	var outHTML="";

	    retCode=openUrl(dataURL);
	    retCode = retCode.substring(retCode.indexOf('^'),retCode.Length-retCode.indexOf('^'));
	    
	    var s1 = retCode.split('*');

	    for(var i=0;i<s1.length;i++)
	    {	    
	        outHTML += i%(3+1)==0 ? (i!=0?"</div>":"") + "<div>":   "&nbsp;&nbsp;&nbsp;&nbsp;<a  href=\"javascript:void(0)\" onclick=\"document.getElementById('" + this.timeResultElement.id + "').value=this.innerHTML;\">" + s1[i] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
	    }

        outHTML+="</div>";
        
        this.timeSpanContainer.innerHTML=outHTML;
        this.timeSpanContainer.style.position="absolute";
        var h = (i/3 * 15);
        this.timeSpanContainer.style.height = (h>200? 200:h) + "px";		
    }

}

function   openUrl(url)
   {  
        if   (window.XMLHttpRequest)  
        {   
                objxml   =   new   XMLHttpRequest();   
        }  
         else   if   (window.ActiveXObject)  
        {   
                objxml   =   new   ActiveXObject("Msxml2.XMLHTTP");   
        }   
        
        objxml.open("GET",url,false);
        
        objxml.send(""); 
        retInfo=objxml.responseText;          
        if   (objxml.status== "200 ")
        {  
                return   retInfo;  
        }  
        else
        {  
                return   "";  
        }  
}  
 
 
 
        function showTimeSelect(my)
          {

          var rstOBJ=document.getElementById("ctl00_ContentPlaceHolder1_Powerlevelingorder1_txtStartingTime");
          var timeOBJ=document.getElementById("divTimeSelect");
        
          var x = new TimeZone();
          
          x.timeSpanContainer=timeOBJ;
          x.timeResultElement=rstOBJ;
          x.doGetTimeSpan();
          timeOBJ.style.display="block";
          
          //timeOBJ.style.left=rstOBJ.style.left;
          //timeOBJ.style.top=rstOBJ.style.top;
          }
          //--end show time select))))


          function hideSelection(e)
          {
          var objx=document.getElementById("divTimeSelect");
          var cobj=document.getElementById("ctl00_ContentPlaceHolder1_Powerlevelingorder1_txtStartingTime");

          var eobj= e.srcElement ? e.srcElement : e.target;
          if(eobj.id != cobj.id)
          objx.style.display="none";
          }






$(window).load(function(){
    readcurrency();
})