//<![CDATA[
/*// JavaScript  Document's prototype
======================================================
/// 徐武开发   time:2007-12-1 visor
// website:www.023si.com www.maihuolang.cn www.p-so.com
======================================================*/


//=======================变量开始=========================

var userAgent = navigator.userAgent.toLowerCase();

var now = /..:..:../.exec(Date())[0]; //最简单的获取当前时间(js)兼容firefox
var tt=0;

//=======================函数开始=========================
//trim 函数 
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.replaceAll=function(s1,s2)
{var demo=this
 while(demo.indexOf(s1)!=-1)
 demo=demo.replace(s1,s2);
 return demo;
}

function AJAXRequest() {
	var xmlPool=[],AJAX=this,ac=arguments.length,av=arguments;
	var xmlVersion=['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP']
	var emptyFun=function(){};
	var av=ac>0?typeof(av[0])=="object"?av[0]:{}:{};
	var encode=av.charset?av.charset.toUpperCase()=="UTF-8"?encodeURIComponent:escape:encodeURIComponent;
	this.url=getp(av.url,"");
	this.oncomplete=getp(av.oncomplete,emptyFun);
	this.content=getp(av.content,"");
	this.method=getp(av.method,"POST");
	this.async=getp(av.async,true);
	this.onexception=getp(av.onexception,emptyFun);
	this.ontimeout=getp(av.ontimeout,emptyFun);
	this.timeout=getp(av.timeout,3600000);
	this.onrequeststart=getp(av.onstartrequest,emptyFun);
	this.onrequestend=getp(av.onendrequest,emptyFun);
	if(!getObj()) return false;
	function getp(p,d) { return p?p:d; }
	function getObj() {
		var i,j,tmpObj;
		for(i=0,j=xmlPool.length;i<j;i++) if(xmlPool[i].readyState==0||xmlPool[i].readyState==4) return xmlPool[i];
		try { tmpObj=new XMLHttpRequest; }
		catch(e) {
			for(i=0,j=xmlVersion.length;i<j;i++) {
				try { tmpObj=new ActiveXObject(xmlVersion[i]); } catch(e2) { continue; }
				break;
			}
		}
		if(!tmpObj) return false;
		else { xmlPool[xmlPool.length]=tmpObj; return xmlPool[xmlPool.length-1]; }
	}
	function $(id){return document.getElementById(id);}
	function $N(n,d){n=parseInt(n);return(isNaN(n)?d:n);}
	function $VO(v) {
		if(typeof(v)=="string") {
			if(v=$(v)) return v;
			else return false; }
		else return v;
	}
	function $ST(obj,text) {
		var nn=obj.nodeName.toUpperCase();
		if("INPUT|TEXTAREA".indexOf(nn)>-1) obj.value=text;
		else try{obj.innerHTML=text;} catch(e){};
	}
	function $CB(cb) {
		if(typeof(cb)=="function") return cb;
		else {
			cb=$VO(cb);
			if(cb) return(function(obj){$ST(cb,obj.responseText);});
			else return emptyFun; }
	}
	function send(purl,pc,pcbf,pm,pa) {
		var purl,pc,pcbf,pm,pa,ct,ctf=false,xmlObj=getObj(),ac=arguments.length,av=arguments;
		if(!xmlObj) return false;
		if(!pm||!purl||!pa) return false;
		var ev={url:purl, content:pc, method:pm};
		purl+=(purl.indexOf("?")>-1?"&":"?")+Math.random();
		xmlObj.open(pm,purl,pa);
		AJAX.onrequeststart(ev);
		if(pm=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ct=setTimeout(function(){ctf=true;xmlObj.abort();},AJAX.timeout);
		xmlObj.onreadystatechange=function() {
			if(ctf) { AJAX.ontimeout(ev); AJAX.onrequestend(ev); }
			else if(xmlObj.readyState==4) {
				ev.status=xmlObj.status;
				try{ clearTimeout(ct); } catch(e) {};
				try{ if(xmlObj.status==200) pcbf(xmlObj); else AJAX.onexception(ev); }
				catch(e) { AJAX.onexception(ev); }
				AJAX.onrequestend(ev);
			}
		}
		if(pm=="POST") xmlObj.send(pc); else xmlObj.send("");
	}
	this.setcharset=function(cs) {
		if(cs.toUpperCase()=="UTF-8") encode=encodeURIComponent; else encode=escape;
	}
	this.get=function() {
		var purl,pcbf,ac=arguments.length,av=arguments;
		purl=ac>0?av[0]:this.url;
		pcbf=ac>1?$CB(av[1]):this.oncomplete;
		if(!purl&&!pcbf) return false;
		send(purl,"",pcbf,"GET",true);
	}
	this.update=function() {
		var purl,puo,pinv,pcnt,ac=arguments.length,av=arguments;
		puo=ac>0?$CB(av[0]):emptyFun;
		purl=ac>1?av[1]:this.url;
		pinv=ac>2?$N(av[2],1000):null;
		pcnt=ac>3?$N(av[3],0):null;
		if(pinv) {
			send(purl,"",puo,"GET",true);
			if(pcnt&&--pcnt) {
				var cf=function(cc) {
					send(purl,"",puo,"GET",true);
					if(cc<1) return; else cc--;
					setTimeout(function(){cf(cc);},pinv);
				}
				setTimeout(function(){cf(--pcnt);},pinv);
			}
			else return(setInterval(function(){send(purl,"",puo,"GET",true);},pinv));
		}
		else send(purl,"",puo,"GET",true);
	}
	this.post=function() {
		var purl,pcbf,pc,ac=arguments.length,av=arguments;
		purl=ac>0?av[0]:this.url;
		pc=ac>1?av[1]:"";
		pcbf=ac>2?$CB(av[2]):this.oncomplete;
		if(!purl&&!pcbf) return false;
		send(purl,pc,pcbf,"POST",true);
	}
	this.postf=function() {
		var fo,vaf,pcbf,purl,pc,pm,ac=arguments.length,av=arguments;
		fo=ac>0?$VO(av[0]):false;
		if(!fo||(fo&&fo.nodeName!="FORM")) return false;
		vaf=fo.getAttribute("onsubmit");
		vaf=vaf?(typeof(vaf)=="string"?new Function(vaf):vaf):null;
		if(vaf&&!vaf()) return false;
		pcbf=ac>1?$CB(av[1]):this.oncomplete;
		purl=ac>2?av[2]:(fo.action?fo.action:this.url);
		pm=ac>3?av[3]:(fo.method?fo.method.toUpperCase():"POST");
		if(!pcbf&&!purl) return false;
		pc=this.formToStr(fo);
		if(!pc) return false;
		if(pm) {
			if(pm=="POST") send(purl,pc,pcbf,"POST",true);
			else if(purl.indexOf("?")>0) send(purl+"&"+pc,"",pcbf,"GET",true);
				else send(purl+"?"+pc,"",pcbf,"GET",true);
		}
		else send(purl,pc,pcbf,"POST",true);
	}
	this.formToStr=function(fc) {
		var i,qs="",and="",ev="";
		for(i=0;i<fc.length;i++) {
			e=fc[i];
			if (e.name!='') {
				if (e.type=='select-one'&&e.selectedIndex>-1) ev=e.options[e.selectedIndex].value;
				else if (e.type=='checkbox' || e.type=='radio') {
					if (e.checked==false) continue;
					ev=e.value;
				}
				else ev=e.value;
				ev=encode(ev);
				qs+=and+e.name+'='+ev;
				and="&";
			}
		}
		return qs;
	}
}
function $(id) {
	return document.getElementById(id);
}
// AJAX 错误处理
function onexception(ex){
var ss=ex.status;
var err_title="本站提醒你,在您的一次请求中,有如下错误,请稍后再试!\n\n";
	switch(ss){
	case 400:err_title+="I.对不起，你的请求出现语法错误!";break;
	case 403.8:err_title+="I.对不起，你的访问请求被拒绝!";break;
	case 403.9:err_title+="I.对不起，网站访问人数过多,请稍后重试!";break;
	case 404:err_title+="I.对不起，你的访问请求页面不存在!";break;
	case 500.13:err_title+="I.对不起，Web 服务器太忙!";break;
	case 500.100:err_title+="I.对不起，服务器内部错误!";break;
	case 12029:err_title+="I.对不起，服务器暂时无法链接!";break;
	default: return true;break;
	}
	if (ss>=400){alert(err_title+"\n对不起，你在本次访问中发生了一些未知错误。\n错误ID:"+ss+" 你可以通该错误ID联系我们,以更好的处理您的问题!");}
}

function chage_class(obj,cls){
	var o=$(obj);
	if(o){
		o.className=cls;
		o.onclick=function(){return false;}
		o.onfocus=function(){this.blur();}
	}
}
/// 自动选择菜单函数
function $AutosetSel(idname,str){
var idx=$(idname);
if(idx){
	for(var i=0;i<idx.options.length;i++){                
	if (idx.options[i].value==str){
	idx.selectedIndex=i;
	break;
	}
	}   
}
}

function div_dishide(od)   
{   
  if($(od)){
	  if($(od).style.display=="none"){
	  $(od).style.display="";
	  }else{
	   $(od).style.display="none";
	  }
	  }
}
function ValidateEmail(j)
{
    var emailReg=/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    return emailReg.test(j);
}

function div_show(idp)   
{
var od=$(idp);
	if(od){
		var x,y;
	if(!document.all){
		x=e.pageX; 
		y=e.pageY;
	}else{
		x=document.body.scrollLeft+event.clientX;
		y=document.body.scrollTop+event.clientY; 
	}
	//alert("x:"+x+"y:"+y);
 	 //od.style.top=event.y+15;
// 	 od.style.left=event.x+12;
	 od.style.top=y+12;
 	 od.style.left=x+15;
  	 od.style.display="block";
	}
}
function show_div(od)   
{   
  if($(od)){$(od).style.display="";}   
}
function div_hide(od)   
{   
  if($(od)){$(od).style.display="none";}
}

//整除
function get_int(exp1, exp2)
{
    var n1 = Math.round(exp1); //四舍五入
    var n2 = Math.round(exp2); //四舍五入    
    var rslt = n1 / n2; //除
    if (rslt >= 0)
    {
        rslt = Math.floor(rslt); //返回值为小于等于其数值参数的最大整数值。
    }
    else
    {
        rslt = Math.ceil(rslt); //返回值为大于等于其数字参数的最小整数。
    } 
    return rslt;
}


//获取光标位置
function getCursorPos(){
        var pos=-1;
        var sText=document.selection.createRange();
        var tempText=document.body.createTextRange();;
        sText.select();
        tempText.setEndPoint("EndToStart",sText);
        pos=tempText.text.length;
        return pos;
}
function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

// 找上级ID名
function findfjid(id){
	var s=document.getElementById(id);
	if(s){
		return s.parentNode.id;
	}else{
		return null;	
	}
}

//　改变字体大小
function chanage_font(id,fs){
	var ids=$(id);
	if(fs==""||fs==null){fs=10;}
	if(ids){
		ids.style.fontSize=fs;
	}
}

function checkRateX(v,s)
{
var re = /^[0-9]+.?[0-9]*$/; 
if(s==1){
re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/ 
}
if (!re.test(input.rate.value))
{
alert("请输入数字(例:0.02)");
input.rate.focus();
return false;
}
} 


function win_status(w){window.status=w;return true;}

function trim_s(arr){
	if(arr!=""){
	var sarr=arr.split(",");
		for(i=0;i<=sarr.length-1;i++){
		var x=$(sarr[i])
			if(x){
			x.value=(x.value).trim();
			}
		}
	}
}
// 取二位小数
function getnum(f, c)
{
    var t = Math.pow(10, c);
    return Math.round(f * t) / t;
}
// 随机取色函数
function foo() {
  var rndColor = '#';
  var hexValues = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
  for (var i=0; i<6; i++) {
    rndColor += ''+hexValues[parseInt(Math.random()*hexValues.length)];
  }
	return rndColor;
}

function StripTags(str) { 
    return str.replace(/<\/?[^>]+>/gi, ''); 
  } 
function clear_times(){if(tt!=null){clearTimeout(tt);}} 
//tt=setTimeout("club_divmenuc("+id+")",2000);

function con_com(str){
if(str==null||str==""||str.length<=0){
	return confirm('你确定删除此信息吗？');
}else{
	return confirm(str);
	}
}
function go_url(url){
	location.href=url;
}
 /// 脚本永不出错代码
function killErrors() 
{ 
return true; 
}
function show_mes(id){
var err=$(id);
if(err){
	if(err.innerHTML.trim().length>=5){
		err.style.display="";
		}
	}
}


function isUserName(v) {
	return /^[a-zA-Z-0-9-_]{3,15}$/.test(v);
}
function isPassword(v) {
return /^(.|\n){6,20}$/.test(v);
}
function isPassword(v) {
return /^(.|\n){6,20}$/.test(v);
}
function isRealName(v) {
return /^[\u4e00-\u9fa5]{2,4}$/.test(v);
}
function isempty(v) {
return !((v == null) || (v.length == 0) || /^\s+$/.test(v));
}
function isenglish(v) {
return /^[a-zA-Z]+$/.test(v);
}
function isnumber(v) {
return (!isNaN(v) && !/^\s+$/.test(v));
}
function ischinese(v) {
return /^[\u4e00-\u9fa5]+$/.test(v);
}
function isennumcn(v){
return /^[\u4e00-\u9fa5-a-zA-Z-0-9]+$/.test(v);
}
function isemail(v){
return /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v);
}
function isphone(v){
return /^((0[1-9]{3})?(0[12][0-9])?[-])?\d{6,8}$/.test(v);
}
function ismobilephone(v){
return /(^0?[1][35][0-9]{9}$)/.test(v);
}
function isidcard(v){
var isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/; 
var isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/; 
return isIDCard1.test(v)||isIDCard2.test(v);
}


//window.onerror = killErrors; 
//脚本永不出错代码
//]]>