﻿function getControlByControlId(Tags,ControlId)
{
    var inputList = document.getElementsByTagName(Tags);
    for(var i=0;i<inputList.length;i++)
    {
         var control = inputList.item(i);
        if(control.getAttribute("controlId") == null || control.getAttribute("controlId") ==  undefined) continue;
        if(control.getAttribute("controlId") == ControlId)
        {
             return inputList.item(i);
        }
    }
    return null;
}
	    
function SelectUser(TextControlID ,ValueControlID ,SelCount, SelType, customEvent)
{	
	var location	= document.location.href;
	var txtmriDirectorOpinion =  document.getElementById(ValueControlID);	//txtmriDirectorOpinion
	if(txtmriDirectorOpinion)
	{
		oldValue = txtmriDirectorOpinion.value;
		//setTimeout('CheckLeaderList()',500);
		setTimeout(customEvent,500);
	}
	var Type = '3';
	var Disable = '00000000'
	if(SelType == "dept")
	{
		Type = '3';
		Disable = '00000100'
	}
	//alert(location + 'UAICInterface/Users/GetUser.aspx?ctext=' + TextControlID +'&cvalue=' + ValueControlID + '&m=' + SelCount + '&d=' + Type + '&e=' + Disable);
	location	=  'http://' + location.split('/')[2] + '/';
	//location	=  'http://192.168.0.33/';
	//alert(location);
	
	window.showModalDialog(
		location + 'UAICInterface/Users/GetUser.aspx?ctext=' + TextControlID +'&cvalue=' + ValueControlID + '&m=' + SelCount + '&d=' + Type + '&e=' + Disable,
		window, 
	'dialogHeight: 600px; dialogWidth: 800px;resizable: Yes; scroll: No; status: No; help: No;  '
	);
}
//设置排序css
function Sort(strSortCondition,strdivID)
{
   var htttHead=location .href .split('?')[0];
   var strSpID=location .href .split('?')[1].split('&')[0];
   var str="";
   var strdiv= getControlByControlId("div",strdivID);
   if(strdivID=="divCount")
   {
       if(strdiv.className=="divCount-img-down-sliver")
       {
         strdiv .className="divCount-img-down";
         str="&strOrder=desc"
       }
       else if(strdiv.className=="divCount-img-down")
       {
         strdiv .className="divCount-img-up";
         str="&strOrder=asc"
       }
       else if (strdiv.className=="divCount-img-up")
       {
         strdiv .className="divCount-img-down";
         str="&strOrder=desc"
       }
   }
   else if (strdivID=="divDate")
   {
      if(strdiv .className=="divDate-img-down-sliver")
       {
         strdiv .className="divDate-img-down";
         str="&strOrder=desc"
       }
       else if(strdiv .className=="divDate-img-down")
       {
         strdiv .className="divDate-img-up";
         str="&strOrder=asc"
       }
       else if (strdiv .className=="divDate-img-up")
       {
         strdiv .className="divDate-img-down";
         str="&strOrder=desc"
       }  
   }
   var url=htttHead+"?"+strSpID+"&strSort="+strSortCondition+str+"&strDivID="+strdivID;
   location .href=url;
}
	
// 默认加载排序css
function ChangeSortImg(strDivID)
{
//	  var str=document .getElementById("hidOrder").value;
   var strdivDate= getControlByControlId("div","divDate");
   var str=getControlByControlId("input","hidOrder");
   var strdiv= getControlByControlId("div",strDivID);
   if(str.value!="")
   {
       var strOrder=location .href .split('?')[1].split('&')[2];
       if(strOrder.split('=')[1]=="desc")
       {
          if(strDivID=="divCount")
          {
             strdiv .className="divCount-img-down";
             strdivDate .className="divDate-img-down-sliver";
          }
          else if (strDivID=="divDate")
          {
             strdiv .className="divDate-img-down";
          }
       } 
       else
       {
         if(strDivID=="divCount")
          {
             strdiv .className="divCount-img-up";
             strdivDate .className="divDate-img-down-sliver";
          }
          else if (strDivID=="divDate")
          {
             strdiv .className="divDate-img-up";
          }
       }   
   }
}

//Page css
function PageCss(strSpID)
{
    var strTemp="btn_"+strSpID;
    
     if(document.getElementById(strTemp))
     {
         document.getElementById(strTemp).className  = 'btn-sel-background';
     }
     for( var i=0; i<document.getElementsByTagName("input").length; i++ )  //调整标签样式
     {
        if(document.getElementsByTagName("input")[i].type=='button')
        {
             if(document.getElementsByTagName("input")[i].id!=strTemp)
             {
                 var obj = document.getElementsByTagName("input")[i].id;
                 document .getElementById(obj).className="btn-background";
             }
         }
      }
}

function OpenDetails(strAutonum,spPathID)
{
  var htttHead    ="http://"+location.href.split('/')[2]+"/"+location.href.split('/')[3]+"/";
   var url="PublicInfoUI/PublicInfoDetailElse.aspx?Autonum="+strAutonum;
   var left=(screen.AvailWidth-200)/2;
   var top=(screen.AvailHeight-200)/2;
   left =left -300;
   top =top-300;
   window .open(htttHead+url,'_blank','toolbar=no,width=900,height=800,left='+left+',top='+top+',status=no,scrollbars=no,resizable=yes,menubar=no');
}
