﻿// JScript 文件
var xmlHttp;
var returnString;
function checkform()
{
    if(document.all.UserName.value==""||document.all.UserPwd.value=="")
    {
        alert("请填写用户名和密码!");
        document.all.UserName.focus();
        return false;
    }
    return true;
}

function linkto(url){
  window.location.href=url
}

function ShowDialog(url, width, height, optValidate) {
	var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:yes;status:no");
} 

function showsubmenu(sid)
{
whichEl = eval("submenu" + sid);
if (whichEl.style.display == "none")
{
eval("submenu" + sid + ".style.display='';");
}
else
{
eval("submenu" + sid + ".style.display='none';");
}
}

function createXMLHttpRequest()
{
   if(window.ActiveXObject)
   {
       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   else if(window.XMLHttpRequest)
   {
       xmlHttp=new XMLHttpRequest();
   }  
}

function RcreateXMLHttpRequest()
{
    var xmlHttp2;
      if(window.ActiveXObject)
   {
       xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
   }
   else if(window.XMLHttpRequest)
   {
       xmlHttp2=new XMLHttpRequest();
   } 
   return xmlHttp2;
}

function refreshModeList(SourceSelect,DesSelect,SelectedValue,ParamStr)
{
    var SourceID;
    SourceID=document.getElementById(SourceSelect).value;    
    if(SourceID==""||SourceID=="-1"){clearModelsList(DesSelect,SelectedValue);return;}
    //if(MainCompany=="*"){clearModelsList();document.all.SubCompany.options[0]=new Option('全部','*');return;}
    var url="XmlSelect.aspx?PostType="+DesSelect+"&SourceID="+SourceID+"&NoAll="+ParamStr;
    //alert(url);return;
    createXMLHttpRequest();
    xmlHttp.onreadystateChange = function () {   if(xmlHttp.readyState==4)
   {
       if(xmlHttp.status==200)
       {   
           updateModelsList(DesSelect,SelectedValue);
       }
   } };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    
}
/*
function handleStateChange2()
{
   if(xmlHttp.readyState==4)
   {
       if(xmlHttp.status==200)
       {   
           updateModelsList("SubCompany","");
       }
   } 
}
*/

function updateModelsList(DesSelect,SelectedValue)
{

    clearModelsList(DesSelect);
    
    var modelname=xmlHttp.responseXML.getElementsByTagName("ItemName");
    var modelvalue=xmlHttp.responseXML.getElementsByTagName("ItemValue");
    var option=null;    
    //alert(modelvalue.length);return;
    for(var i=0;i<modelname.length;i++)
    {
        
        document.getElementById(DesSelect).options[document.getElementById(DesSelect).length] = new Option(modelname[i].firstChild.nodeValue,modelvalue[i].firstChild.nodeValue);
        if(SelectedValue!=""&&document.getElementById(DesSelect).options[i].value==SelectedValue) 
        {
            document.getElementById(DesSelect).options[i].selected   =   true;   
        }  
    }    
}

function clearModelsList(DesSelect)
{
    var models;
    models=document.getElementById(DesSelect);
    while(models.childNodes.length>0)
    {
        models.removeChild(models.childNodes[0]);
    }
}


function handleStateChange()
{
   if(xmlHttp.readyState==4)
   {
       if(xmlHttp.status==200)
       {
           returnString=unescape(xmlHttp.responseText);
           //if(mes!=""&&mes!=null){alert(mes);}      
           //if(url)window.location.href=url;
       }
   }
}

function AJpost(postInfo)
{
    
    createXMLHttpRequest();
    xmlHttp.onreadystateChange=handleStateChange;
    xmlHttp.open("POST","../PostData.aspx",false);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(postInfo);
	
	//if(xmlHttp.status==200)alert("ok");
	
}
function AJpostNoalert(postInfo)
{
    var eZuStudio = new ActiveXObject("Microsoft.XMLHTTP");
    eZuStudio.open("POST","PostData.aspx",false);
	eZuStudio.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	eZuStudio.send(postInfo);
	returnString=unescape(eZuStudio.responseText);
	alert(unescape(eZuStudio.responseText));	
}

function a(){
return returnString;
}

function IsDateTime(sValue)
{
    var strEXP = "^([123456789][0123456789][0123456789][0123456789]\\-([0][123456789]|[123456789]|[1][012])\\-([0][123456789]|[123456789]|[12][0123456789]|3[01]))$";
    var str1=new RegExp(strEXP);
    if (str1.test(sValue))
    {
      return true; 
    }
    else
    {
      return false;   
    }   
}

