﻿// JScript 文件

 function $(obj){
	return document.getElementById(obj);
}

 //创建HTTP请求对象
 function CreateXMLHttp() {
    var arrSignatures = ["MSXML2.XMLHTTP",
                         "Microsoft.XMLHTTP"];
      for (var i=0; i < arrSignatures.length; i++) {
        try {
             var xmlhttp = new ActiveXObject(arrSignatures[i]);
             return xmlhttp;
             } 
        catch (oError)
             {
             }
       }          
           throw new Error("你的系统上没有安装MSXML.");               
    }
    
  
    
function Arrange(doctorID){	     	
	 var Arrange = document.getElementById("Arrange");
	 var xmlhttp =CreateXMLHttp();
		try
		{
	 xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
		  var data = xmlhttp.responseText
			Arrange.innerHTML=data;			
			}
		else{
			Arrange.innerHTML="数据加载失败";
			}
		}
	else{
		Arrange.innerHTML="<img src='../images/loading.gif'>数据加载中...";
		}
	}
	xmlhttp.open("post", "GetArrange.aspx",true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send("doctorID="+doctorID);
	}
	catch(e)
	{
	   alert(e.message);
	 }
 }
 
 function Refresh(doctorID,weekID,timeID,pageID)
 {
   ArrangeList(doctorID,weekID,timeID,pageID);   
 }
 
 function ArrangeList(doctorID,weekID,timeID,pageID){		
	 var ArrangeList = document.getElementById("ArrangeList");
	 var xmlhttp =CreateXMLHttp();	
	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			ArrangeList.innerHTML=xmlhttp.responseText;			
			}
		else{
			ArrangeList.innerHTML="数据加载失败";
			}
		}
	else{
		ArrangeList.innerHTML="<img src='images/loading.gif'>数据加载中...";
		}
	}
	xmlhttp.open("post", "GetArrangeList.aspx", true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send("doctorID="+doctorID+"&weekID="+weekID+"&timeID="+timeID+"&pageID="+pageID);
 }


function selCat(name,obj,n)
{
    getData(obj, "");
	for(i=1;i<=n;i++)
	{ 
	if (name.substring(0,2)=='eR' )
	  {eval("document.getElementById('"+name+i+"').className='eR'");}	   
	   else
 	   {j=name+i
		eval("document.getElementById('"+name+i+"').className=j");
		}
		if(name == 'n' || name == 's'){}
		else{
			eval("document.getElementById('display_"+name+'_'+i+"').style.display='none'");
			}
	}
	N=name+obj
	if(name == 'myt' || name == 'dt' ||  name == 'ds'||  name.substring(0,2) == 'eR'){
	  if (name.substring(0,2)=='eR'){ N='eR_two'}
	    if (name=='ght'){ N='ght_two'}
	  else {N=N+'_two';}
		eval("document.getElementById('"+name+obj+"').className= N");
		}

	else{ 
	   if (name.substring(0,2)=='eR'){ N='eR'}
	    if (name=='ght'){ N='ght'}
	   else {N=N;}
		eval("document.getElementById('"+name+obj+"').className= N");
	}
	if(name == 'n' || name == 's'){}
	else{
		eval("document.getElementById('display_"+name+'_'+obj+"').style.display=''");
	}
}

function Show(id,name){
    var obj = $(name);
	var xmlhttp =CreateXMLHttp();	
	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			getData(obj ,xmlhttp.responseText);
		}
	}
	}
	xmlhttp.open("POST", "js/comobox.aspx", true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send("key="+escape(obj.value)+"&id="+escape(id));
}


function getData(obj, str){
	if($("FloatDiv")!=null){
	document.body.removeChild($("FloatDiv"));
	}
	if(str!=""){
		var objDiv = document.createElement("Div");		
		obj.style.position="relative"; 
		objDiv.style.position="absolute"; 
		objDiv.setAttribute("id","FloatDiv");
		objDiv.style.background = "#fff";	
		objDiv.style.height = "95px";
		objDiv.style.overflow = "auto";		
		objDiv.style.width = (obj.offsetWidth) + "px";
		objDiv.style.top = (obj.offsetTop+15) + "px";
		objDiv.style.left =(obj.offsetLeft) + "px";
		
		document.body.appendChild(objDiv);		
		var arrStr = str.split(',');
		for(var i=0; i<arrStr.length;i++){
			var objSub = document.createElement("Div");
			objSub.innerHTML = "&nbsp;"+arrStr[i];
			objSub.style.display = "block";
			objSub.style.width = (obj.offsetWidth-20) + "px";
			objSub.onclick = function(){				
				this.style.background = "#ccc";
				objDiv.style.display ="none";
				obj.value = this.innerHTML.replace("&nbsp;", "");
			}
			objSub.onmouseout = function(){				
				this.style.background = "#fff";
			}
			objDiv.appendChild(objSub);
		}
	}
}

function ShowGHT(id,name){
    var obj = $(name);
	var xmlhttp =CreateXMLHttp();	
	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			getDataGHT(obj ,xmlhttp.responseText);
		}
	}
	}
	xmlhttp.open("POST", "../js/comobox.aspx", true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send("key="+escape(obj.value)+"&id="+escape(id));
}

function getDataGHT(obj, str){
	if($("FloatDiv")!=null){
	document.body.removeChild($("FloatDiv"));
	}
	if(str!=""){
		var objDiv = document.createElement("Div");		
		obj.style.position="relative"; 
		objDiv.style.position="absolute"; 
		objDiv.setAttribute("id","FloatDiv");
		objDiv.style.background = "#fff";	
		objDiv.style.height = "95px";
		objDiv.style.overflow = "auto";		
		objDiv.style.width = (obj.offsetWidth) + "px";
		objDiv.style.top = (obj.offsetTop+5) + "px";
		objDiv.style.left =(obj.offsetLeft) + "px";
		
		document.body.appendChild(objDiv);		
		var arrStr = str.split(',');
		for(var i=0; i<arrStr.length;i++){
			var objSub = document.createElement("Div");
			objSub.innerHTML = "&nbsp;"+arrStr[i];
			objSub.style.display = "block";
			objSub.style.width = (obj.offsetWidth-20) + "px";
			objSub.onclick = function(){				
				this.style.background = "#ccc";
				objDiv.style.display ="none";
				obj.value = this.innerHTML.replace("&nbsp;", "");
			}
			objSub.onmouseout = function(){				
				this.style.background = "#fff";
			}
			objDiv.appendChild(objSub);
		}
	}
}


function loginIndex(id,user,psw)
    {
        var Login = document.getElementById('Login');       
	    var xmlhttp =CreateXMLHttp();
		try
		{
	      xmlhttp.onreadystatechange=function(){
	         if (xmlhttp.readyState==4){
		        if (xmlhttp.status==200){
		         var data = xmlhttp.responseText;		              
		         Login.innerHTML=data;	
		        
		          if(document.getElementById("rwstr"))
		         { 
		          if(document.getElementById('rwstr').value==1)
		          history.go(0);
		         }
		                 					
		       }
		       else{
			     Login.innerHTML="数据加载失败";
			   }
		     }
	        else{
		      Login.innerHTML="<img src='images/loading.gif'>数据加载中...";
		    }
	     }
	     xmlhttp.open("post", "reg/Load.aspx",true);
	     xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	    xmlhttp.send("id="+id+"&user="+user+"&psw="+psw);
	 }
	catch(e){
	   alert(e.message);
	 }	
 }
 
function hospdata(id)
    { 
       if(id==1)
        {var hospdv = document.getElementById('display_ds_1');}
        else
        {var hospdv = document.getElementById('display_ds_2');}      
	    var xmlhttp =CreateXMLHttp();
		try
		{
	      xmlhttp.onreadystatechange=function(){
	         if (xmlhttp.readyState==4){
		        if (xmlhttp.status==200){
		         var data = xmlhttp.responseText;		              
		         hospdv.innerHTML=data;	        	        					
		       }
		       else{
			     hospdv.innerHTML="数据加载失败";
			   }
		     }
	        else{
		      hospdv.innerHTML="<img src='images/loading.gif'>数据加载中...";
		    }
	     }
	     xmlhttp.open("post", "js/hot.aspx",true);
	     xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	    xmlhttp.send("id="+id);
	 }
	catch(e){
	   alert(e.message);
	 }	
 }
 
function showload()
	{
		 window.open('shop/activation.aspx','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=390,height=500,left=200,top=200');
	
	}