var xmlhttp = null;
var rootn = null;
var callBack = null;
var params = null;
var httpUrl = null;

 ////////////////////////////////////////////////////////////////////////////////////
 //
 // 创建httprequest对象
 //
 ///////////////////////////////////////////////////////////////////////////////////
function createHttpRequest(){	
        if(window.ActiveXObject){
            try {
                return new ActiveXObject("Msxml2.XMLHTTP") ;
            } catch (e) {
                try {
                    return new ActiveXObject("Microsoft.XMLHTTP") ;
                } catch (e2) {
                    return null ;
                 }
             }
        } else if(window.XMLHttpRequest){
            return new XMLHttpRequest() ;
        } else {
            return null ;
        }
    }
 ////////////////////////////////////////////////////////////////////////////////////
 //
 // 发送数据
 // param: callBackName执行
 //
 ///////////////////////////////////////////////////////////////////////////////////
function sendRequest(callBackName,method,data,actionMethod,encodedF,callBackData){
	callBack = callBackName;
	params	= callBackData;
	xmlhttp =createHttpRequest(); 
	if ( xmlhttp == null ){
		return;
	}
	
	 var url =document.URLUnencoded;
	 var endFile = null;
		 if ( url.indexOf(".")>0){
		 	endFile = url.substring(url.lastIndexOf("/")+1,url.length);
		    url = url.substring(0,url.lastIndexOf("/"));
		 } 
		
	 url = url + "/cisp.doAjax";
	 if (!encodedF) {
	 	data = uriEncode(data);
	 }
	 if ( method.toUpperCase() == 'GET'){
	 	url += "?";
	 	url += "cispAjax=" +actionMethod;
		if ( data != null){
			if (data.length>0){
				url += "&"+data;	
			}
		}
  	  data = null;
	 }else if( method.toUpperCase() == 'POST') {
	 	url += "?";
	 	url += "cispAjax=" +actionMethod;	 
	 }
	
	 xmlhttp.onreadystatechange = requestValue;
	
	
	 xmlhttp.open(method.toUpperCase(),url,true);
	 
	 setEncHeader(xmlhttp);
	 
	 xmlhttp.send(data);
	 
}
 ////////////////////////////////////////////////////////////////////////////////////
 //
 // 设定传递ajax的头对象
 //
 ///////////////////////////////////////////////////////////////////////////////////
 function setEncHeader(xmlhttp){
     var contentTypeUrlenc = 'application/x-www-form-urlencoded; charset=UTF-8';
     if(!window.opera){
         xmlhttp.setRequestHeader('Content-Type',contentTypeUrlenc);
     } else {
         if((typeof xmlhttp.setRequestHeader) == 'function'){
             xmlhttp.setRequestHeader('Content-Type',contentTypeUrlenc);
          }
     }
     return xmlhttp
 }
 ////////////////////////////////////////////////////////////////////////////////////
 //
 // 把数据用&连接起来
 //
 ///////////////////////////////////////////////////////////////////////////////////
 function uriEncode(data){
     if(data!=""){
         var encdata = '';
         var datas = data.split('&');
         for(i=1;i<datas.length;i++)
         {
             var dataq = datas[i].split('=');
             encdata += '&'+encodeURIComponent(dataq[0])+'='+encodeURIComponent(dataq[1]);
         }
     } else {
         encdata = "";
     }
     return encdata;
 }
 ////////////////////////////////////////////////////////////////////////////////////
 //
 // 获得系统的返回值
 //
 ///////////////////////////////////////////////////////////////////////////////////
function requestValue(){
 var rexmlRess = null;
 rootn = null;
 if (xmlhttp.readyState == 4) { 
  	if (xmlhttp.status == 200) {  
  		rexmlRess  = xmlhttp.responseXML;
  		var root=rexmlRess.documentElement;
  		rootn =  root.childNodes;
		var callBacks= callBack;
		if( params == null){
			params = new Array();
		}
		callBacks +="(";
		for(var i = 0 ; i < rootn.length ; i++){
			var id = rootn[i].getAttribute("id");
			for( var j=0;j<params.length;j++){
			var obj = params[j];
				if ( obj == id ){
					var value = rootn[i].getAttribute("value");
					callBacks += "'"+value +"',";
				}				
			}
		}
		if ( callBacks.length > callBack.length +1 ){
			callBacks = callBacks.substring(0,callBacks.length-1);
		}
		callBacks +=")";
  		setTimeout(callBacks, 1); 
	  }else{
		return rexmlRess;
	  }
   }	 
   return rexmlRess;
}
////////////////////////////////////////////////////////////////////////////////////
//
// 高级搜索 根据选择搜索的条件 进行字段变化所用的javascript
//
///////////////////////////////////////////////////////////////////////////////////
function changeTalbe()
{
	if(this.document.getElementById("select").options.value==0)
	{
		document.getElementById("table1").style.display='none'; 
		document.getElementById("table3").style.display='none'; 
		document.getElementById("table4").style.display='none';
	}
	else if(this.document.getElementById("select").options.value==1)
	{
		document.getElementById("table1").style.display='block';
		document.getElementById("table3").style.display='none'; 
		document.getElementById("table4").style.display='none';
	}
	else if(this.document.getElementById("select").options.value==3)
	{
		document.getElementById("table1").style.display='none';
		document.getElementById("table3").style.display='block'; 
		document.getElementById("table4").style.display='none';
	}
	else if(this.document.getElementById("select").options.value==4)
	{
		document.getElementById("table1").style.display='none'; 
		document.getElementById("table3").style.display='none'; 
		document.getElementById("table4").style.display='block';
	}
}
////////////////////////////////////////////////////////////////////////////////////
//
// 验证母婴用品的搜索字段是否都为空
//
///////////////////////////////////////////////////////////////////////////////////
function   isfulla(){  
	    if(document.muying.vipStr1.value==""&&document.muying.vipStr2.value==""&&document.muying.vipStr3.value==""&&document.muying.vipStr4.value==""&&document.muying.vipStr5.value==""&&document.muying.vipStr6.value==""&&document.muying.vipStr7.value==""&&document.muying.vipStr8.value==""){   
		  alert("您输入的搜索条件至少有一项不能为空！");  
		  return   false;   
		  }
  	return   true;
}
////////////////////////////////////////////////////////////////////////////////////
//
// 验证药品的搜索字段是否都为空
//
/////////////////////////////////////////////////////////////////////////////////// 
function   isfullb(){    
	    if(document.yaopin.vipStr1.value==""&&document.yaopin.vipStr2.value==""&&document.yaopin.vipStr3.value==""&&document.yaopin.vipStr4.value==""&&document.yaopin.vipStr5.value==""&&document.yaopin.vipStr6.value==""&&document.yaopin.vipStr7.value==""&&document.yaopin.vipStr8.value==""&&document.yaopin.vipStr9.value==""&&document.yaopin.vipStr10.value==""&&document.yaopin.vipStr11.value==""&&document.yaopin.vipStr12.value==""&&document.yaopin.vipStr13.value==""&&document.yaopin.vipStr14.value==""&&document.yaopin.vipStr15.value==""&&document.yaopin.vipStr16.value==""&&document.yaopin.vipStr17.value==""&&document.yaopin.vipStr18.value==""&&document.yaopin.vipStr19.value==""){   
		  alert("您输入的搜索条件至少有一项不能为空！");   
		  return   false;   
		  }
  	return   true;
}
////////////////////////////////////////////////////////////////////////////////////
//
// 验证知识库的搜索字段是否都为空
//
/////////////////////////////////////////////////////////////////////////////////// 
	function   isfullc(){   
    
	    if   (document.zhishiku.vipStr1.value==""&&document.zhishiku.vipStr2.value==""&&document.zhishiku.vipStr3.value==""){   
		  alert("您输入的搜索条件至少有一项不能为空！");   
		  document.zhishiku.vipStr1.focus();   
		  return   false;   
		}   
  	return   true;
}

