//关闭窗口onbeforeunload
function closewin1(event) { 

  var event=window.event;
 
  if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey){ 
 
   try{
   if(window.opener!=null&&window.opener.name=='right'){
   
    window.opener.refresh();
   }
   }catch(err){
   }
  } 
} 

//关闭窗口(取消按钮使用)
function closewin2() { 
   self.close(); 
   try{
   if(window.opener!=null&&window.opener.name=='right'){
    window.opener.refresh();
   }
   }catch(err){
  }
}

function getSelected(oldStr,newStr) {
    if(oldStr==newStr){
      document.write("selected");
    }
}
//设置多选框为选中
function setSelect(name){
   var selectobj=document.getElementById(name);
   for(var i = selectobj.length - 1; i >= 0; i-- ){
	   selectobj[i].selected=true;
	  
   }
 
   
 } 
//判断多选框为空
function isSelectEmpty(name){
 if(document.getElementById(name).value==''){return true;}
 return false;
}



function checkTwoDateEarlier(strStart, strEnd , message) {
    //如果有一个输入为空，则通过检验
    if (( strStart == "" ) || ( strEnd == "" )) {
      return true;
    }
    var regEp =/( |-|\/|:)/g
    var start = strStart.replace(regEp,"");
    var end =strEnd.replace(regEp,"");
    if (start < end) {
      return true;
    }
      alert(message);
      return false;
  }   
  
//判断结束时间大于开始时间
//日期格式YYYY-MM-DD HH:mm
//message:弹出提示框的信息
function validateTwoDate(strStart, strEnd , message) {
    if (( strStart == "" ) || ( strEnd == "" )) {
      return true;
    }
    var startDate=strStart.substring(0,10);
    var endDate=strEnd.substring(0,10);
    var array1 = startDate.split("-");
    var array2 = endDate.split("-");
    
    var start = new Date(array1[0],array1[1]-1,array1[2],strStart.substring(11,13),strStart.substring(14,16),0,0);
    var end = new Date(array2[0],array2[1]-1,array2[2],strEnd.substring(11,13),strEnd.substring(14,16),0,0);
    if (start < end) {
      return true;
    }
      alert(message);
      return false;
}

//判断结束时间大于等于开始时间
//日期格式YYYY-MM-DD HH:mm
//message:弹出提示框的信息
function checkTwoDate(strStart, strEnd , message) {
    if (( strStart == "" ) || ( strEnd == "" )) {
      return true;
    }
    var startDate=strStart.substring(0,10);
    var endDate=strEnd.substring(0,10);
    var array1 = startDate.split("-");
    var array2 = endDate.split("-");
    
    var start = new Date(array1[0],array1[1]-1,array1[2],strStart.substring(11,13),strStart.substring(14,16),0,0);
    var end = new Date(array2[0],array2[1]-1,array2[2],strEnd.substring(11,13),strEnd.substring(14,16),0,0);
    if (start <=end) {
      return true;
    }
      alert(message);
      return false;
}


//过滤前后空格
//form:
function trimAll(form){
     for (var i = 0; i < form.length; i++) {
    	 var ob = form.elements(i);
    	 if((ob.type == 'hidden' ||
                ob.type == 'text' ||
                ob.type == 'password') &&
                ob.disabled == false){
    	 	ob.value=trim(ob.value);
    	 }
     }
}

//过滤回车
function returnKeyDown(){
  
  if (event.keyCode==13) {
  
  return false;
  }
}  

//动态调整窗口的高度
//width:窗口的宽度
function dyniwindowsize(defaultWidth,defalutHeight){
	var width=window.document.body.scrollWidth;
	var height=window.document.body.scrollHeight+40;
	//alert(width);
	//alert(height);
	//window.resizeTo(width,height);
	if(width>defaultWidth){
	  width=defaultWidth;
	}
	if(height>defalutHeight){
	  height=defalutHeight;
	}
	//alert(width);
	//alert(height);
	window.resizeTo(defaultWidth,height);
}
  

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0 

function dyniframesize(iframename) {
  var pTar = null;
  if (document.getElementById){
    pTar = document.getElementById(iframename);
  }
  else{
    eval('pTar = ' + iframename + ';');
  }
  if (pTar && !window.opera){
    //begin resizing iframe
    pTar.style.display="block"
   
    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
      //ns6 syntax
      pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
    }
    else if (pTar.Document && pTar.Document.body.scrollHeight){
      //ie5+ syntax
      pTar.height = pTar.Document.body.scrollHeight;
    }
    
    if (pTar.contentDocument && pTar.contentDocument.body.offsetWidth){
      //ns6 syntax
      pTar.width = pTar.contentDocument.body.offsetWidth; 
    }
    else if (pTar.Document && pTar.Document.body.scrollWidth){
      //ie5+ syntax
      pTar.width = pTar.Document.body.scrollWidth;
    }
    
    
    
  }
}
  
  

