﻿
function CheckQuotation(){
    var price =  document.getElementById("lblPrice");
    var time = document.getElementById("lblTime");
    var sl = document.getElementById("__l_sl");
    var el = document.getElementById("__l_el");
    
    if((sl.selecteIndex=="0" && el.selecteIndex=="0") || el.selecteIndex=="0" || price.value.length<=0 || price.value=="0" || time.value.length<=0 || time.value=="0"){
        return false;
    }else{
        return true;
    }
}

function BuyTB(inputid,pid)
{
    $("#__s1_p_"+inputid).val(pid);
}

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 GetProductInfo(pguid,nguid,start,end,index)
        {
         var d=new Date();
         var code=d.toLocaleTimeString();
         $.ajax({
                    url : '/PLDataDispose.aspx',
	                type : 'get',
	                data : 'pguid='+pguid+'&nguid='+nguid+'&start='+start+'&end='+end+'&index='+index+ '&'+d.getTime().toString(),
	                dataType : 'html',
	                success : function(html){
	                var data = html.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;       
                        }
	                }
                 });
//         XMLHTTP = createXMLHttpRequest();
//         if(XMLHTTP == null){
//          alert("对不起你的浏览器不支持XMLHTTP,请升级");
//          return;}

//	        XMLHTTP.onreadystatechange= ProductInfoBack;
//	        XMLHTTP.open("GET","data_ajax/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;       
//            }
//      }