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();
}

/*****************************************************************
****                     判断是否为日期数据  (lhm)           *****
*****************************************************************/
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)                   *****
'//		  strMsg：输入的题示语言
'//返回值：1，2（1：确定   2：取消）
*****************************************************************/
function msg(strMsg)
{
	if (confirm('\n'+strMsg))
	  return 1;
	else
	  return 2;
}

/*****************************************************************
****                      检查输入字符    (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;
}

/*****************************************************************
****                     去除空格     (lhm)                 *****
*****************************************************************/
function trim(inputStr) {
	var result = inputStr;
	while (result.substring(0,1) == " ") {
		result = result.substring(1,result.length)
	}
	
	while (result.substring(result.length-1, result.length) == " ") {
		result = result.substring(0, result.length-1)
	}
		
	return result;
}

/*****************************************************************
****               复选框的全选与取消     (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;
		}
	}
}




/*****************************************************************
****                     删除处理     (LHM)                  *****
*****************************************************************/

function del_btn (form,strMsg)
{
  	
  	var string = "00";
  	var length = form.itemId.length;
	if (form.itemId.checked) { //只有一条记录时执行此语句

		string = "1";
		
	}  		
	for (var i=0; i<length; i++)
	{ 
		if (form.itemId[i].checked){
		  string="1";

		}
		 		
	}
  if (string == "00")
  {
    alert ("没有选择任何项目!");
    return false;
  }
  else
  {
	if (msg(strMsg)==2)
	{
		form.actionType.value='_blank'
		return false;
	}
	else {	
	return true;}
  }
 
}



/*****************************************************************
****                   表单提交处理    (LHM)                 *****
*****************************************************************/
//////////////////////////////////////////////////////////////////
//过程名：formSubmit(objForm,strUrl,strActionType)
//描  述：
//参  数：
//作  者：黎活明
//////////////////////////////////////////////////////////////////
function formSubmit(objForm,strUrl,strActionType)
{
	objForm.action = strUrl;
	objForm.actionType.value=strActionType;
	//alert (objForm.actionType.value);
	objForm.submit();
}


/*****************************************************************
****                   项目提交处理    (LHM)                 *****
*****************************************************************/

function itemSubmit(objForm,strUrl,actionType,intItemId)
{
	objForm.actionType.value=actionType;
	objForm.action = strUrl;
	objForm.ModId.value=intItemId;
	objForm.submit();
}


/*****************************************************************
****                    转化字符串     (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()
{
	if ( !((window.event.keyCode >=48)&&(window.event.keyCode<=57)))
	{
		window.event.keyCode=0;
	}
}

/*****************************************************************
****          有小数点数字输入控制处理     (LHM)             *****
*****************************************************************/
function InputLongNumberCheck()
{
	if ( !((window.event.keyCode >=48)&&(window.event.keyCode<=57) || window.event.keyCode ==46))
	{
		window.event.keyCode=0;
	}
}
/*****************************************************************
****          检查有小数点的数字是否正确     (LHM)           *****
*****************************************************************/
function CheckLongIsError(str){
 if (str.split(".").length >2 )
    return true;
 else
    return false;
}
/*****************************************************************
****                  项目打开处理     (LHM)                 *****
*****************************************************************/

function open_resizeble_dialog(rul,name,width,height){
	var left = (screen.width-width)/2;
	var top = (screen.height-height)/2;
	window.open(rul,name,"titlebar=no,menubar=no,status=no,directories=no,scrollbars=no,resizable=yes,left="+left+",top="+top+",width="+width+",height="+height);
}



/*****************************************************************
****                  数据校验处理     (LHM)                 *****
*****************************************************************/
function verifyData(objField,strName,strFormat,maxLength,minLength){
	returnValue = true;
	if (minLength != 0) {
		if (trim(objField.value) == ""){
			alert (strName + " 为必添项，请输入！");
			objField.focus();
			return returnValue = false;
		}
	}
	
	if (minLength > 1) {
		if (byteLength(objField.value)< minLength){
			alert (strName + " 的长度在" + minLength +"和" + maxLength + "位之间，请确认！");
			objField.focus();
			return returnValue = false;
		}
	}
	
	if (byteLength(objField.value)>maxLength){
		msgs = " 最多为" + maxLength + " 个字符，请修改！"
		msgs += "\n\n   注意：1个汉字相当于2个字符"
		alert ("\n" + strName + " " + msgs);
		objField.focus();
		return returnValue=false;
	}
	if (objField.value!="" && strFormat=="number"){
		if (isNaN(objField.value)==true){
			alert (strName + " 为有效数字，请确认！");
			objField.focus();
			return returnValue=false;
		}
	}
	if (objField.value!="" && strFormat=="mail"){
		if (objField.value.indexOf("@")==-1 || objField.value.indexOf(".")==-1){
			alert (strName + "中邮件地址不合法，请确认！");
			objField.focus();
			return returnValue=false;
		}
	}
	if (objField.value!="" && strFormat=="char"){
	
		if (objField.value.length != byteLength(objField.value)){
			alert (strName + "中有非法字符，请确认！");
			objField.select();
			objField.focus();
			return returnValue=false;
		}
	
	}
	if (objField.value!="" && strFormat=="chinese"){
	
		if (objField.value.length*2 != byteLength(objField.value)){
			alert (strName + "中有非中文法字符，请确认！");
			objField.select();
			objField.focus();
			return returnValue=false;
		}
	}
	if (objField.value!="" && strFormat=="dateYear"){
	
		if (isNaN(objField.value)==true || objField.value < 1900){
			alert (strName + "中的年份值有误，请确认！");
			objField.select();
			objField.focus();
			return returnValue=false;
		}
	}
	if (objField.value!="" && strFormat=="phone"){
	
		if (objField.value.indexOf("-")==-1){
			alert (strName + "您输入的电话号码有误，请确认！");
			objField.select();
			objField.focus();
			return returnValue=false;
		}
	}
	
	if (objField.value!="" && strFormat=="date"){
	
		if (itIsDate(objField.value)==false){
			alert (strName + " 的日期格式有误，请确认！\n\n  建议格式：yyyy-mm-dd");
			objField.select();
			objField.focus();
			return returnValue=false;
		}
	}
	
	if (strFormat=="select"){
	
		if (objField.value == ""){
			alert (strName + " 项为必填项，请选择！");
			objField.focus();
			return returnValue=false;
		}
	}	
	return returnValue;
}


/*****************************************************************
****                  转化成html                             *****
*****************************************************************/
function copyWord(objFile){
  finish = IClipProc.Transform(); 
  if (finish==0){
    htmlPath = IClipProc.HtmlPath 
    zipPath=IClipProc.ZipPath;
  	strResult = "";
	j=0;
	for (i=0;i<zipPath.length;i++){ 
		Char = zipPath.charAt(i);
		if (Char=="~"){
		    strResult = strResult + "\{"+"\~}";
		    j=i+1;
		} 
		else{
		strResult = strResult + Char
		}
	}
	//alert (strResult);
    document.all("iFrame1").src=htmlPath;
    var WshShell=new ActiveXObject("WScript.Shell");
    objFile.select();
    WshShell.sendKeys(""+strResult+"") ;
  }
}


/*****************************************************************
****                    转化字符串     (LHM)                 *****
*****************************************************************/

function single_code(paraString)
{
	//alert (paraString)
	strResult = "";
	j=0;
	for (i=0;i<paraString.length;i++){ 
		Char = paraString.charAt(i);
		if (Char=="'"){
		    strResult = strResult + "\'" + "\'";
		} 
		else
		{
		   strResult = strResult + Char;
		}	
	}
	return strResult;
}

/*****************************************************************
****                    转化字符串     (LHM)                 *****
*****************************************************************/
function win_location(objField){
window.location=objField.value+".htm"
}

/*****************************************************************
****                     获得页面的焦点                   *****
*****************************************************************/
function getfocus(path)
	{	
		remote= window.open(path,"RemoteRateWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,Height=240,top=200,left=350");
        if (remote.opener == null) remote.opener = window;
		if (window.focus) 
		{
			remote.focus();
		}
		return false;
	}

/*****************************************************************
****                    打开页面时获取焦点                   *****
*****************************************************************/
function onLoad(fieldName){
    fieldName.focus(); 
}

/*****************************************************************
****                        换页处理                         *****
*****************************************************************/
function toWhichPage(whichPage){
    document.form1.whichPage.value = whichPage;
    document.form1.submit();
}