<!--
//*为JavaScript增加Trim函数*//
String.prototype.Trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//*为JavaScript增加LTrim函数*//
String.prototype.LTrim = function(){
	return this.replace(/(^\s*)/g, "");
}

//*为JavaScript增加RTrim函数*//
String.prototype.RTrim = function(){
	return this.replace(/(\s*$)/g, "");
}

//*为JavaScript增加IsByte函数*//
String.prototype.IsByte=function(){
	len=this.length;
	for(i=0;i<this.length;i++){
		if(this.charCodeAt(i)>0x7f)
			len++;
	}
	return len;
}
//*为JavaScript增加IsNumeric函数*//
String.prototype.IsNumeric=function(){
	var regexp1=/^[0-9]{1,}$/g;
	var regexp2=/^[0-9]{1,}[.][0-9]{1,}$/g;
	return (regexp1.test(this)||regexp2.test(this));
}
//*为JavaScript增加Trim函数*//
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//*为JavaScript增加LTrim函数*//
String.prototype.ltrim = function(){
	return this.replace(/(^\s*)/g, "");
}

//*为JavaScript增加RTrim函数*//
String.prototype.rtrim = function(){
	return this.replace(/(\s*$)/g, "");
}

//*为JavaScript增加IsByte函数*//
String.prototype.isByte=function(code){
	len=this.length;
	for(i=0;i<this.length;i++){
		if(this.charCodeAt(i)>0x7f){
			len++;
			if(code!=undefined && code=='UTF-8')
				len++;
		}
	}
	return len;
}
//*为JavaScript增加IsNumeric函数*//
String.prototype.isNumeric=function(){
	var regexp1=/^[0-9]{1,}$/g;
	var regexp2=/^[0-9]{1,}[.][0-9]{1,}$/g;
	return (regexp1.test(this)||regexp2.test(this));
}
String.prototype.isDate = function(){
  var r = this.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]);
}
Array.prototype.distinct = function(){
	var ret = [];
	for (var i = 0; i < this.length; i++) {
		for (var j = i+1; j < this.length;) {
			if (this[i] === this[j]) {
				ret.push(this.splice(j, 1)[0]);
			} else {
				j++;
			}
		}
	}
	return ret;
}
//*为JavaScript的Array对象增加strip函数*//
Array.prototype.strip=function(){
	if(this.length<2) return [this[0]]||[];
	var arr=[];
	for(var i=0;i<this.length;i++){
		arr.push(this.splice(i--,1));
		for(var j=0;j<this.length;j++){
			if(this[j]==arr[arr.length-1])
				this.splice(j--,1);
		}
	}
	return arr;
}
//*为JavaScript的Array对象增加inArray函数*//
Array.prototype.inArray=function(str){
  for(var i = 0; i < this.length ; i++){
  	if(str == this[i])
  		return i;
  }
  return -1;
}

var caution			= false;
/**
 * 创建Cookie
 * @Params name:String		//cookie名称
 * @Params value:String		//cookie值
 * @Params expires:String	//cookie有效时间
 * @Params path:String		//cookie有效路径
 * @Params domain:String	//cookie对应域名
 */
function setCookie(name, value, expires, path, domain, secure){
	var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	if (!caution || (name + "=" + escape(value)).length <= 4000){
		document.cookie = curCookie;
	}else{
		if (confirm("Cookie exceeds 4KB and will be cut!"))
			document.cookie = curCookie;
	}
}

/**
 * 得到指定名称的Cookie值
 * @Params name:String		//cookie名称
 * @Return :String			//cookie值
 */
function getCookie(name){
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1)
		return null;

	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length

	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

/**
 * 删除指定名称的Cookie值
 * @Params name:String		//cookie名称
 * @Params value:String		//cookie值
 * @Params expires:String	//cookie有效时间
 * @Params domain:String	//cookie对应域名
 */
function deleteCookie(name, path, domain){
	if (getCookie(name)){
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
/**
 * 日期校正
 * @Params date:Object		//日期对象
 */
function fixDate(date){
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew)
}

function zoomimg(img){
	var zoom=parseInt(img.style.zoom,10) || 100;
	zoom += event.wheelDelta / 24;
	if (zoom > 10 && zoom < 400)
		img.style.zoom = zoom + "%";

	return false;
}

//*检测手机是否正确*//
function isMobile(str){
  var regexp=/^1[35][0-9]{9}((,1[35][0-9]{9})*)$/g;
  return regexp.test(str);
}
//*检测电话号码是否正确*//
function isTel(str){
  var regexp=/^0[0-9]{2,4}-(([1-9][0-9]{6,7}(,))*)([1-9][0-9]{6,7})$/g;
  return regexp.test(str);
}
//*是否为身份证号码*//
function isCode(str){
	var regexp=/^[0-9a-z]+$/ig;
	return regexp.test(str);
}
//*是否为数字*//
function isNumeric(str){
	var regexp=/^[0-9]{0,}$/g;
	return regexp.test(str);
}
//*检测是否为字母数字下划线*//
function isUser(str){
	var regexp=/^[a-z][-a-z0-9]{0,}[a-z0-9]$/ig;
	return regexp.test(str);
}
//*检测email是否正确*//
function isMail(str){
	var regexp=/^[a-z0-9][.a-z0-9_-]{0,15}[a-z0-9]@(([a-z0-9][a-z0-9-]{0,34}[a-z0-9]\.)+)[a-z]{2,4}$/ig;
	return regexp.test(str);
}
//*打开一个弹出窗口*//
function openwin(fileName,note,width,height){
	window.open(fileName,note,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,top=200,left=200,width="+ width +",height="+height)
}

//*打开一个消息窗口*//
function openDialog(fileName,note,width,height){
	return window.showModalDialog(fileName,note,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;scroll:no;status:no;help:no;");
}

//*放大缩小字体*//
function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px';
}
function set_Fontsize(CtrlType){
	if(CtrlType=='minus')
		document.getElementById("cabfont").style.fontSize=eval(parseInt(document.getElementById("cabfont").style.fontSize)+1)+"px" 
	else
		document.getElementById("cabfont").style.fontSize=eval(parseInt(document.getElementById("cabfont").style.fontSize)-1)+"px" 
} 

function set_Fontlineheight(CtrlType){
	if(CtrlType=='minus')
		document.getElementById("cabfont").style.lineHeight=eval(parseInt(document.getElementById("cabfont").style.lineHeight)+4)+"px" 
	else
		document.getElementById("cabfont").style.lineHeight=eval(parseInt(document.getElementById("cabfont").style.lineHeight)-4)+"px" 
}
function CheckAll(theform){
	for (var i=0;i<theform.elements.length;i++){
		var e = theform.elements[i];
		e.checked = true;
	}
}
function FanAll(theform){
	for (var i=0;i<theform.elements.length;i++){
		var e = theform.elements[i];
		if (e.checked == true)
			e.checked = false;
		else 
			e.checked = true;
	}
}
function cntChecked(theform){
	var n=0;
	for (var i=0;i<theform.elements.length;i++){
		if (theform.elements[i].checked == true)
			n++;
	}
	return n;
}
function clean_html(str){
	var reg=/<[^>]*>/ig;
	return str.replace(reg,'').replace(/[\r\n]/g,'').replace(/&nbsp;/ig,'').replace(/&amp;nbsp;/ig,'');
}
//-->
