﻿
    var objwindow_onload = window.onload ;
    var IE  = (window.navigator.appName.indexOf("Microsoft Internet Explorer") != -1 ? true : false);
    
    function sys_winshow(url,title,width,height)
    {
             var sys_width        = (width  == undefined || isNaN(width)  ? screen.availWidth  : width);
             var sys_height       = (height == undefined || isNaN(height) ? screen.availHeight : height);
             var sys_showx        = (screen.availWidth - width)/2;
             var sys_showy        = (height == undefined ?  0  : (screen.availHeight - height)/2);

             if (IE)
             {
                 return window.showModalDialog("../Show.aspx?url="+url,[self,title==undefined?"":title],"dialogLeft:"+sys_showx+";dialogTop:"+sys_showy+";dialogWidth:"+sys_width+"px;dialogHeight:"+sys_height+"px; status:no;help:no");
             }
             else
             {
                 var objw= window.open("../Show.aspx?url="+url,title,"status=no,menubar=no,toolbar=no,resizable=yes,left="+sys_showx+",top="+sys_showy+",width="+sys_width+",height="+sys_height);
             }
    }

    function auto_update(PrimaryKey)
    {
             var returnValue = window.returnValue;
             if (IE){
                 if (PrimaryKey != undefined)
                     if (returnValue !=  undefined)
                         window.returnValue = returnValue + ";" + PrimaryKey;
                     else
                         window.returnValue = PrimaryKey;
                 else
                         window.returnValue = 'update';
             }
             else
             {
                top.opener.onupdate_DataGriddg1(null,PrimaryKey,PrimaryKey);
             }
    }  
   
    function sys_winview( url )
    {
             showW = screen.availWidth  - 11;
             showH = screen.availHeight - 80;
             var ReturnValue = window.open(url,"","status=yes,menubar=no,toolbar=yes,resizable=yes,scrollbars=yes,left=0,top=0,width="+showW+",height="+showH);
    }
    
    function sys_winwait(e,text)
    {
            var waitframe = document.getElementById("ifMain")
            if (waitframe == null)
                return false;

            if (e == "open"){
                waitframe.style.display="";
                var sptitle = ifMain.document.getElementById("sptitle");
                var sptotal = ifMain.document.getElementById("sptotal");
                if (sptitle != null)
                    sptitle.innerText = text;
                if (sptotal!=null)
                    sptotal.innerText = "1";
            }
            if (e == "close"){
                waitframe.style.display="none";
            }
            waitframe.style.left = (parseInt(document.body.clientWidth) - parseInt(waitframe.style.width))/2
            waitframe.style.top  = document.body.scrollTop+(parseInt(document.body.clientHeight) - parseInt(waitframe.style.height))/2
   }
      
   function calendar_show(ctrlobj)
   {
            if (ctrlobj != null)
            {
                if (ctrlobj.readOnly || ctrlobj.disabled)
                    return false;
            }
            showx = event.screenX - event.offsetX; // + deltaX;
            showy = event.screenY - event.offsetY; // + deltaY;
            newWINwidth = 210 + 4 + 18;

            retval = window.showModalDialog("Calendar.aspx", "", "dialogWidth:280px; dialogHeight:190px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;help:no"  );
            if(retval != null )
            {
               ctrlobj.value = retval;
               return true;
            }
            return false;
   }
   
   function calendar_show2(ctrlobj)
   {
            if (ctrlobj != null)
            {
                if (ctrlobj.disabled)
                    return false;
            }
            showx = event.screenX - event.offsetX; // + deltaX;
            showy = event.screenY - event.offsetY; // + deltaY;
            newWINwidth = 210 + 4 + 18;

            retval = window.showModalDialog("Calendar.aspx", "", "dialogWidth:280px; dialogHeight:190px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;help:no"  );
            if(retval != null )
            {
               ctrlobj.value = retval;
               return true;
            }
            return false;
   }
   
   function CalendarDlg(ctrlobj)
   {
            showx = event.screenX - event.offsetX; // + deltaX;
            showy = event.screenY - event.offsetY; // + deltaY;
            newWINwidth = 210 + 4 + 18;

            retval = window.showModalDialog("../sysdate.htm", "", "dialogWidth:280px; dialogHeight:190px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;help:no"  );
            if( retval != null )
           ctrlobj.value = retval;

   }
   function document_always_onkeydown()
   {
             var keycode    = event.keyCode;
             var onclick    = event.srcElement.onclick;
             var onkeypress = event.srcElement.onkeypress;
             var onkeyup    = event.srcElement.onkeyup;
             if (keycode == 13){
                 if (event.srcElement.type == "file") return true;
                 if (onclick    != null ||
                     onkeypress != null ||
                     onkeyup    != null ||
                     event.srcElement.type == "textarea" ||
                     event.srcElement.type == "submit"){
                     event.keyCode=13;
                     return true;
                 }
                 event.keyCode = 9;
            }
   }
 
   function document_always_onload()
   {
            if (objwindow_onload != null &&
                objwindow_onload.toString().indexOf("document_always_onload()") == -1){
                objwindow_onload();
            }
            
            document.body.scrollTop = self.window.status;
            var iframeObj            = document.createElement("iframe");
            iframeObj.id             = "ifMain";
            iframeObj.name           = iframeObj.id;
            iframeObj.src            = "../Wait.aspx";
            iframeObj.className      = "sys_wait_frame";
            iframeObj.frameBorder    = "0";
            iframeObj.marginheight   = "0";
            iframeObj.marginwidth    = "0";
            iframeObj.style.left     = "0px";
            iframeObj.style.top      = "0px";
            iframeObj.style.width    = "350px";
            iframeObj.style.height   = "80px";
            iframeObj.style.display  = "none";
            iframeObj.style.position = "absolute";
            iframeObj.scrolling      = "no";
            document.body.appendChild(iframeObj);
   }

   document.onkeydown   = document_always_onkeydown;
   window.onload        = document_always_onload;
   
   
   function generalfindDlg(ctrlObj,filename,pathname,width,height,showAll,hidCtrlObj,findCondition,hiddm){
            
            if (typeof(showAll) == "undefined"){
               showAll = "false";
            }
            showx = event.screenX - event.offsetX;
            showy = event.screenY - event.offsetY + 20;
            var findConditions;
            if (typeof(hiddm) != "undefined" && findCondition == ""){
                var dm  =  document.getElementById(hiddm);
                findConditions = dm.value;
            }
            else
            {
              findConditions  =  findCondition;
            }

              var returnValue = winshowDlg("App_Web/general_find.aspx&ctrl="+ctrlObj+
                               "&xmlFileName="+filename+"&pathName="+pathname+
                               "&showAll="+showAll+"&ctrlHid="+hidCtrlObj+
                               "&findCondition="+findConditions,filename,
                               "通用查找对话框",showx,showy,width,height);

   }
   
   function winshowDlg(url,pageName,title,showx,showy,width,height){
            pageName   = pageName.substring(pageName.indexOf("_")+1,pageName.length);
            if (width == "")
                width=400;
            if (height == "")
                height=388;
            var r=window.showModalDialog("../Show.aspx?url="+url,[self,title==undefined?"":title],"dialogLeft:"+showx+";dialogTop:"+showy+";dialogWidth:"+width+"px;dialogHeight:"+height+"px;status:no;help:no");
            if (r==1){
               document.forms[0].submit();
            }
   }
   
    var ReturnWins;
    function sys_openFile( url )
    {
             showW = screen.availWidth  - 11;
             showH = screen.availHeight - 80;
             ReturnWins = window.open(url,"","status=yes,menubar=no,toolbar=yes,resizable=yes,left=0,top=0,width="+showW+",height="+showH);
             //setTimeout("cloase_openFile()",8000); 
    }
    
    function cloase_openFile()
    {
      ReturnWins.close();
    }
    
    function getFormParamByControl(tagName) 
   {
   	        var arr      = "";
         	
         	var tagObj   = document.getElementById(tagName);
         	var inputObj = tagObj.getElementsByTagName("INPUT");
         
        	for (var i = 0;i < inputObj.length ; i++)
        	{
                 var type = inputObj.item(i);
 		         if (type.nodeType == 1)
		         {
			         if (type.type!="radio" && type.type!="checkbox")
				         arr += type.name + "=" + type.value + "&";
				     else if(type.checked)
				         arr += type.name + "=" + type.value + "&";
			     }
		    }
		    
		    var selectObj = tagObj.getElementsByTagName("SELECT");
		    for (var i = 0;i < selectObj.length ; i++)
        	{
                 var type = selectObj.item(i);
 		         if (type.nodeType == 1)
		         {
			         arr += type.name + "=" + type.value + "&";
			     }
		    }
		    
		    var textareaObj = tagObj.getElementsByTagName("TEXTAREA");
		    for (var i = 0;i < textareaObj.length ; i++)
        	{
                 var type = textareaObj.item(i);
 		         if (type.nodeType == 1)
		         {
			         arr += type.name + "=" + type.value + "&";
			     }
		    }
		    
 	        if (arr.length > 0)
      		    arr = arr.substring(0, arr.length - 1);	
      		      		     			
	        return arr;
    }

//-->