function $(element){
	if(typeof element == "string")
		return document.getElementById(element);
	return element;
}
function $T(){return (new Date()).getTime();}
function $CSS(e,sn){
	if(e.style[sn]){return e.style[sn];}
	if(e.currentStyle){return e.currentStyle[sn];}
	if(document.defaultView&&document.defaultView.getComputedStyle){
		var s=document.defaultView.getComputedStyle(e,null);
		sn=sn.replace(/[A-Z]/g,"-$1");
		//return s&&s.getPropertyValue(sn);
		return s?s[sn]:null;
	}
}
function applyStyle(){
	var args=arguments;
	if(args.length==2){
		if(typeof(args[1])=="string") args[0].className=args[1];
		else if(typeof(args[1])=="object"){
			for(var i in args[1]) args[0].style[i]=args[1][i];
		}
	}
	else if(args.length==3) args[0].style[args[1]]=args[2];
	return args[0];
}
function getRand(nMin,nMax){
	var rand=Math.random();
	return parseInt((rand*(nMax-nMin+1)+nMin));
}
function getNavSize(){
	var w=(window.innerWidth)?window.innerWidth:(
	(document.documentElement&&document.documentElement.clientWidth)?
	document.documentElement.clientWidth:document.body.offsetWidth
	);
	var h=(window.innerHeight)?window.innerHeight:(
	(document.documentElement&&document.documentElement.clientHeight)?
	document.documentElement.clientHeight:document.body.offsetHeight
	);
	return [w,h];
}
function alpha(w,trans){
	if(typeof(trans)!='number') return w;
	return isIE()?applyStyle(w,'filter','alpha(opacity='+trans+')'):applyStyle(w,'opacity',trans/100);
}
function deployScript(ajaxReturn,context){
	var Exp=new RegExp(expcls.scriptTag,'img');
	var funcs=ajaxReturn.match(Exp);
	if(funcs==null) return;
	for(var i=0;i<funcs.length;i++){
		context.eval(funcs[i].replace(/\<\/?script[^\>]*\>/img,''));
	}
}
function stopE(e){
	if(e.stopPropagation)
		e.stopPropagation();
	else
		window.event.cancelBubble=true;
}
function buildCls(){return function(){this.initial.apply(this,arguments);}}
function extend(d,s){for(var property in s){d[property]=s[property];}return d;}
function buildFunc(obj,fn){obj=(obj)?obj:window;var args=$A(arguments).slice(2);return function(){obj[fn].apply(obj,args);}}
function package(obj,fn){return function(){fn.apply(obj,arguments);}}
function $pkg(obj,fn){var args=$A(arguments).slice(2);return function(){fn.apply(obj,args);}}
function $A(iterable){
	if(!iterable) return [];
	var r=[];
	for(var i=0;i<iterable.length;i++) r.push(iterable[i]);
	return r;
}
function lTrim(str){return str.replace(/^\s+/,"")}
function rTrim(str){return str.replace(/\s+$/,"")}
function trim(str){return lTrim(rTrim(str))}
function isIE(){return navigator.userAgent.match(/\bMSIE\b/)!=null;}
function isNumber(num){return num.match(/^\d+$/)!=null}
function isUrl(u){return u.match(/^http:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?$/)!=null}
function isEmail(e){return e.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)!=null}
function isPhone(p){return p.match(/^(\(\d{3,4}\)|(\d{3,4}-))?\d{7,8}$/)!=null}
function isMPhone(p){return p.match(/^(13|15)\d{9}$/)!=null}
function isChinese(str){return str.match(/[\u4e00-\u9fa5]+/)!=null}
function isDomain(domain){
	domain=domain.toLowerCase();
	if(domain.length>=26) return false;
	var dlist=['www','clinic','doctor','club','down','info','shop','hos','demo'];
	for(var i=0;i<dlist.length;i++){
		if(domain==dlist[i]) return false;
	}
	var rExp=/^[a-z0-9]+\-?[a-z0-9]+$/ig
	return (domain.match(rExp)!=null);
}
function badChar(str){
	var regE=/\$|!|\<|\>|\?|\#|\^|\%|\@|~|`|\&|\*|\(|\)|\;|\:|\+|\=|\'|\"/img;
	return regE.test(str);
}
function isDate(dt){
	var da,dy,dm,dd,ny,nm,nd;
	da=dt.split("-");
	if(da.length!=3) return false;
	dy = da[0];
	dm = da[1];
	dd = da[2];
	dt = new Date(dt.replace(/\-/g,"\/"));
	if(dt=="NaN") return false;
	ny = dt.getFullYear();
	nm = dt.getMonth()+1;
	nd = dt.getDate();
	if(ny!=dy||nm!=dm||nd!=dd) return false;
	return true;
}
function compDate(d1,d2){
	d1 = (typeof(d1)=="string")?new Date(d1.replace(/\-/g,"\/")):d1;
	d2 = (typeof(d2)=="string")?new Date(d2.replace(/\-/g,"\/")):d2;
	return (d1==d2)?0:(d1>d2)?1:-1;
}
function clearModelTag(str){return str.replace(/\<[^\>]+\>/g,"");}
function ReSize(w,limit){
	if(parseInt(w.width) <= limit) return;
	w.height = parseInt(w.height / w.width * limit);
	w.width  = limit;
}
var autoExec=buildCls();
autoExec.prototype={
	initial:function(fn,second){
		this.counter   = 0;
		this.runTime   = 0;
		this.isRunning = false;
		this.fqcy      = second*1000;
		this.callback  = fn;
		this.run();
	},
	run:function(){this.interval=setInterval(buildFunc(this,"runfn"),this.fqcy);},
	runfn:function(){
		if(!this.isRunning){
			try{
				this.isRunning=true;
				this.counter+=1;
				this.runTime=this.counter*this.fqcy/1000;
				this.callback(this);
			}catch(e){this.stop();}
			finally{this.isRunning=false;}
		}
	},
	stop:function(){
		if(!this.interval) return;
		clearInterval(this.interval);
		this.isRunning=false;
		this.interval=null;
	},
	start:function(){
		if(this.interval) return;
		this.run();
	},
	getMsg:function(){
		var rmsg=['Running Status:'];
		for(var i in this){
			if(typeof(this[i])!="function"&&i!="interval")
				rmsg.push(i+"-------------"+this[i]);
		}
		return rmsg.join('\n');
	}
};