Array.prototype.indexOf=function(substr,start){var ta,rt,d='\0';if(start!=null){ta=this.slice(start);rt=start;}else{ta=this;rt=0;}var str=d+ta.join(d)+d,t=str.indexOf(d+substr+d);if(t==-1)return -1;rt+=str.slice(0,t).replace(/[^\0]/g,'').length;return rt;}
String.prototype.isDate=function(){ var regexp = /^((((((0[48])|([13579][26])|([2468][048]))00)|([0-9][0-9]((0[48])|([13579][26])|([2468][048]))))-02-29)|(((000[1-9])|(00[1-9][0-9])|(0[1-9][0-9][0-9])|([1-9][0-9][0-9][0-9]))-((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30))|(((0[1-9])|(1[0-2]))-((0[1-9])|(1[0-9])|(2[0-8]))))))$/i;return regexp.test(this); } 
function delArr(arr,val){for(var i=0; i<arr.length;i++){if(arr[i]==val){for(var j=i;j<arr.length;j++){arr[j]=arr[j+1];}arr.pop();}}}
function copyBoard(){window.clipboardData.setData("Text",location.href);}
function userLogout(ele , uid , url , utype){utype = typeof utype=="undefined"?"users":utype;$(ele).click(function(){$.get(url,{'uid':uid,'utype':utype,'m':Math.random(123)},function(da){if(da.substr(0,2) == "ok")location.href = "/";});});return false;}
function lookTypeSelect( ele , url){$(ele).change(function(){$('option:selected', this).each(function(){if(this.value != '')location.href = url+this.value;else location.href = url;});});}
function showForm(ele , act , formId , hiDiv ,resetId , exefun){$(ele).click(function(){var o = this;$(formId)[0].reset();if(act != "")$(formId)[0].action = act;if( typeof exefun == 'function' )exefun(o);displayAlreadyDiv(hiDiv);});$(resetId).click(function(){hiddenAlreadyDiv(hiDiv);});}
var topp = 4;var toppp = 7;
function displayAlreadyDiv(ele,PARENT){if($(ele).css("display") == "block")return false;if(typeof PARENT == "undefined"){var l=($(window).width()-$(ele).width())/2;if(self != parent)var num = toppp;else var num = topp;$(ele).css({top: (getPageScroll()[1] + (getPageHeight() / num)+"px") ,left:(l+"px")}).fadeIn(400);}else{var l=($(window,window.parent.window).width() - $(ele,window.parent.document).width()) / 2 ;var num = 2;$(ele,window.parent.document).css({top: (getPageScroll()[1] + (getPageHeight() / num)+"px") ,left:(l+"px")}).fadeIn(1000);}}
function hiddenAlreadyDiv(ele){$(ele).fadeOut(400).find("form").each(function(){$(this)[0].reset();});}
function mulDel(chkBoxName,url,notDel,callback){var idstr = getChkBoxVal(chkBoxName);if(idstr == ""){alert("请先选择要删除的记录");return false;}else{notDel = typeof notDel == "undefined" ? "您确定要删除吗?" : notDel ;if(!confirm(notDel))return false;$.get(url,{'ids':idstr,'m':Math.random(1234)},function(da){if(typeof callback != "undefined")callback(da);else if(da.substr(0,2).indexOf("ok") > -1)location.reload();else alert(da);});}}
function mulChioseOpera(chkBoxName,url,noWarn,callback){var idstr = getChkBoxVal(chkBoxName);if(idstr == ""){alert("请先选择要执行操作的记录");return false;}else{noWarn = (typeof noWarn == "undefined" || noWarn == false ) ? "您确定要册删除吗?" : noWarn ;if(noWarn != true){if(!confirm(noWarn))return false;}insertWaitImg();$.get(url , {'ids':idstr , 'm':Math.random(1234)},function(da){removeWaitImg();if(typeof callback != "undefined")callback(da);else if(da.substr(0,4)=="warn")alert(oneWarning[da]);else if(da.substr(0,2).indexOf("ok") > -1)location.reload();else alert(da);});}}
function del(ele,url,force,callback){$(ele).click(function(){if (confirm("您确定要删除这条记录吗?")){if (this.id){ids = this.id.split("_");
				if (ids[1]=="")
					ids[1]="''";
				$.get(url,{"id":ids[0],"para":ids[1],'force':0,'m':Math.random(1234)}, function(da){var re = da.split("|||")
					if(typeof callback != "undefined")callback(da);
					else if(re[0].substr(0,3).indexOf("ok") > -1 && (re[1] == "undefined" || re[1].length < 4))location.reload();
					else if (re[0].substr(0,3).indexOf("ok") > -1 && (re[1] != "undefined" || re[1].length > 4)){	alert("执行成功但过程中出现了一般性的错误: \n" + re[1]);location.reload();}
					else{alert(da);
						if(confirm("你要尝试强制删除吗?")){
							$.get(url,{"id":ids[0],"para":ids[1],'force':1,'m':Math.random(1234)}, function(da){
								var re = da.split("|||")
								if(re[0].substr(0,3).indexOf("ok") > -1 && (re[1] == "undefined" || re[1].length < 4))
									location.reload();
								else if (re[0].substr(0,3).indexOf("ok") > -1 && (re[1] != "undefined" || re[1].length > 4)){	alert("执行成功但过程中出现了一般性的错误: \n" + re[1]);
									location.reload();}else
									alert(da);});}}});}}return false;});
}
function subForm(formId , reset , au , callback , subId){$(formId).ajaxForm ({resetForm: reset,success:function (data){$("#uploadingFORM").remove();if(callback != "undefined")callback(data);},beforeSubmit:function (){if( au == false)return true;var btni = $("#submitBtnNotice");if(typeof subId == "undefined"){t = new Object();t.top = "45%";}else{var t = getPos($(subId)[0]);t.t = (t.t - 60 + "px");}if(au.check){topp = 2.5;insertWaitImg();if(btni.length > 0)btni.html("");return true;}else{if(btni.length > 0)btni.html("<font color='red'>　　带＊号的是必填或必选项，请注意红色提示部份。</font>");return false;}}});$(formId).bind('form-pre-serialize', function() {if (typeof tinyMCE != "undefined")tinyMCE.triggerSave(); });}
function insertWaitImg(){
	$("body").append("<div id='uploadingFORM' style='position:absolute;z-index:100;background-color:#FFFFFF; background-image:url(/imgs/loading2.gif);background-repeat:no-repeat;background-position:15% 40%; top:"+(getPageScroll()[1] + (getPageHeight() / topp))+"px;left:40%;width:150px;height:50px;border:1px solid #CCCCCC;'> \
	<div style='margin-left:60px;margin-top:10px;color:#000000;'>Waiting...</div></div>");
}
function removeWaitImg(){$("#uploadingFORM").remove();}
function submitPost(url , para , callback){
	insertWaitImg();
	$.post(url , para ,function(da){
		$("#uploadingFORM").remove();
		if(da.substr(0,2) == 'ok'){
			if(typeof callback != "undefined")callback(da);
			else{location.reload();}
		}else
			alert(da);
	});
}
function edit(obj){
	for(i in obj){eval("this." + i + "=obj[i]");}
	this.initFunc = false;
	this.da = false;
	this.open = function(){
		var o = this;
		$(o.ele).click(function()	{
			if(o.initFunc != false ){o.initFunc( o.ele );}
			if (this.id){
				ids=this.id.split("_");
				$.get(o.get,{'id':ids[0],'m':Math.random(1234)},function(da){//alert(da)
					try{o.da = eval("("+da+")");
						displayAlreadyDiv(o.hiDIV);
						$(o.Form)[0].action = o.action;
						if(!$("#idname").length){
							alert("您将如何添加更新所需的ID");
							return false;
						}$(o.Form)[0].reset();
						if(typeof o.tinyMceBox != 'undefined'){
							tinyMCE.getInstanceById(o.tinyMceBox).getBody().innerHTML = "";
						}$("#idname").attr("name",o.idName).attr("value",eval("o.da[0]." + o.idName));o.insert();
					}catch(e){alert(e.message +" | "+da);}
				});
			}
		});
	}
	this.insert = function(){
		for(i in this.da[0]){
			if($("#"+i).length > 0){
				if(eval("this.da[0]."+i)==null){
					continue;}
				if(typeof $("#"+i).attr("type") == "undefined")
					continue;
				if($("#"+i).attr("type").toLowerCase()=="file")
					continue;
				if($("#"+i).attr("class")=="descClass" && $("#"+i).attr("type")=="textarea"){$("#"+i).val(eval("this.da[0]."+i));}
				else if($("#"+i).attr("type")=="textarea" && $("#"+i).attr("class")!="descClass"){
					$("#"+i).val("");
					if (typeof tinyMCE != "undefined")
						tinyMCE.execInstanceCommand(i,'mceInsertContent', false, eval("this.da[0]."+i).replace(/\"/g,"'"));
					else
					{ $("#"+i).val(eval("this.da[0]."+i));}
				}else if($('select[@name="'+i+'"]').attr("id") == i){
					if(typeof this.callback != "undefined")
						this.callback(i , eval("this.da[0]."+i));
					else
						$("#"+i).attr("value" , eval("this.da[0]."+i));	
				}else
				{$("#"+i).val(eval("this.da[0]."+i));}
			}
			else{$("input[@type=radio][@name="+i+"][@value="+(eval("this.da[0]."+i))+"]").attr("checked",'true'); 
				if( eval("this.da[0]."+i) != null && eval("this.da[0]."+i) != 'null' ){CheckAll(i , true , eval("this.da[0]."+i) );}
			}
		}
	}
}
function resetformstate(submitId , resetId , formId , url , subVal , resVal){$(resetId).click(function(){$(formId)[0].action = url;if( typeof subVal != "undefined")$(submitId).val( subVal );if( typeof resVal != "undefined")$(resetId).val( resVal );});}
function authForm(form){
	this.f = form;
	this.check = true;
	this.notEmpty = [];
	this.mustSelect = [];
	this.mustInt = [];
	this.RadioEmpty = [];
	this.invEmail = [];
	this.invUrl = [];
	this.invFullUrl = [];
	this.eqV = [];
	this.mostV = [];
	this.strLen = [];
	this.errEle = [];
	this.invPhoneAndTel = [];
	this.invPhone = [];
	this.authPhone = false;
	this.invTel = [];
	this.invFax = [];
	this.invDate = [];
	this.invPostCode = [];
	this.forbidStr = [];
	this.isEmailOrInt = [];
	this.floatOrInt = [];
	this.color = "#000000";
	this.warning = {};
	this.debug = true;
	this.engOrInt = [];
	this.debugFunc = 0;
	this.forceBind = [];
	this.mustSelectBind = false;
	this.funs = {};
	this.errString = "";
	this.onSubmit = false;
	this.alertErr = function(){
		if(this.debug && this.errString != ""){alert(this.errString);}
		this.errString = "";
	}
	this.submitBeforeFunc = function (){
		var o = this;
		o.check = true;
		o.errEle = [];
		for(func in o.funs){
			try{ 
				o.funs[func]();
			}catch(e){
				alert(e.message);
				o.check = false;
				return false;
			}
		}
		if (o.notEmpty.length > 0){
			for(var i = 0; i < o.notEmpty.length ; i++){
				var ids = o.notEmpty[i].split("~~");
				o.delErr(ids[0]);
				if (typeof ids[0] == "object")o.chkFile(ids[0]);
				else{if(ids.length > 1)
						o.chkEmpty(ids[1] , ids[0]);
					else
						o.chkEmpty("" , ids[0]);
				}
			}this.alertErr();
		}
		if(o.mustSelect.length > 0){
			for(var i = 0; i < o.mustSelect.length ; i++){
				o.delErr(o.mustSelect[i]);
				o.chkSelect(o.mustSelect[i]);
			}
		}
		if(o.mustInt.length > 0){for(var i=0;i<o.mustInt.length; i++){o.delErr(o.mustInt[i]);o.chkInt(o.mustInt[i]);}}
		if(o.eqV.length>0){for(var i=0;i< o.eqV.length;i++){o.delErr(o.eqV[i][1]);o.chkEqValue(o.eqV[i][0] , o.eqV[i][1]);}}
		if(o.mostV.length > 0){
			for(var i = 0; i < o.mostV.length ; i++){
				o.delErr(o.mostV[i][0]);
				o.chkMostValue(o.mostV[i][0] , o.mostV[i][1]);
			} 
		}
		if(o.strLen.length > 0){
			for(var i = 0; i < o.strLen.length ; i++){
				o.delErr(o.strLen[i][0]);
				o.chkStrLength(o.strLen[i][0] , o.strLen[i][1] , (typeof o.strLen[i][2]=="undefined" ?"":o.strLen[i][2]));
			} 
		}
		if(o.RadioEmpty.length > 0){
			for(var i = 0; i < o.RadioEmpty.length ; i++){
				o.chkRadio(o.RadioEmpty[i][0],o.RadioEmpty[i][1]);
			}
		}
		if (o.invEmail.length > 0){
			for(var i = 0; i < o.invEmail.length ; i++){
				o.delErr(o.invEmail[i]);
				o.chkEmail(o.invEmail[i]);
			}
		}
		if(o.invPhoneAndTel.length > 0){
			for(var i = 0; i < o.invPhoneAndTel.length ; i++){
				o.delErr(o.invPhoneAndTel[i]);
				o.chkPhoneAndTel(o.invPhoneAndTel[i]);
			}
		}
		if(o.invFax.length > 0){
			for(var i = 0; i < o.invFax.length ; i++){
				o.delErr(o.invFax[i]);
				o.chkFax(o.invFax[i]);
			}
		}
		if(o.invPhone.length > 0){
			for(var i = 0; i < o.invPhone.length ; i++){
				o.delErr(o.invPhone[i]);
				o.chkPhone(o.invPhone[i]);
			}
		}
		if(o.invTel.length > 0){
			for(var i = 0; i < o.invTel.length ; i++){
				o.delErr(o.invTel[i]);
				o.chkTel(o.invTel[i]);
			}
		}
		if(o.invDate.length > 0){
			for(var i = 0; i < o.invDate.length ; i++){
				o.delErr(o.invDate[i]);
				o.chkDate(o.invDate[i]);
			}
		}
		if(o.invPostCode.length > 0){
			for(var i = 0; i < o.invPostCode.length ; i++){
				o.delErr(o.invPostCode[i]);
				o.chkPostCode(o.invPostCode[i]);
			}
		}
		if(o.forbidStr.length > 0){
			for(var i = 0; i < o.forbidStr.length ; i++){
				o.delErr(o.forbidStr[i]);
				o.chkForbidStr(o.forbidStr[i]);
			}
		}
		if(o.invUrl.length > 0){
			for(var i = 0; i < o.invUrl.length ; i++){
				o.delErr(o.invUrl[i]);
				o.chkUrl(o.invUrl[i]);
			}
		}
		if(o.invFullUrl.length > 0){
			for(var i = 0; i < o.invFullUrl.length ; i++){
				o.delErr(o.invFullUrl[i]);
				o.chkFullUrl(o.invFullUrl[i]);
			}
		}
		if(o.engOrInt.length > 0){
			for(var i = 0; i < o.engOrInt.length ; i++){
				o.delErr(o.engOrInt[i]);
				o.chkEngOrInt(o.engOrInt[i]);
			}
		}
		if(o.isEmailOrInt.length > 0){
			for(var i = 0; i < o.isEmailOrInt.length ; i++){
				o.delErr(o.isEmailOrInt[i]);
				o.chkEmailOrInt(o.isEmailOrInt[i]);
			}
		}
		if(o.floatOrInt.length > 0){
			for(var i = 0; i < o.floatOrInt.length ; i++){
				o.delErr(o.floatOrInt[i]);
				o.chkFloatInt(o.floatOrInt[i]);
			}
		}
		return o.check;
	}
	this.execBind = function(){
		var o = this;
		if(o.mustSelect.length > 0){
			for(var i = 0; i < o.mustSelect.length ; i++){$("#"+o.mustSelect[i]).bind("change",function(){o.onSubmit=false;o.submitBeforeFunc();});}
		}
		o.forceBind = o.forceBind.concat(o.notEmpty);
		if(o.forceBind.length > 0){
			for(var i = 0; i < o.forceBind.length ; i++){
				if (typeof o.forceBind[i] == "object"){}
				else{var ids = o.forceBind[i].split("~~");o.delErr(ids[0]);
					$("#"+ids[0]).bind("blur",function(){o.onSubmit = false;o.submitBeforeFunc();});}
			}
		}
	}
	this.submit = function(){
		var o = this;
		$(o.f).submit( function(){o.onSubmit = true;o.submitBeforeFunc() ;}); 
	}
	this.chkEmpty = function(clew,id){
		var o = this;
		var v = $("#"+id).val(); 

		if (typeof tinyMCE != "undefined" && v ==""){	
			if(tinyMCE.get(id) == "object"){
				v = tinyMCE.get(id).getContent();
			}
		}
		if (o.isEmpty(v))
			o.check = o.check == true ? true : false;
		else{
			if(o.onSubmit == false)
				return ;
			o.warning.empty = clew + "必须填写";
			if($("#"+id).attr('type').toLowerCase() != "file"){	
				o.setErr(id ,o.warning.empty)
			}
			else
				o.setErr(id ,"必须选择一个文件或图片");
			o.errEle.push(id);o.check = false;
		}
		o.setEmpty(id);
	}
	this.chkSelect = function(id){
		var o = this;
		var v = selectVal(id);
		if (v != "" && v != null)
			o.check = o.check == true ? true : false;
		else{
			if(o.onSubmit == false)return ;
			o.warning.select = "下拉菜单必须选择";o.setErr(id ,o.warning.select);o.errEle.push(id);o.check = false;
		}
		o.setEmpty(id);
	}
	this.setErr = function(id,errStr){
		var o = this;
		if(this.debugFunc == 0){
			if(typeof $("#"+id+"_err")[0] != "undefined" && o.errEle.indexOf(id)== -1){
				$("#"+id+"_err").text(" * "+errStr).css("color",o.color);
			}
			else{if(o.debug)alert(errStr);}
		}else{this.debugFunc("setErr",id ,errStr );}
	}
	this.delErr = function(id){
		var o = this;
		if(this.debugFunc == 0){
			if(typeof $("#"+id+"_err")[0] != "undefined" && o.errEle.indexOf(id)== -1)
				$("#"+id+"_err").text(" * ").css("color","#000000");
		}else{
			if(o.errEle.indexOf(id)== -1)
				this.debugFunc("delErr" , id , false );
		}
	}
	this.isEmpty = function(v){
		if( v == "" || v == "必须填写" || v.replace(/[ ]/g,"") == "")return false;
		else return true;
	}
	this.chkInt = function(id){
		var o = this;
		var v = $("#"+id).val();
		if (o.isInt(v))
			o.check = o.check == true ? true : false;
		else{o.warning.isint = "必须是数字整数";o.setErr(id ,o.warning.isint);o.errEle.push(id);o.check = false;}
		o.setEmpty(id);
	}
	this.chkFloatInt = function(id){
		var o = this;
		var v = $("#"+id).val();
		if (o.isfloatOrInt(v))
			o.check = o.check == true ? true : false;
		else{o.warning.isfloatorint = "必须是整数或小数"+v;o.setErr(id ,o.warning.isfloatorint);o.errEle.push(id);o.check = false;}
	}
	this.chkRadio = function(name , arti){//alert(name)
		var o = this;
		if (o.isRadioEmpty(name))
			o.check = o.check == true ? true : false;
		else{alert("必须选择"+arti+"单选按钮");o.check = false;}
	}
	this.isRadioEmpty=function(name){
		var re = $("input[@type=radio][@name="+name+"][@checked]").val();
		if (typeof re=="undefined")return false;
		else
			return true;
	}
	this.isInt = function(v){
		var reg = /^\d+$/;
		if(!reg.test(v) && v != "")return false;
		else
			return true;
	}
	this.isfloatOrInt = function(v){
		var reg = /^\d+(\.\d+)?$/;
		if(!reg.test(v) && v != "")return false;
		else
			return true;
	}
	this.chkFile = function(JQ){
		var chk = false ;
		var o = this;
		JQ.each(function(i){
			if($(this).val() != "")chk = true;
		});
		o.check = o.check == false ? false : chk;
	}
	this.mostValue = function(v1 , V2){if(parseInt(v1) > parseInt(V2))return false;else return true;}
	this.chkMostValue = function(id,setV){
		var o = this;
		var v = $("#"+id).val();
		if(o.mostValue(v,setV))
			o.check = o.check == true ? true : false;
		else{	o.warning.most = "最大值不得超过"+setV+".";o.setErr(id ,o.warning.most);o.errEle.push(id);o.check = false;}o.setEmpty(id);
	}
	this.eqValue = function(v1 , V2){try{if(v1 != V2 && V2 != "")return false;else return true;}catch(e){alert(e.message)}}
	this.chkEqValue = function(id1,id2){
		var o = this;var v1 = $("#"+id1).val();var v2 = $("#"+id2).val();
		if(o.eqValue(v1,v2))
			o.check = o.check == true ? true : false;
		else{
			o.warning.eqv = "两次输入的值不一致.";
			if($("#"+id2).attr('type').toLowerCase() == "password")
				o.setErr(id2 ,"两次输入的密码不一致");
			else
				o.setErr(id2 ,o.warning.eqv);
			o.errEle.push(id2);
			o.check = false;
		}
		o.setEmpty(id2);
	}
	this.chkEmail = function(id){
		var o = this;
		var v = $("#"+id).val();
		if ( v != ""){
			if (o.isEmail(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isemail = "无效的email地址";
				o.setErr(id , o.warning.isemail);
				o.errEle.push(id);
				o.check=false;
			}
			o.setEmpty(id);
		}
	}
	this.isEmail = function(v){
		var regstr=/^[a-zA-Z0-9_-]+\.?[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		return v.match(regstr);
	}
	this.chkEngOrInt = function(id){
		var o = this;
		var v = $("#"+id).val();
		if ( v != ""){
			if (o.isEngOrInt(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isEngorInt = "只能是数字英文和下划线";
				o.setErr(id , o.warning.isEngorInt);
				o.errEle.push(id);
				o.check = false;
			}
			o.setEmpty(id);
		}
	}
	this.isEngOrInt = function(v){
		var regstr=/^[a-zA-Z0-9_]+$/;
		return v.match(regstr);
	}
	this.chkStrLength = function(id , minL , maxL){
		var o = this;
		var v = $("#"+id).val();
		if ( v != ""){
			if (o.strLength(v , minL , maxL))
				o.check = o.check == true ? true : false;
			else{
				if(v.length < minL)
					o.warning.strlength = "您输入的字符长度"+v.length+"不符合最少字符长度限制"+minL;
				else if(v.length > maxL)
					o.warning.strlength = "您输入的字符长度"+v.length+"超出了最大字符长度限制"+maxL;
				o.setErr(id , o.warning.strlength);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.strLength = function(v,MINL,MAXL){
		var regstr = eval("/^.{" + MINL + "," + MAXL + "}$/");
		return v.replace(/[ ]|\s/g,"").match(regstr);
	}
	this.chkUrl = function(id){
		var o = this;var v = $("#"+id).val();
		if ( v != ""){
			if (o.isUrl(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isurl = "格式: www.sina.com";
				o.setErr(id , o.warning.isurl);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.chkFullUrl = function(id){
		var o = this;var v = $("#"+id).val();
		if ( v != ""){
			if (o.isUrl(v,true))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isfurl = "格式: http://www.sina.com";
				o.setErr(id , o.warning.isfurl);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.isUrl = function(v,f){
		if(typeof f != 'undefined')
			var regstr = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^\"\"])*$/;
		else
			var regstr = /^[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^\"\"])*$/;
		return v.match(regstr);
	}
	this.chkPhoneAndTel = function(id){
		var o = this;
		var v = $("#"+id).val();
		if(v != ""){
			if (o.isPhoneAndTel(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isPhoneandtel = "电话号码格式错误";
				o.setErr(id , o.warning.isPhoneandtel);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.isPhoneAndTel = function(str){
		if(str.indexOf("-")>-1){
            var regstr=/^\d{3,4}\-\d{7,8}$/;
	        return regstr.test(str);
	    }
		else{
			var regstr2 = /^\d{11}$/;
		    var regstr3 = /^\d{7,8}$/;
			if(regstr2.test(str) || regstr3.test(str))return true;
			else
				return false;
		}
	}
	this.chkFax = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			if (o.isFax(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isfax = "传真号码格式错误";
				o.setErr(id , o.warning.isfax);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.isFax = function(str){
		if(str.indexOf("-")>-1){var regstr=/^\d{3,4}\-\d{7,8}$/;return regstr.test(str);}
		else{var regstr3 = /^\d{7,8}$/;return regstr3.test(str);}
	}
	this.chkPhone = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			if (o.isPhone(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.isPhone = "电话号码格式错误";
				o.setErr(id , o.warning.isPhone);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.isPhone = function(str){
		var o = this;if(o.authPhone){var regstr=/^\d{3,4}\-\d{7,8}$/;return regstr.test(str);}
		else{var regstr3 = /^\d{7,8}$/;return regstr3.test(str);}
	}
	this.chkTel = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			if (o.isTel(v))
				o.check = o.check == true ? true : false;
			else{
				o.warning.istel = "手机号码格式错误";
				o.setErr(id , o.warning.istel);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.isTel = function(str){
		var regstr2 = /^\d{11}$/;
		if(regstr2.test(str))return true;
		else
			return false;
	}
	this.chkDate = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			if (v.isDate())o.check = o.check == true ? true : false;
			else{
				o.warning.isdate = "日期格式错误";
				o.setErr(id , o.warning.isdate);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.chkPostCode = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			if (o.isPostCode(v))o.check = o.check == true ? true : false;
			else{
				o.warning.isPostcode = "邮政编码格式错误";
				o.setErr(id , o.warning.isPostcode);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.isPostCode = function(str){var regstr = /^\d{6}$/;return regstr.test(str);}
	this.chkEmailOrInt = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			if((o.isEmail(v) || o.isInt(v)) && v.length > 4)o.check = o.check == true ? true : false;
			else{
				o.warning.isEmailInt = "QQ或MSN号码格式错误";
					o.setErr(id , o.warning.isEmailInt);
					o.errEle.push(id);
					o.check = false;
			}
		}
	}
	this.chkForbidStr = function(id){
		var o = this;var v = $("#"+id).val();
		if(v != ""){
			var re = o.legalityStr(v);
			if( re === true )o.check = o.check == true ? true : false;
			else{
				o.warning.isForbid = "有禁止的字符：" + re;
				o.setErr(id , o.warning.isForbid);
				o.errEle.push(id);
				o.check = false;
			}
		}
	}
	this.legalityStr = function(str , ary){
		ary = typeof ary == "undefined" ? filterStrOfArray : filterStrOfArray.concat(ary);
		if (typeof str == "object"){
			for(s in str){
				for(i in ary){if (str[s].indexOf(ary[i]) > -1){return ary[i];}}
			}
		}else{
			for(i in ary){
				if (str.indexOf(ary[i]) > -1){
					return ary[i];
				}
			}
		}
		return true;
	}
	this.setEmpty = function(id){
		var o = this;
		$("#"+id).focus(function(){
			for(i in o.warning){
				if($("#"+id).val() == o.warning[i]){
					$("#"+id).val("").css("color",o.color);
				}
			}
		});
	}
}
function myDebugOne(type , id , err){
	if(type == "setErr"){
		$("#"+id).addClass("setErr");
		$("#"+id+"_err").addClass("setErr2");
		$("#"+id+"_err2").addClass("setErr2").text(" "+err);
	}else{
		$("#"+id).removeClass("setErr");
		$("#"+id+"_err").removeClass("setErr2");
		$("#"+id+"_err2").removeClass("setErr2").text("");
	}
}
function resetTaxis( ele , url , paro , callback ){
	$(ele).blur(function(){
		if(this.id){
			var nv = $(this).val();var ids = this.id.split("_");var reg = /^\d+$/;
			if(nv == ids[1] || !reg.test(nv) || nv < 1){
				$(this).val(ids[1]);
				return false;
			}
			var sObj = {'id':ids[0] , 'nv':nv , 'ov':ids[1] , 'para':ids[2] , 'm':Math.random(1234)};
			if(typeof paro == 'object')$.extend( sObj , paro );
			insertWaitImg();
			$.get(url , sObj , function(da){
				removeWaitImg();
				if(typeof callback != 'undefined')callback(da);
				else if(da.substr(0,2) == 'ok')location.reload();
				else
					alert(da);
			});
		}
	});
}
function paginationObj(ele, line , pgId , pgSize , url , edge ,disNum){
	$(ele).pagination(line,{
		current_page: (pgId-1),		
		items_per_page: pgSize,
		num_edge_entries: edge,
		num_display_entries: disNum,
		link_to: url,
		callback:function(id,jq){return true;}
	});
}
function setCommend(ele , url , callback){
	$(ele).click(function(){
		if(this.id){var o = this;var ids = this.id.split("_");
			$.get(url,{'id':ids[0], 'para':ids[1],'m':Math.random(1234)},function(da){
				if(typeof callback != "undefined")callback(da , o.id);
				else
					alert(da);
			})
		}
	});
}
function setFlag(eles , url , callback){
	$(eles).click(function(){
		if(this.id){var o = this;var ids = this.id.split("_");var urlstr = url + ids[2];
			$.get(urlstr,{'id':ids[0], 'para':ids[1],'m':Math.random(1234)},function(da){
				if(typeof callback != "undefined")callback(da , o.id);
				else
					alert(da);
			});
		}
	});
}
function getPos(obj){
   var to = new Object();
   to.t=to.l=to.w=to.h=0;
   to.t = obj.offsetTop;
   to.l = obj.offsetLeft;
   to.w = obj.offsetWidth;
   to.h = obj.offsetHeight;
   while(obj = obj.offsetParent){
       to.t += obj.offsetTop;
	   to.l += obj.offsetLeft;
   }
   return to;
}
function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;	
    }
    return new Array(xScroll,yScroll) 
}
function getPageHeight(){
    var windowHeight
    if (self.innerHeight){
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
      windowHeight = document.body.clientHeight;
    }	
    return windowHeight
}
function addSelectItem(id , ary , empty){$(id).empty();$("<option value=''>"+empty+"</option>").appendTo(id);for(i in ary){if(typeof ary[i] == "object")$("<option value='"+ary[i]['val']+"'>"+ary[i]['txt']+"</option>").appendTo(id);}	}
function insertSelectEmptyItem(id , txt){$(id).empty();$("<option value=''>"+txt+"</option>").appendTo(id);}
function relationSelectCascade(pid , sid , aryName , emptyItem){
$(pid).change(function(){$('option:selected', this).each(function(){if(this.value!=''){addSelectItem(sid, eval(aryName + this.value) , emptyItem);}else{insertSelectEmptyItem(sid,emptyItem);}});});}
function insertSelect(parentSelId , subSelId , ary , emptyItemStr){$(parentSelId).change(function(){$('option:selected', this).each(function(){if(this.value != ''){addSelectItem(subSelId, ary , emptyItemStr);}});});}
function selectVal (Name){return $("select[@name='"+Name+"']").val(); }
function selectSet (ID , Val){$(ID).attr("value", Val);}
function setRadioAttr(rName , rValue , attrb ,val){if( typeof val == 'undefined')val = "true";$("input[@type=radio][@name="+rName+"][@value="+rValue+"]").attr(attrb, val); }
function removeDisAttr(rName,rValue){$("input[@type=radio][@name="+rName+"][@value="+rValue+"]").removeAttr("disabled");}
function keyDownSubmit(ele ,formId,callback){$(ele).keydown(function(event){if(event.keyCode == 13){if (typeof callback != "undefined"){callback();return false;}else $(formId).submit();}});}
function getRadioVal(name){return $("input[@type=radio][@name="+name+"][@checked]").val(); }
function getChkBoxVal(name){var chkObj = $("input[@type=checkbox][@name="+name+"][@checked]");var valstr = "";var ds = ",";chkObj.each(function(i){var vs = $(this).val();if(vs != "undefined"){if(i == (chkObj.length - 1) )ds = "";valstr += (vs + ds);}});return  valstr;}
function CheckAll(name,boolv,valStr){var chkObj = $("input[@type=checkbox][@name="+name+"]");if(typeof valStr == "undefined"){chkObj.each(function(){$(this).attr("checked",boolv);});}else{valStr = valStr.split(",");for(i=0 ; i < valStr.length ; i++){chkObj.each(function(){if(this.value == valStr[i])$(this).attr("checked" , boolv);});}}}
function sumtotal(ele){var sum = 0;$(ele).each(function(){sum += parseFloat( $(this).text() );});return sum.toFixed(2);}
function sumtotalDou(ele,ele2){var sum = 0;var ary1 = new Array();var ary2 = new Array();$(ele).each(function(i){ary1[i]=parseFloat($(this).text());});$(ele2).each(function(i){ary2[i]=parseFloat($(this).text());});for(i=0; i< ary1.length ; i++){if( ary1[i] > 0 && ary2[i] == 0 ){sum += ary1[i];}else if( ary1[i] == 0 && ary2[i] > 0 ){sum += ary2[i];}else if( ary1[i] > 0 && ary2[i] > 0 ){if( ary1[i] > ary2[i] ){sum += ary2[i];}else{sum += ary1[i];}}}return sum.toFixed(2);}
function countRebate(p,r){if(r < 1)return p;else return (p/10*r);}var filterStrOfArray = ['共产','共产党','法轮','法轮功','社会主义'];var oneWarning = new Array();oneWarning['warn_pwd_differ'] = "两次输入的密码不一致." ;oneWarning['warn_username_exists'] = "用户名已被使用,请重新输入." ;oneWarning['warn_username_notExists'] = '用户名不存在.';oneWarning['warn_pwd_wrong'] = '密码错误.';oneWarning['warn_uname_pwd_empty'] = "用户名和密码必须填写.";oneWarning['warn_uname_or_mail_wrong'] = "用户名或邮件地址有错误.";oneWarning['warn_cont_must'] = "内容不能为空.";oneWarning['warn_must_login'] = "必须先登录.";oneWarning['warn_commodity_exists'] = "该商品已经在您的收集夹中了.";oneWarning['warn_exists_shoppingcar'] = "该商品已存在于你的购物车中.";oneWarning['warn_wrong_operation'] = "错误的操作程序.";oneWarning['warn_noChecked'] = "你所提交的信息没有通过审核,有任何疑问可以直接和我们联系.";oneWarning['warn_add_shoppingcar_fail'] = "放入购车失败.";oneWarning['warn_not_add_self'] = "不能添加自已";oneWarning['warn_league_exists'] = "您添加的加盟商已是您的下级";oneWarning['warn_league_is_parent'] = "不能将自已上级加盟商做为自已的下级";oneWarning['warn_order_goodslist_relation'] = "该定单下有相关的商品清单记录，不能删除";oneWarning['warn_alerady_add'] = "您所推荐的加盟商已经被其它加盟商推荐过了.";