﻿var mywin = null;
function Myoa_tool(mylink){ 
  if (! mywin || mywin.closed)
	{
		  mywin=window.open(mylink,"newWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=10,left=10,width=480,height=300");		        
	}
	else
	{	
		   mywin.close();
		   mywin=window.open(mylink,"newWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=10,left=10,width=480,height=300");   
	}
}

function el(obj)
{
    return document.getElementById(obj);
}

var newwin = null;
function showcalendar(type)
{
  //dv=window.showModalDialog("UpLoad.asp?formname="+escape(document.getElementById("mylistn").value),"44","center:1;help:no;status:no;dialogHeight:180px;dialogWidth:433px;scroll:no")
  //if (dv) {if (dv=="null") obj.value='';else obj.value=dv;}
  var mylink="";
  if(type=="link")
  {
     mylink="UpLoad.asp?formname="+type;
  }
  else
  {
     mylink="../UpLoad.asp?formname="+type;
  }
  
  if (! newwin || newwin.closed)
	{
				newwin=window.open(mylink,"newWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=10,left=10,width=480,height=140");
		        
		}
	else
		{	
		         newwin.close();
				newwin=window.open(mylink,"newWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=10,left=10,width=480,height=140");		
		        
		}
  //document.write("<INPUT class=input style=\"CURSOR: hand\" onclick=\"showcalendar(this,this)\" readOnly size=\"25\" name=date1>");
}


function openwin(url)
        {
            top.window.open(url);
            window.close();
            return false;
        }
		
		
//鼠标经过时颜色变化
function MOver(src, clrOver)
{
   if (!src.contains(event.fromElement))
   {
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
   }
}

//鼠标离开时颜色变化
function MOut(src, clrIn)
{
    if (!src.contains(event.toElement))
	{
		src.style.cursor = 'default';			
		src.bgColor = clrIn;
    }
}
	
	function mClk1(src, id) {
        window.location.href = src;
    }
	
	//创建xmlhttprequest对象
	var xmlHttpRequest = null;
	  function getXMLHttpRequest()
		{
			if(window.XMLHttpRequest)
			{
				return new XMLHttpRequest();
			}
			else if (window.ActiveXObject)
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
				
				if (!request)
				{
					request = new ActiveXObject("Msxml2.XMLHTTP");
				}
				
				return request;
			}

		}
		
		//去除字符串左端空格
                function LTrim(str)
				{
                    return str.replace(/^\s*/, '');
                }

                //去除字符串右端空格

               function RTrim(str) {
                      return str.replace(/\s*$/, '');
                }
				//去除字符串两端空格
                function Trim(str) 
				{
                     return LTrim(RTrim(str));
                }
				
				//是否为空值;
function IsEmpty(_str){
    var tmp_str = Trim(_str);
    return tmp_str.length == 0;
}
//是否有效的Email;
function IsMail(_str){
    var tmp_str = Trim(_str);
    var pattern = /^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$/;
    return pattern.test(tmp_str);
}
//是否有效的数字;
//是否有效的数字;
function IsNumber(checkStr)
{
var checkOK = "0123456789";
var allValid = true;
if (checkStr.length<1)
 allValid=false;
  for (i=0;i<checkStr.length;i++)
  {
    ch=checkStr.charAt(i);
    for(j=0;j<checkOK.length;j++)
      if(ch==checkOK.charAt(j))
        break;
    if(j==checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  return allValid;
}

//是否有效的颜色值;
function IsColor(color){
    var temp=color;
    if (temp=="") return true;
    if (temp.length!=7) return false;
    return (temp.search(/\#[a-fA-F0-9]{6}/) != -1);
}
//是否有效的链接;
function IsURL(url){
    var sTemp;
    var b=true;
    sTemp=url.substring(0,7);
    sTemp=sTemp.toUpperCase();
    if ((sTemp!="HTTP://")||(url.length<10)){
        b=false;
    }
    return b;
}
//是否有效的手机号码;
function IsMobile(_str){
    var tmp_str = Trim(_str);
    var pattern = /13\d{9}/;
    return pattern.test(tmp_str);
}

function ResizeImage(imageid,limitWidth,limitHeight) 
        {     
            var image = new Image(); 
            image.src = imageid.src; 
             
            if(image.width <= 0 && image.height <= 0) return; 
             
            if(image.width/image.height >= limitWidth/limitHeight) 
            { 
                if(image.width > limitWidth) 
                { 
                    imageid.width = limitWidth; 
                    imageid.height = (image.height*limitWidth)/image.width; 
                } 
            } 
            else if(image.height > limitHeight) 
            { 
                    imageid.height = limitHeight; 
                    imageid.width = (image.width*limitHeight)/image.height;      
            } 
             
        }

        function InitImages() 
        { 
            var maxWidth = 300; 
            var maxHeight = 500; 
             
            var imgs = document.getElementsByTagName("img"); 
             
            for(var i=0; i < imgs.length; i++) 
            { 
                var img = imgs[i]; 
                
                if(img.width>maxWidth||img.height>maxHeight) 
                    ResizeImage(img, maxWidth, maxHeight); 
                if (img.parentElement.tagName != "A") 
                { 
                    img.onclick = function(){window.open(this.src);} 
                    img.style.cursor = "hand"; 
                } 
               
            } 
        }
		
		function isInt(str)
		{
		    if(!/^\d+$/.test(str))
			{
			   return false;
			}
			else
			{
			   return true;
			}
		}
		
		
		function checkAll()
	 {
	     var allchk=document.all.chkall.checked;
		 var length=document.all.chkselect.length;
		 if(typeof(length) !="undefined")
		 {
		 for(var i=0;i<length;i++ )
		 {
		    document.all.chkselect[i].checked=allchk;
		 }
		 }
		 else
		 {
		    document.all.chkselect.checked=allchk;
		 }
	 }