﻿// JScript 文件
function DIVShow(i){
    if( document.getElementById(i).style.display=='')
       document.getElementById(i).style.display = 'none';
    else
       document.getElementById(i).style.display = '';
}


var curTip = "";
        function displayToolTip(id) {
          if( curTip != "" ) {
            hideToolTip( curTip );
          }
          
          tip = document.getElementById( id );
          tip.style.display="block";
          tip.style.zIndex=1000;
          curTip = id;
        }

        function hideToolTip(id) {
          tip = document.getElementById( id );
          tip.style.display="none";
          curTip = "";
        }
        function calculateProject(formindex){
	        var p=document.getElementById("__s0_p_"+formindex);
	        var n=document.getElementById("__s0_n_"+formindex);
	        var l1=document.getElementById("__s0_l1_"+formindex);
	        var l2=document.getElementById("__s0_l2_"+formindex);
	        var l1v=parseInt((l1.value==""?"0":l1.value),10),l2v=parseInt((l2==null?"-1":(l2.value==""?"0":l2.value)),10);
	        document.getElementById("__s0_pr_"+formindex).value="";
	        document.getElementById("__s0_tm_"+formindex).value="";
	        if(l1v<=0||(l1v>=l2v&&l2v!=-1))
		        return;	
	        GetProductInfo(p.value,n.value,l1v,l2v,formindex);
        }
        function changeProject(formindex){
	        document.getElementById("__s0_pr_"+formindex).value="";
	        document.getElementById("__s0_tm_"+formindex).value="";
	        var l1=document.getElementById("__s0_l1_"+formindex);
	        var l2=document.getElementById("__s0_l2_"+formindex);
	        if(l1!=null){l1.value="";try{l1.selectedIndex=0;}catch(e){}}
	        if(l2!=null){l2.value="";try{l2.selectedIndex=0;}catch(e){}}
        }

        //初始化AJAX引擎
        function createXMLHttpRequest(){
	        if(window.XMLHttpRequest) return new XMLHttpRequest();
	        try{return new ActiveXObject('MSXML2.XMLHTTP.4.0');}
	        catch(e){try{return new ActiveXObject('MSXML2.XMLHTTP.3.0');}
	        catch(e){try{return new ActiveXObject('MSXML2.XMLHTTP.2.6');}
	        catch(e){try{return new ActiveXObject('MSXML2.XMLHTTP');}
	        catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP');}
	        catch(e){return null;}}}}}
        }

        function GetLevelInfo()
        {
            var s_l=document.getElementById("__l_sl").value;
            d = new Date();
            var e_l=document.getElementById("__l_el").value;
            document.getElementById("StartLevel").value=s_l;    
            document.getElementById("EndLevel").value=e_l;
            if(parseFloat(s_l)>parseFloat(e_l))
            {
                document.getElementById("__l_sl").value=document.getElementById("__l_sl").options[0].value;
                s_l = document.getElementById("__l_sl").value;
            }
            var pobj=document.getElementById("__l_char");
            var pguid;
            if(pobj!=null)
            {
                pguid=pobj.value;
            }
            else
                pguid="";
            document.getElementById("Profession").value=pguid;
            XMLHTTP = createXMLHttpRequest();
            if(XMLHTTP == null){
            alert("对不起你的浏览器不支持XMLHTTP,请升级");
             return;}

	            XMLHTTP.onreadystatechange= LevelInfoBack;
	            XMLHTTP.open("GET","PLLevelOutPut.aspx?gamecode="+'<%= gamecode%>'+"&pguid="+pguid+"&start="+s_l+"&end="+ e_l+ "&"+d.getTime().toString(),true);
	            XMLHTTP.send(null);
        }

        function LevelInfoBack()
        {
             if(XMLHTTP.readyState!=4)
          return;
         var text=XMLHTTP.responseText;

        //分析文本并显示到页面
            var data = text.split("\n");  
            if(data.length>0)
            { 
                if(data[0]!=null && data[0]!="")
                    document.getElementById("lblPrice").value=Math.round(parseFloat(data[0])*1000)/1000;
                if(data[1]!=null && data[1]!="")
                    document.getElementById("lblTime").value=Math.round(parseFloat(data[1])*1000)/1000;
            }
        }

        function GetProductInfo(pguid,nguid,start,end,index)
        {
         var d=new Date();
         var code=d.toLocaleTimeString();
         XMLHTTP = createXMLHttpRequest();
         if(XMLHTTP == null){
          alert("对不起你的浏览器不支持XMLHTTP,请升级");
          return;}

	        XMLHTTP.onreadystatechange= ProductInfoBack;
	        //alert(pguid+"/"+nguid+"/"+start+"/"+end+"/"+index+"/"+d.getTime().toString());
	        XMLHTTP.open("GET","PLDataDispose.aspx?pguid="+pguid+"&nguid="+nguid+"&start="+start+"&end="+end+"&index="+index+ "&"+d.getTime().toString(),true);
	        XMLHTTP.send(null);
        }

        function ProductInfoBack()
        {
         if(XMLHTTP.readyState!=4)
          return;
         var text=XMLHTTP.responseText;

        //分析文本并显示到页面
            var data = text.split("\n");    
            if(data.length>0)
            { 
                if(data[0]!=null && data[0]!="")
                    document.getElementById("__s0_pr_"+data[2]).value=Math.round(parseFloat(data[0])*1000)/1000;     
                if(data[1]!=null && data[1]!="")
                    document.getElementById("__s0_tm_"+data[2]).value=Math.round(parseFloat(data[1])*1000)/1000;       
            }
        }


