// JavaScript Document
// JScript 文件
/*
objs:要修改样式的元素
index:当前要修改的索引
count:同类型的元素的长度
value:已选择的元素的value
objs2:需更改显示方式的元素
*/
function tab(objs,index,count,value,objs2){
    tab_SetStyle(objs,index,count,value);
    tab_SetDisp(objs2,index,count);                           
}

function tab_SetStyle(objs,index,count,value){
	if(value==""||count==0) return;
    var tempValue = "";
    var prop = "className";
    var vIndex = 0;
    var objAry = objs.split("|");
    var values = value.split("|");
    if(values[0].indexOf("$")!=-1){
		prop = values[0].split("$")[0];
		vIndex = 1;
	}//未实现多元素
    if(eval("$(objAry[0]+index)."+prop) == values[0].split("$")[vIndex])
        return;
    else
        tempValue = eval("$(objAry[0]+index)."+prop);
    for(var i=0;i<objAry.length;i++){
        for(var j=1;j<=count;j++){
            eval("$(objAry[i]+j)."+prop+"=tempValue;");
        }
        eval("$(objAry[i]+index)."+prop+"=values[i].split('$')[vIndex];");
    }
}

function tab_SetDisp(objs,index,count){
	if(count==0) return;
    var objAry = objs.split("|");
    var temp = $(objAry[0]+index).style.display;
    if(temp == "block" || temp == "")
        return;
    for(var i=0;i<objAry.length;i++){	
        for(var j=1;j<=count;j++){
            $(objAry[i]+j).style.display = "none";
        }
        $(objAry[i]+index).style.display = "block";
    }
}

function $(){
return document.getElementById(arguments[0]);
}

function $1(id,value){
var o=$(id);
if(o) o.innerHTML=value;
}
//清除字符串前后空格
String.prototype.trim = function(){
	return this.replace(/^\s+/,"").replace(/\s+$/,"");
}
String.prototype.startsWith = function(s){
	if(this.length<s.length)
		return false;
	if(this.substr(0,s.length) == s)
		return true;
	return false;
}
String.prototype.endsWith = function(s){
	if(this.length<s.length)
		return false;
	if(this.substring(this.length-s.length)==s)
		return true;
	return false;
}

 function SearchSick(){
	   var title=GetObj("tbx_SickName").value;
	   if(title.replace(/(^[\s]*)/g, "").length>0){
	   location.href ="Search.aspx?QueryTitle="+title;
	   }
	   else
	   {
	    alert("疾病名称不能为空！");
		GetObj("tbx_SickName").focus();
	   }
	 }
	 
	 
	 
	 function SearchMedicine(){
	 var types=document.getElementsByName("rd_MedicineType");
	 var typestr="9";
	 if(types[0].checked){
	  typestr="0";
	 }
	 else if(types[1].checked){
	  typestr="1";
	 }
	  else if(types[2].checked){
	  typestr="2";
	 }
	   var names=GetObj("tbx_MedicineName").value;
	   var fuction=GetObj("tbx_MedicineFunction").value;
	   
	   if(names.replace(/(^[\s]*)/g, "").length==0&&fuction.replace(/(^[\s]*)/g, "").length==0)
	   {
	    alert("药品名称或药品功效不能为空！");
		GetObj("tbx_MedicineName").focus();
		return;
	   }
	   
	 
	      location.href ="../Medicine/Search.aspx?QueryType="+typestr+"&QueryName="+names+"&QueryFunction="+fuction;
	 }
	 
	  
	 function SearchInspection(){
	   var title=GetObj("tbx_InspectionName").value;
	   if(title.replace(/(^[\s]*)/g, "").length>0){
	   location.href ="../Inspection/Search.aspx?QueryTitle="+title;
	   }
	   else
	   {
	    alert("检查名称不能为空！");
		GetObj("tbx_InspectionName").focus();
	   }
	 }
	 
	  //搜索医生医院 
 function SearchDoc()
 {
 var type=document.getElementsByName("rd_HsType");
 var p=GetObj("select_Province").value;
 var c=GetObj("select_City").value;
 var v=GetObj("tbx_Key").value;
 var f=GetObj("sel_DoctorOffices").value;
  if(p=="请选择"){
   p="";
  }
  if(c=="请选择"){
   c="";
  }
   if(type[0].checked)//医院
   {
     location.href="../Hospital/SearchHospital.aspx?QueryProvince="+p+"&QueryCity="+c+"&QueryKey="+v+"&QueryDoctorOffices="+f;
   }
   else//医生
   {
    location.href="../Hospital/SearchDoctor.aspx?QueryProvince="+p+"&QueryCity="+c+"&QueryKey="+v+"&QueryDoctorOffices="+f;
   }
 }	
