  function Switch_One(o){
	  var o=o , o1=document.all.ID;
	  if (o.index && o1){
		  if (o.style.backgroundColor=="#ff9900"){
			  o.style.backgroundColor="#ffffcc";
			  if (!o1.length) o1.checked=false; else o1[o.index].checked=false;
		  }else{
			  o.style.backgroundColor="#ff9900";
			  if (!o1.length) o1.checked=true; else o1[o.index].checked=true;
		  }
	  }
  }
  function Switch_All(checked){
	  var checked=checked;
	  var o=document.all.TRID, o1=document.all.ID;
	  
	  if (checked==null) checked=true;
	  if (o && o1){
		  if (!o1.length){
			  if (checked==true){
				  o.style.backgroundColor="#ff9900";
				  o1.checked=true;
			  }else{
			      o.style.backgroundColor="#F6F8F9";
				  o1.checked=false;
			  }
		  }else{
			  for (var i=0;i<o1.length;i++){
				  if (checked==true){
				      o[i].style.backgroundColor="#ff9900";
				      o1[i].checked=true;
			      }else{
			          o[i].style.backgroundColor="#F6F8F9";
				      o1[i].checked=false;
			      }
			  }
		  }
	  }
  }
  
  function Is_Switch_One(){
	  var IDs = gFocusIDs(document.all.ID);
	  if (IDs=="" || IDs.indexOf(", ")!=-1) return ""; else return IDs;
  }
  
  function gFocusIDs(id){
	 var id=id;
	 if (id){
	   if (!id.length){
		 if (id.checked) {return id.value;} else {return "";}
	   }else{
		  var IDs="";
		  for (var i=0;i<id.length;i++){
			 if (id[i].checked == true) IDs+=id[i].value+", ";
		  }
		  if (IDs.substr(IDs.length-2,IDs.length)==", "){return IDs.substr(0,IDs.length-2);}else{return IDs;}
	   }
	 }else return "";
  }
  
  function gValues(id){
	 var id=id;
	 if (id){
	   if (!id.length){
		 if (!id.disabled) return id.value; else return "";
	   }else{
		  var IDs="";
		  for (var i=0;i<id.length;i++){
			 if (!id[i].disabled) IDs+=id[i].value+", ";
		  }
		  if (IDs.substr(IDs.length-2,IDs.length)==", "){return IDs.substr(0,IDs.length-2);}else{return IDs;}
	   }
	 }else return "";
  }
  function SetOrderNo(no, index, disabled){
	var no=no, index=index, disabled=disabled;
	if (index==null || index=="") index=0;
	if (no){
	  if (!no.length){
		no.disabled=!disabled;
	  }else{
	    no[index].disabled=!disabled;
	  }
	}
  }
  
  function CNum(value){
    if (isNaN(parseFloat(value))){
	  return 0;
	}else{
	  return parseFloat(value);
	}
  }
  function CInt(value){
    if (isNaN(parseInt(value))){
	  return 0;
	}else{
	  return parseInt(value);
	}
  }
  
  function DoMany(URL, Action, Title, Confirm){
	  var IDs=gFocusIDs(document.all.ID);
	  if (IDs==""){
		  alert("请选择要"+ Title +"的记录.");
	  }else{
		  if (Confirm!=null && Confirm){
		      if (!confirm("确定要"+ Title +"选中的记录吗?"))return;
		  }
		  window.location=URL + "action=" + action + "&IDs=" + IDs;
	  }
  }
  
  function DoOne(URL, Title){
	  var IDs=gFocusIDs(document.all.ID);
	  if (IDs=="" || IDs.indexOf(', ')!=-1){
		  alert("请选择要一个要"+ Title +"的记录.");
	  }else{
		  window.location=URL + IDs;
	  }
  }
  
  function Delete(URL, action){
	  var IDs=gFocusIDs(document.all.ID);
	  if (IDs==""){
		  alert("请选择要删除的记录.");
		  //alert("Please choose to delete the record.");
	  }else{
		  if (confirm("确定要删除选中的记录吗?")){
		  //if (confirm("Determined to delete the selected record?")){
			  window.location=URL + "action=" + action + "&IDs=" + IDs;
		  }
	  }
  }
  
  function Status(URL, action, ID, Value){
	  var V=Value;
	  if (V==null || V==true) V="Yes"; else V="No";
	  window.location=URL + "action=" + action + "&IDs=" + ID + "&Values=" + V;
  }
  
  function Order(URL, Derect){
	  var Derect = Derect;
	  if (Derect=="Up") Title="上移"; else Title="下移";
	  var IDs=gFocusIDs(document.all.ID);
	  if (IDs==""){
		  alert("请选择一个要"+ Title +"的记录.");
	  }else{
		  if (IDs.indexOf(", ")!=-1){
			  alert("请只选择一个"+ Title +"要的记录.");
		  }else{
			  if (Derect=="Up")
			  window.location=URL + "action=OrderUp&IDs=" + IDs;
			  else
			  window.location=URL + "action=OrderDown&IDs=" + IDs;
		  }
	  }
  }
  
  function getRemark(action, Title){
	  var cache;
	  var IDs=gFocusIDs(document.all.ID);
	  if (IDs==""){
		  alert("Please select will do items.");
	  }else{
		  var f=document.DoForm;
		  if (f){
		      f.action.value=action;
			  f.IDs.value = IDs;
			  window.open("Remark.asp?Title=" + Title, "Remark", "left=200px,top=150px,Width=400px,Height=150px,status=0;scrollbars=no,resizable=no");
		  }
	  }
  }
  
  function getOpen(URL,width,height,scrollbars,action,title){
	  var title=title;if (title==null) title="操作";
	  var f=document.SearchFrom;
	  var IDs=gFocusIDs(document.all.ID);
	  if (IDs==""){alert("请选择要"+ title +"的记录");return;}
	  if (f){
		  f.action.value=action;
		  f.IDs.value=IDs;
		  window.open(URL,"","left=200,top=100,width=" + width + ",height=" + height + ",scrollbars=" + scrollbars);
	  }
  }
  
  function Open(URL,width,height,scrollbars){
	  window.open(URL,"","left=200,top=100,width=" + width + ",height=" + height + ",scrollbars=" + scrollbars);
  }
  
  
  function LoadSelect(O, Source, OID, CheckedOID, Values, Texts, Selected){
	  var O=O;if (!O) return;
	  var Source = Source.split(",||||,");
	  var Values = Values.split("|");
	  var Texts = Texts.split("|");
	  var Selected = Selected;
	  var Cache, NewCache="";
	  
	  for (var i=0;i<Source.length;i++){
		  Cache = Source[i].split(",||,")
		  if (Cache[OID]==CheckedOID) NewCache+=Source[i] + ",||||,";
	  }
	  
	  if (NewCache.substr(NewCache.length-6,NewCache.length)==",||||,") NewCache=NewCache.substr(0,NewCache.length-6);
	  if (NewCache==""){
		  O.length = 1;
	  }else{
	      var a="",b="";
		  NewCache = NewCache.split(",||||,");O.length = NewCache.length + 1;
		  for (var i=0;i<NewCache.length;i++){
			  Cache = NewCache[i].split(",||,");
			  a="";b="";
			  for (var j=0;j<Values.length;j++) a+=Cache[Values[j]];
			  for (var j=0;j<Texts.length;j++) b+=Cache[Texts[j]];
			  O.options[i+1].value=a;O.options[i+1].text=b;
		  }
		  if (Selected!=null && Selected!="" && Selected!="0") O.value=Selected;
	  }
  }
  
  
  function SubmitForm(f){
	var f=f;
	if (f){
		for (var i=0;i<f.elements.length;i++){
			var o=f.elements[i];
			if (o.DateType && o.msg){
				switch (o.DateType.toUpperCase()){
					case "INT":
					  if (CInt(o.value)<=0){
						  alert(o.msg);
						  o.focus();
						  return false;
					  }
					  break;
					case "NUMBER":
					  if (CNum(o.value)==0){
						  alert(o.msg);
						  o.focus();
						  return false;
					  }
					  break;
					case "STR":
					  if (o.value==""){
						  alert(o.msg);
						  o.focus();
						  return false;
					  }
					  break;
					case "EMAIL":
					  if (o.value!=""){
	                      if (o.value.indexOf("@") == -1){
							  alert(o.msg);
						      o.focus();
		                      return false;
	                      }
					  }
					  break;
					case "CHECKBOX":
					  var IDs = gFocusIDs(o);
					  if (IDs==""){
						  alert(o.msg);
						  return false;
					  }
					  break;
					case "EDITOR":
					  var Source=document.frames[o.msg];
					  if (Source) o.value=Source.GetHtml();
					  break;
					case "DATE":
					  
					  break;
					default:
					  break;
				}
			}
		}
		return true;
	}else return false;
  }
  
  function OjbDisplay(o){
	  var o=o;
	  if (o){
		  o.style.display=(o.style.display=="")?"none":"";
	  }
  }
  
  
  addEvent(window, "load", SetManageTable);
  function SetManageTable(){
	  var BGColor1="#E3E3E3";
	  var BGColor2="#F5F5F5";
	  if (!document.getElementsByTagName) return;
      tables = document.getElementsByTagName("table");
	  for (ti=0;ti<tables.length;ti++) {
        thisTbl = tables[ti];
        if (thisTbl.id && thisTbl.id=="ManageTable") {
			if (thisTbl.rows && thisTbl.rows.length > 0) {
				for (var i=0;i<thisTbl.rows.length;i++){
					if (i % 2==0){
					    thisTbl.rows[i].style.background=BGColor1;
					}else{
						thisTbl.rows[i].style.background=BGColor2;
					}
				}
            }
        }
      }
  }
  
  
  
  function addEvent(elm, evType, fn, useCapture)
  // addEvent and removeEvent
  // cross-browser event handling for IE5+,  NS6 and Mozilla
  // By Scott Andrew
  {
      if (elm.addEventListener){
        elm.addEventListener(evType, fn, useCapture);
        return true;
      } else if (elm.attachEvent){
        var r = elm.attachEvent("on"+evType, fn);
        return r;
      } else {
        alert("Handler could not be removed");
      }
  }
  