﻿//去除字符两边的空格
function trim(value) {
    return value.replace(/(^\s*)|(\s*$)/g, "");
}

function OpenWin(file,w,h,s)
 {
	   win=window.open(file,"win","width="+w+"px,height="+h+"px,left=0,top=0,status=1,help=0,scrollbars="+s+",resizable=0");
	   win.focus();
}

//CheckBox 全选
function SelectAllCheckBox() 
{
  var b=false;
  if(document.getElementById("selall").checked)
  {
      b=true;
  }
  var objs = document.getElementsByTagName("input");
  for(var i=0; i<objs.length; i++) {
    if(objs[i].type.toLowerCase() == "checkbox" )
      objs[i].checked = b;
  }
}

function fs(obj,ex) {
    if(document.images) {
        (new Image()).src="/stat.aspx?tl=" + window.location + "&target="+obj.href+"&ex=" +ex;
    }
    return true;
}


 function getLeftChars(varField)
	 {
	    var i = 0;
	    var counter = 0;
	    var cap = 2000;
	       
	    var leftchars = cap - varField.value.length;    
	    
	    return (leftchars);
	 }

	function onCharsChange(varField)
	{
	     var leftChars = getLeftChars(varField);
	     if ( leftChars >= 0)
	     {
		charsmonitor.innerText = leftChars;	
			return true;
	     } 
	     else
	     {
		charsmonitor.innerText="0";
		alert("超过了系统限定的字数！你只能输入2000个汉字！");
		//var len = Comment.value.length + leftChars; 	
		//	Comment.value = Comment.value.substring(0, len);
		//	leftChars = getLeftChars(Comment);
		//	 if ( leftChars >= 0) {
		//		charsmonitor.innerText=leftChars;
		//	}
		
		var len = varField.value.length + leftChars; 	
			varField.value = varField.value.substring(0, len);
			leftChars = getLeftChars(varField);
			 if ( leftChars >= 0) {
				charsmonitor.innerText=leftChars;
			}
		return false;
	    }
	}
