/**********CONMON FUNCTION**********/
function $(o){return document.getElementById(o);}
function $$(o,t){return o=(typeof(o)=='object')?o.getElementsByTagName(t):$(o).getElementsByTagName(t);}
function $pre(o,a){/*(a:previousSibling,nextSibling,parentNode)*/
	var o=(typeof(o)=='object')?o[a]:$(o)[a];
	return o.nodeType==1?o:$pre(o,a);
}
function $cld(o){
	var o=(typeof(o)=='object')?o.childNodes:$(o).childNodes,c=[];
	for(var i=0,j=o.length;i<j;i++){if(o[i].nodeType==1)c.push(o[i]);}
	return c;
}
function $frame(o){
	return $(o).contentDocument || document.frames[o].document;
}
function $pos(o){
	var w=o.offsetWidth,h=o.offsetHeight,l=o.offsetLeft,t=o.offsetTop;
	while(o=o.offsetParent){w+=o.offsetLeft;t+=o.offsetTop;}
	t+=h;
	return {w:w,h:h,l:l,t:t}
}
function $crt(o,t){
	t=document.createElement(t);
	return (typeof(o)=='object')?o.appendChild(t):$(o).appendChild(t);
}
function $bws(){
	var B={},BI=navigator.userAgent.toLowerCase(),BN;
	(BN=BI.match(/msie ([\d.]+)/)) ? B.ie=BN[1]:(BN=BI.match(/firefox\/([\d.]+)/)) ? B.firefox=BN[1]:(BN=BI.match(/chrome\/([\d.]+)/)) ? B.chrome=BN[1]:(BN=BI.match(/opera.([\d.]+)/)) ? B.opera=BN[1]:(BN=BI.match(/version\/([\d.]+).*safari/)) ? B.safari=BN[1]:0;
	return {ie:B.ie,firefox:B.firefox,chrome:B.chrome,opera:B.opera,safari:B.safari}
}
function $move(o,e){
	var e=e || window.event,posX=e.clientX-parseInt(o.style.left),posY=e.clientY-parseInt(o.style.top);
	document.onmousemove=function(e){
		var e=e || window.event;
		o.style.filter='alpha(opacity=80)';
		o.style.MozOpacity='0.8';
		o.style.left=(e.clientX-posX)+'px';
		o.style.top=(e.clientY-posY)+'px';
	}
	document.onmouseup=function(){o.style.filter='';o.style.MozOpacity='';document.onmousemove=null;}
}
function $trim(v){return v.replace(/^\s+|\s+$/g,'');}
function $stop(e){var e=e || window.event;if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble=true;}}
/**********AJAX CLASS**********/
function $ajax(){
	this.xmlHttp=false;
	this.createXmlHttp=function(){
		try{this.xmlHttp=new XMLHttpRequest();}catch(e1){
			try{this.xmlHttp=new ActiveX0bject('Msxml2.XMLHTTP');}catch(e2){
				try{this.xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');}catch(e3){
					this.xmlHttp=false;}}}
		if(!this.xmlHttp){return false;}
	}
	this.createXmlHttp();
	var ajaxObj=this.xmlHttp,backFun=null;
	this.sendAjaxRequest=function(fun,url,urlArg,mode,bool){/*url:网址; urlArg:网址参数;mode:请求方式;bool:是否异步*/
		if(ajaxObj){
			mode=mode || 'GET',bool=bool || true,backFun=fun;
			ajaxObj.open(mode,url,bool);
			ajaxObj.onreadystatechange=this.stateAjaxRequest;
			ajaxObj.setRequestHeader('Content-Type','application/x-www-urlencode;charset=utf-8');
			if(mode=='POST'){ajaxObj.send(urlArg);}else{ajaxObj.send(null);}
		}
	}
	this.stateAjaxRequest=function(){
		if(ajaxObj.readyState==4 && ajaxObj.status==200){
			if(backFun!=null && typeof backFun=='function'){backFun(ajaxObj.responseText);}
		}
	}
}
/**********COOKIE CLASS**********/
var $cookie={
	setCookie:function(name,value,option){
		var cookieStr=name+'='+escape(value);
		if(option){
			if(option.expiresHours){
				var hours=option.expiresHours*3600*1000;
				var date=new Date();
				date.setTime(date.getTime()+hours);
				cookieStr+=';expires='+date.toGMTString();
			}
			if(option.path){cookieStr+=';path='+option.path;}
			if(option.domain){cookieStr+=';domain='+option.domain;}
			if(option.secure){cookieStr+=';true';}
		}
		document.cookie=cookieStr;
	},
	getCookie:function(name){
		var cookieArray=document.cookie.replace(/ /g,'').split(';');
		for(var i=0,j=cookieArray.length;i<j;i++){
			var nameArray=cookieArray[i].split('=');
			if(name==nameArray[0]){return unescape(nameArray[1]);}
		}
		return '';
	},
	deleteCookie:function(name,option){this.setCookie(name,'',option);}
}
/**********SELECT CLASS**********/
var $s={
	sed:function(o,v){
		var t=v ? this.isset(o,v):false;
		if(o.options.length){
			if(t!==false){o.options[t].selected=true;}
			else{o.options[0].selected=true;}
		}
	},
	isset:function(o,v){
		for(var i=0,j=o.options.length;i<j;i++){
			if(o.options[i].value==v){return i;}
		}
		return false;
	},
	add:function(o,v,t){
		o.options.add(new Option(t ? t:v,v));
	},
	del:function(o,v){
		var t=v ? this.isset(o,v):false;
		if(o.options.length){
			if(t!==false){o.options.remove[t];}
			else{o.options.length=0;}
		}
	}
};
