﻿// JScript 文件


  window.onresize=DivSize;
  function document.oncontextmenu() 
  { 
       return false; 
  }
  var UrlBarCode;
function showEdit(TempBarCode,TempBarCodeUrl)
{

     var ClearCount=document.getElementById("ctl00_ContentPlaceHolder1_txtCount");
     var Clearspec=document.getElementById("ctl00_ContentPlaceHolder1_txtspec");
     var ClearRemark=document.getElementById("ctl00_ContentPlaceHolder1_txtRemark");
     ClearCount.value="1";
     Clearspec.value="0";
     ClearRemark.value="";
     var arrySize = getPageSize();
     LoadTempData(TempBarCode,TempBarCodeUrl);    
     document.getElementById('doing').style.width =arrySize[0];
     document.getElementById('doing').style.height =arrySize[1];
     document.getElementById('doing').style.display = "block";
     var ShowDiv=document.getElementById("EditDiv");
     ShowDiv.style.display='';
     var iTop =(document.documentElement.clientHeight-ShowDiv.clientHeight)/2+document.documentElement.scrollTop-50+"px";
     var iLeft = (document.documentElement.clientWidth-ShowDiv.clientWidth)/2+document.documentElement.scrollLeft+"px";
     ShowDiv.style.left =iLeft;
	 ShowDiv.style.top =iTop;
	 if (window.attachEvent) {  
                window.attachEvent("onscroll",this.fixed);  
            } else if (window.addEventListener) {  
                window.addEventListener("scroll",this.fixed, false);    
            }         
     _displaySelect("EditDiv");
     IsExitsBarCode();
}

function fixed()
{
      var ShowDiv=document.getElementById("EditDiv");
      ShowDiv.style.position = "absolute";
      var iTop =(document.documentElement.clientHeight-ShowDiv.clientHeight)/2+document.documentElement.scrollTop-50+"px";
      var iLeft=(document.documentElement.clientWidth-ShowDiv.clientWidth)/2+document.documentElement.scrollLeft+"px";
      ShowDiv.style.left =iLeft;
	  ShowDiv.style.top =iTop;   
}
function DivSize()
{
    var arrySize = getPageSize();
    document.getElementById('doing').style.width =arrySize[0];
    document.getElementById('doing').style.height =arrySize[1];
    fixed();
}
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	//arrayPageSize = new Array(1000,800,800,1000)
	return arrayPageSize;
}
function myCheck(chkid)
{
      
      var myChkLink=document.getElementById('chkLink');
      var mytxtComCheck=document.getElementById('ctl00_ContentPlaceHolder1_txtComCheck');
      var myChkBox=document.getElementById(chkid);
      var arr=new Array();
      if(myChkBox.checked)
      {
          if((mytxtComCheck.value=='')||(mytxtComCheck.value==null))
          {
              mytxtComCheck.value=chkid+",";
          }
          else
          {
             mytxtComCheck.value=mytxtComCheck.value+chkid+",";
          }
      }
      else
      {
          if((mytxtComCheck.value=='')||(mytxtComCheck.value==null))
          {
              mytxtComCheck.value='';
          }
          else
          {
             //debugger;
             arr=mytxtComCheck.value.split(',');
             mytxtComCheck.value="";
             for(var i=0;i<arr.length-1;i++)
             {
                if(arr[i]!=chkid)
                {
                  mytxtComCheck.value+=arr[i]+",";
                }
             }
          }
      }
      myChkLink.href="PlateCompare.aspx?chkid="+mytxtComCheck.value+"&chkType=1";
}
function CreateXmlHttpObj()
{
    if(window.ActiveXObject)
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        if(window.XMLHttpRequest)
        {
            xmlhttp = new XMLHttpRequest();
        }
    }
    return xmlhttp;
}
function LoadTempData(TempBarCode,TempBarCodeUrl)
{
    var t=document.getElementById('ctl00_ContentPlaceHolder1_txtBarCode');
    t.value=TempBarCode;
    UrlBarCode=TempBarCodeUrl;
    var drp1=document.getElementById("ctl00_ContentPlaceHolder1_bllManRockName");
    
    for(var i = drp1.options.length -1;i>=0;i--)
	{
	    drp1.remove(i);
	}
	var mytypename='请 选 择';
    var mytypeid='0';
    var drpClear=document.getElementById("ctl00_ContentPlaceHolder1_bllManRockName");
    drpClear.options.add(new Option(mytypename,mytypename));
   
   //========================================================================================================================================
   //主石名称  副石名称
   //=========================================================================================================================================
    url="XmlHttpPage/LoadBindRockName.aspx?CodeID="+TempBarCodeUrl+"&TypeID="+"1";
    var xml1=CreateXmlHttpObj();
    var oDoc1 = new ActiveXObject("MSXML2.DOMDocument");
    xml1.open("Post",url,false);
    xml1.send();
    result1 = xml1.responseText;
    oDoc1.loadXML(result1);
    items = oDoc1.selectNodes("//NewDataSet/ds");
    var selectObj1 = new Array();
    var biao1=0;
    for (var item = items.nextNode(); item; item = items.nextNode())
    {
       var smaname = item.selectSingleNode("RockName").nodeTypedValue;
       var smaid = item.selectSingleNode("RockName").nodeTypedValue;
       biao1=biao1+1;
       selectObj1[biao1]=item.selectSingleNode("IsSelect").nodeTypedValue;
       drp1.options.add(new Option(smaname,smaid));
      
    }
    for(var i=0;i<=biao1;i++)
    {
       if(selectObj1[i]=="1")
       {
         drp1.options[i].selected=true;
       }
    }
   
}

//释放遮盖层


function CloseEditDiv()
{
    var ShowDiv=document.getElementById("EditDiv");
    _displaySelect("EditDiv");
    document.getElementById('doing').style.display = "none";
    ShowDiv.style.display='none';
}

function IsExitsBarCode()
{ 
      var ListMessage=document.getElementById("ListMessage");
      var xmlUrl="XmlHttpPage/BackBarCode.aspx?BarCode="+UrlBarCode;//document.getElementById("ctl00_ContentPlaceHolder1_txtBarCode").value;
      var xmlHttp=new CreateXmlHttpObj();
      xmlHttp.open("Post",xmlUrl,false);
      xmlHttp.send(null);
     if(xmlHttp.responseText=="true")
     {
         ListMessage.style.display="Block";
     }
     else
     {
          ListMessage.style.display="none";
         // ListMessage.style.display="";
     }
     
}




//**************************************************************************
//函数的作用：将所有下拉框都隐藏
//*************************************************************************
//function $(_sId)
//{return document.getElementById(_sId);}

function _displaySelect(Divname)
{ 
     //debugger;
    var selects=document.getElementsByTagName("select");//整个页面的所有下拉框 
    var objWindow = document.getElementById(Divname);
    var DIVselects = objWindow.getElementsByTagName("select");//整个弹出层的所有下拉框 
    var objselect2=document.getElementById("ctl00_ContentPlaceHolder1_bllSmaMaterials");
    var objselect3=document.getElementById("ctl00_ContentPlaceHolder1_bllManRockName");
    for(var i=0;i<selects.length;i++)
    { 
          if(selects[i].style.visibility){ 
            if((selects[i].id==objselect2.id)||(selects[i].id==objselect3.id))
            {
               selects[i].style.visibility="hidden";
            }
            else
            {
              selects[i].style.visibility=""; 
            }
            
        }else{
            if((selects[i].id==objselect2.id)||(selects[i].id==objselect3.id))
            {
               selects[i].style.visibility=""; 
            }
            else
            {
              selects[i].style.visibility="hidden"; 
            }
            
            
         } 
      
    } 
    
} 
//**************************************************************************
//函数的作用：验证提交是否正确
//**************************************************************************
 function ValidOrder()
 {
     var vcount=document.getElementById("ctl00_ContentPlaceHolder1_txtCount");
     var vspec=document.getElementById("ctl00_ContentPlaceHolder1_txtSpec");
     var isNum=true;
     var isSpec=true;
     isNum=isNumber(vcount.value);
     var ListMessage=document.getElementById("ListMessage");
     var xmlUrl="XmlHttpPage/BackBarCode.aspx?BarCode="+UrlBarCode;
     var xmlHttp=new CreateXmlHttpObj();
     xmlHttp.open("Post",xmlUrl,false);
     xmlHttp.send(null);
     if(xmlHttp.responseText=="true")
     {
        ListMessage.style.display="Block";
        return false;
     }
     if((vcount.value=="")||(vspec.value==""))
     {
       alert("请输入你选择的数量");
       return false;
     }
     else
     {
          if((isNum))
          {
             return true;
          }
          else
          {
             alert("请填写正确的数字");
             return false;
          }
     }
  }
 function isNumber(oNum) 
 { 
     if(!oNum) return false; 
     var strP=/^\d+(\.\d+)?$/; 
     if(!strP.test(oNum)) return false; 
      try{ 
       if(parseFloat(oNum)!=oNum) return false; 
       } 
       catch(ex) 
       { 
         return false; 
       } 
     return true; 
  }
 

