function winOpen (strURL,strName,width,height)
{
    theWindow = window.open (strURL,strName,"width="+width+" height="+height+" scrollbars=yes left="+(1024-width)/2+" top="+(768-height)/2);	
    if (theWindow.opener == null) theWindow.opener = window;
    if (window.focus) theWindow.focus();
}
//验证邮件
function verifyEmailAddress(strEmail){
  var myReg = /^[_a-zA-Z0-9_-_._-]+@([_a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,3}$/;
  return myReg.test(strEmail);
}
/*****************************************************************
****                     判断是否为日期数据  (lhm)       例子:itIsDate("2009-10-7" , "-")    *****
*****************************************************************/
function itIsDate(DateString , Dilimeter) 
{ 
  if (DateString==null) return false; 
  if (Dilimeter=='' || Dilimeter==null) 
   Dilimeter = '-'; 
  var tempy=''; 
  var tempm=''; 
  var tempd=''; 
  var tempArray; 
  if (DateString.length<8 && DateString.length>10) 
    return false;    
  tempArray = DateString.split(Dilimeter); 
  if (tempArray.length!=3) 
   return false; 
  if (tempArray[0].length==4) 
  { 
   tempy = tempArray[0]; 
   tempd = tempArray[2]; 
  } 
  else 
  { 
   tempy = tempArray[2]; 
   tempd = tempArray[1]; 
  } 
  tempm = tempArray[1]; 
  var tDateString = tempy + '/'+tempm + '/'+tempd+' 8:0:0';//加八小时是因为我们处于东八区 
  var tempDate = new Date(tDateString); 
  if (isNaN(tempDate)) 
   return false; 
 if (((tempDate.getUTCFullYear()).toString()==tempy) && (tempDate.getMonth()==parseInt(tempm)-1) && (tempDate.getDate()==parseInt(tempd))) 
  { 
   return true; 
  } 
  else 
  { 
   return false; 
  } 
} 

/*****************************************************************
****                   求字符串的字节长度     (lhm)          *****
*****************************************************************/
function byteLength(paraString) 
{
 var strValue =new String(paraString);
 var strLength = strValue.length;
 var numLength =0;
  for (globle_i =0 ; globle_i<strLength;globle_i++){
    var ASCIIValue =strValue.charCodeAt(globle_i);
    if ( ASCIIValue > 0 && ASCIIValue < 127 )  
      numLength = numLength + 1 
    else
     numLength = numLength + 2
  }
  return numLength;
}

/*****************************************************************
****                     去除空格     (lhm)                 *****
*****************************************************************/
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
	
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
		
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim = function() {return this.replace(/^\s+/,"");}
String.prototype.rtrim = function() {return this.replace(/\s+$/,"");}
/*****************************************************************
****               复选框的全选与取消     (LHM)              *****
*****************************************************************/
function CheckAll(form){
	var length = form.itemId.length;
	var tocheck = form.chkall.checked;
	if (length)
		for (var i=0; i<length; i++){ 
			if (form.itemId[i].disabled != true){
				form.itemId[i].checked = tocheck;
			} 			
		}
	else {
		if (form.itemId.disabled !=true){
			form.itemId.checked = tocheck;
		}
	}
}

function CheckBoxAll(form){
	var length = form.itemId.length;
	if (length){
		for (var i=0; i<length; i++){ 
			if (form.itemId[i].checked){
					return true;
			}
		}
	}else if(form.itemId.checked){
		return true;
	}
	return false;
}

function CheckRadio(obs){
	for(var i = 0;i<obs.length;i++)
	{
		if(obs[i].checked)
		{
			return true;
			break;
		}
	}
	return false;
}

function getRadioValue(obs){
	for(var i = 0;i<obs.length;i++)
	{
		if(obs[i].checked)
		{
			return obs[i].value;
			break;
		}
	}
	return "";
}
/*****************************************************************
****                     删除处理     (LHM)                  *****
*****************************************************************/
function del_btn (form,strMsg,actionurl){
  	var result = false;
  	var length = form.itemId.length;	
	if (form.itemId.checked) { //只有一条记录时执行此语句
		result = true;	
	}  		
	for (var i=0; i<length; i++){ 
		if (form.itemId[i].checked){
		  result = true;
		  break;
		}		 		
	}
    if (!result){
		alert ("没有选择任何项目!");
		return false;
    }else{
		if (confirm('\n'+strMsg)){
			form.action = actionurl;
			return true;
		}
	    return false;
	} 	
}

/*****************************************************************
****                    转化字符串     (LHM)                 *****
*****************************************************************/
function conversion_code(paraString)
{
	strResult = "";
	j=0;
	for (i=0;i<paraString.length;i++){ 
		Char = String1.charAt(i);
		if (Char=="'"){
		    strResult = strResult + paraString.substring(j,i)+"\\"+"\'";
		    j=i+1;
		 } 
	return strResult;
	}
}

/*****************************************************************
****                 数字输入控制处理     (LHM)              *****
*****************************************************************/
function InputIntNumberCheck(){
	//为支持IE 或 Netscape
	var theEvent=window.event || arguments.callee.caller.arguments[0]; 
	var elm ;
	var ver = navigator.appVersion;
	if (ver.indexOf("MSIE") != -1){  // IE
		if ( !((theEvent.keyCode >=48)&&(theEvent.keyCode<=57))){
			theEvent.keyCode=0;
		}
	}else{ // Netscape
		if ( !((theEvent.which >=48)&&(theEvent.which<=57))){
			theEvent.stopPropagation();
			theEvent.preventDefault();
		}
	}
	//
}

/*****************************************************************
****          有小数点数字输入控制处理     (LHM)             *****
*****************************************************************/
function InputLongNumberCheck(){
	if ( !((window.event.keyCode >=48)&&(window.event.keyCode<=57) || window.event.keyCode ==46)){
		window.event.keyCode=0;
	}

	var theEvent=window.event || arguments.callee.caller.arguments[0]; 
	var elm ;
	var ver = navigator.appVersion;
	if (ver.indexOf("MSIE") != -1){  // IE
		if (!((theEvent.keyCode>=48)&&(theEvent.keyCode<=57) || theEvent.keyCode ==46)){
			theEvent.keyCode=0;
		}
	}else{ // Netscape
		if ( !((theEvent.which >=48)&&(theEvent.which<=57) || theEvent.which ==46)){
			theEvent.stopPropagation();
			theEvent.preventDefault();
		}
	}
}

/*****************************************************************
****                        换页处理                         *****
*****************************************************************/
function toWhichPage(objform, whichPage){
    objform.whichPage.value = whichPage;
    objform.submit();
}

/*************************liuxch   *******************************
****                        获取cookie内容                   *****
*****************************************************************/
function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ){
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
			endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;	
		if ( x == 0 ) break;
	}
	return "";
}

/*****************************************************************
****                    设置cookie内容、过期时间              *****
*****************************************************************/
function setCookie( name, value, expiredays ) { 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 
/*****************************************************************
****                      检查输入字符    (lhm)              *****
'//		 islegality：输入的字符是否为给定的字符
'//返回值：bool
*****************************************************************/
function islegality(checkstrpass){
var checkokpass="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
for (i=0; i<checkstrpass.length; i++) {
       ch=checkstrpass.charAt(i);
       for (j=0;j<checkokpass.length; j++){
        if (ch==checkokpass.charAt(j))
        break;
        }
      if (j==checkokpass.length){
	  return false; //函有特别字符时返回false
      break;
        }
  }
   return true;
}
/**
* 检查输入是否中文
*/
function ck_chinese(value_) {
  return escape(value_).indexOf("%u")!=-1 
}
//判断中英文：中文true,英文false
function isChinese(str)
{
    var lst = /[u00-uFF]/;      
    return !lst.test(str);     
}
function strlen(str)
{
   var strlength=0;
   for (i=0;i<str.length;i++)
   {
     if (isChinese(str.charAt(i))==true)
        strlength=strlength + 2;
     else
        strlength=strlength + 1;
   }
   return strlength;
}
function checkTagInput(istr)
{
	if (strlen(istr.value) > 32)
	{
		istr.value = b_subString(istr.value, 32);
	}
}
function b_subString(a,b){for(var c=0,e="",d=0;d<a.length;d++){if(a.charCodeAt(d)>128)c+=2;else c++;if(c>b)return e;e+=a.charAt(d)}return e}
/**
   判断日期格式 2000-01-01
   strDate：检测的日期格式
   return： true/false
**/
 function   isDate(strDate){  
	var   strSeparator = "-";   //日期分隔符  
	var   strDateArray;  
	var   intYear;  
	var   intMonth;  
	var   intDay;  
	var   boolLeapYear;  
	//var strDate=form1.a.value   //表单中的日期值
	strDateArray = strDate.split(strSeparator);  
	if(strDateArray.length!=3){
		alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); 
		return false;
	}	 
	intYear = parseInt(strDateArray[0],10);  
	intMonth = parseInt(strDateArray[1],10);  
	intDay = parseInt(strDateArray[2],10); 
	if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)){
		alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); 
		return false;
	}	 
	if(intMonth>12||intMonth<1) {
		alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); 
		return false;
	}  
	if((intMonth==1||intMonth==3||intMonth==5||intMonth==7||intMonth==8||intMonth==10||intMonth==12)&&(intDay>31||intDay<1)){
		alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); 
		return false;
	} 
	 
	if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30||intDay<1)){
		alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); 
		return false;
	}
	 
	if(intMonth==2){  
		  if(intDay<1){
			  alert('提示: 日期格式错误! \r\n 请依【YYYY-MM-DD】格式输入！'); 
			  return false;
		  }
		  boolLeapYear = false;  
		if((intYear%4==0 && intYear %100!=0)||(intYear %400==0)){
		  boolLeapYear=true;
		}
		   
		if(boolLeapYear){  
			if(intDay>29){
				alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); return   false;
			}
		}else{  
		   	if(intDay>28){
				alert('提示: 日期格式错误! \r\n  请依【YYYY-MM-DD】格式输入！'); 
				return false;
			}
		}
	}
	return true;  
}
//1 短时间，形如 (13:04:06)
function isTime(str)
{
var a = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/);
if (a == null) {alert('输入的参数不是时间格式'); return false;}
if (a[1]>24 || a[3]>60 || a[4]>60)
{
alert("时间格式不对");
return false
}
return true;
}

//2. 短日期，形如 (2008-07-22)
function strShortDateTime(str)
{
var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
if(r==null)return false; 
var d= new Date(r[1], r[3]-1, r[4]); 
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}

//3 长时间，形如 (2008-07-22 13:04:06)
function strLongDateTime(str)
{
var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
var r = str.match(reg); 
if(r==null)return false; 
var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}


function DrawImage_bak(ImgD,width,height){ 
	var flag=false; 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width/image.height>= width/height){ 
			if(image.width>width){ 
				ImgD.width=width; 
				ImgD.height=(image.height*width)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"×"+image.height; 
		} 
		else{ 
			if(image.height>height){ 
			ImgD.height=height; 
			ImgD.width=(image.width*height)/image.height; 
			}else{ 
			ImgD.width=image.width; 
			ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"×"+image.height; 
		} 
	} 
}

function DrawImage(ImgD,width){ 
	var flag=false; 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0){ 
		flag=true; 
		if(image.width>= width){ 
			if(image.width>width){ 
				ImgD.width=width; 
				ImgD.height=(image.height*width)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"×"+image.height; 
		} 
		//else{ 
//			if(image.height>height){ 
//			ImgD.height=height; 
//			ImgD.width=(image.width*height)/image.height; 
//			}else{ 
//			ImgD.width=image.width; 
//			ImgD.height=image.height; 
//			} 
//			ImgD.alt=image.width+"×"+image.height; 
//		} 
	}
}

function stripscript(s) {
	return s.replace(/<script.*?>.*?<\/script>/ig, '');
}

function setSelectState(state){
    var objl=document.getElementsByTagName('select');
    for(var i=0;i<objl.length;i++){
            objl[i].style.visibility=state;
    }
}

//var $=function(id){
//   return "string"==typeof(id)?document.getElementById(id):id;
//}
function strip(){return this.replace(/^\s+/,'').replace(/\s+$/,'');}
function stripTags(){return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,'');}
function stripScripts(){return this.replace(new RegExp(Prototype.ScriptFragment,'img'),'');}

