/***
   Author: Hangring
   Date: 2008-11-04
   ---
   global.lib.js string.lib.js browser.lib.js css.lib.js node.lib.js cookie.lib.js events.lib.js oajax.lib.js url.lib.js number.lib.js
***/

$Defined('Global');var Global={PATH:'/'};Global.GetObject=function($_){var d=document;return(d.all&&d.all($_))||(d.getElementById&&d.getElementById($_))||null;}
Global.GetDocWidth=function(d){d=d||document;return Math.max(this.GetClientWidth(d),d.body.offsetWidth);};Global.GetDocHeight=function(d){d=d||document;return Math.max(this.GetClientHeight(d),d.body.offsetHeight);};Global.GetScrollLeft=function(d){d=d||document;return(d.documentElement?d.documentElement.scrollLeft:d.body.scrollLeft);};Global.GetScrollTop=function(d){d=d||document;return(d.documentElement?d.documentElement.scrollTop:d.body.scrollTop);};Global.GetClientWidth=function(d){d=d||document;return(window.innerWidth||d.documentElement&&d.documentElement.clientWidth||d.body.clientWidth);};Global.GetClientHeight=function(d){d=d||document;return(window.innerHeight||d.documentElement&&d.documentElement.clientHeight||d.body.clientHeight);};Global.GetOffsetTop=function(el,p){el=$(el);var _t=el.offsetTop;while(el=el.offsetParent){if(el==p)break;_t+=el.offsetTop;}
return _t;};Global.GetOffsetLeft=function(el,p){el=$(el);var _l=el.offsetLeft;while(el=el.offsetParent){if(el==p)break;_l+=el.offsetLeft;}
return _l;};Global.SetPosition=function(el,related_el,offx,offy){el.style.left=Global.GetLeft(related_el,offx);el.style.top=Global.GetTop(related_el,offy);}
Global.GetLeft=function(p_el,offx){return this.GetOffsetLeft(p_el)+p_el.offsetWidth+(offx||'')+'px'};Global.GetTop=function(p_el,offy){return this.GetOffsetTop(p_el)+(offy||'')+'px';};Global.Random=function(){return(new Date().getTime()+'_'+Math.floor(Math.random()*10000000));};Global.FlashEnabled=function(startVersion,endVersion){var enabled=false;var start=6;var end=11;if(typeof startVersion=='number'){start=startVersion;end=endVersion?(endVersion+1):(startVersion+1);}
if(window.ActiveXObject){for(var i=start;i<end;i++){if(new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+i))
break;}
if(i<end)enabled=true;}
else{var description=navigator.plugins['Shockwave Flash'].description;var arr=/^Shockwave\s+Flash\s+([0-9]+)/i.exec(description);if(arr&&arr.length>1&&arr[1]>=start&&arr[1]<end){enabled=true;}}
return(!!enabled);};Global.LoadScript=function(src){document.write('<script type="text/javascript" src="'+src+'"><'+'/'+'script>');};Global.IsLocal=function(){return location.href.indexOf('file:///')==0;};Array.prototype.push||(Array.prototype.push=function(arg){this[this.length]=arg;});function ToArray(obj,index){return Array.prototype.slice.apply(obj).slice(index||0);}
function TypeOf(obj){if(typeof obj=='undefined')return'undefined';var type=obj.constructor.name;if(obj.constructor&&typeof(type)=='undefined'){if(obj.constructor===Object)
return'object';if(obj.constructor===Function)
return'function';}
return(type?type.toLowerCase():'string');};function $(){var $_=arguments;if($_.length==1){$_=typeof $_[0]=='string'?Global.GetObject($_[0]):$_[0];}
else if($_.length>1){for(var i=0;i<$_.length;i++){$_[i]=typeof $_[i]=='string'?Global.GetObject($_[i]):$_[i];}}
else{$_=null;}
return $_;}
function $E(e,win){win=win||window;return win.event||e||null;}
function $EO(e,win){return e&&(e.target||e.srcElement)||null;}
function $Defined(cls){if(typeof eval(cls)!='undefined')
alert('变量'+cls+' 重定义。');}
window.onerror=function(){};String.prototype.Contains=function(str){return(this.indexOf(str)>-1);};String.prototype.Trim=function(){return this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,'');};String.prototype.LTrim=function(){return this.replace(/^[ \t\n\r]*/g,'');};String.prototype.RTrim=function(){return this.replace(/[ \t\n\r]*$/g,'');};String.prototype.HtmlEntities=function(){return this.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;');};String.prototype.Repeat=function(count){if(typeof count!='number')throw new Error('count is invaild number');var str=_str=this.valueOf();for(var i=0;i<count-1;i++){str+=_str;}
return str;}
String.Space=function(count,htmlEntity){var meta=htmlEntity?'&nbsp;':'\x20';return meta.Repeat(count);};$Defined('Browser');var Browser={s:navigator.userAgent.toLowerCase()};(function(b){b.IsIE=b.s.Contains('msie');b.IsIE5=b.s.Contains('msie 5');b.IsIE6=b.s.Contains('msie 6');b.IsIE7=b.s.Contains('msie 7');b.IsIE56=!b.IsIE7&&(b.IsIE6||b.IsIE5);b.IsGecko=b.s.Contains('gecko');b.IsSafari=b.s.Contains('safari');b.IsOpera=b.s.Contains('opera');b.IsMac=b.s.Contains('macintosh');b.IsIELike=(b.IsIE||b.IsOpera);b.IsGeckoLike=(b.IsGecko||b.IsSafari);})(Browser);$Defined('CSS');var CSS={LEFT:'left',RIGHT:'right',BOTH:'both'};CSS.GetRe=function(c){return new RegExp('^\\s*'+c+'\\s+|\\s+'+c+'\\s*$|\\s+'+c+'\\s+|^\\s*'+c+'\\s*$','');};CSS.AddClass=function(el){if(!oNode.IsNode(el))return;var list=arguments;for(var i=1,len=list.length;i<len;i++){var c=list[i];if(typeof c!='string'||c=='')continue;var re=this.GetRe(c);if(!re.test(el.className)){el.className+=((el.className?'\x20':'')+c).replace(/\s{2,}/g,'\x20');}}};CSS.RemoveClass=function(el){if(!oNode.IsNode(el))return;var list=arguments;for(var i=1,len=list.length;i<len;i++){var c=list[i];if(typeof c!='string'||c=='')continue;var re=this.GetRe(c);if(re.test(el.className)){el.className=el.className.replace(re,'\x20').replace(/^\s{2,}$/,'\x20');}}};CSS.ReplaceClass=function(el,replaced,replacing){this.RemoveClass(el,replaced);this.AddClass(el,replacing);};CSS.HasClass=function(el,c){if(!oNode.IsNode(el))return false;if(typeof c!='string'||c=='')return false;return this.GetRe(c).test(el.className);};CSS.SetAlpha=function(el,opacity){if(Browser.IsIE){try{el.filters[0].Opacity=opacity;}
catch(e){el.style.filter='alpha(Opacity='+opacity+')';}}
else{el.style.MozOpacity=opacity/100;el.style.opacity=opacity/100;}};CSS.GetAlpha=function(el){if(Browser.IsIE){try{return el.filters[0].Opacity;}
catch(e){return 100;}}
else{return el.style.opacity*100;}};CSS.SetDisplay=function(el,display,unset){el.style.display=!!display?(unset?'block':''):'none';};CSS.SetVisible=function(el,visible){el.style.visibility=!!visible?'visible':'hidden';};CSS.SetFloat=function(el,dir){el.style.styleFloat=dir;el.style.cssFloat=dir;};CSS.AddClear=function(el,clear){var node=oNode.CreateNode('div');oNode.AddNode(node,el);node.style.overflow='hidden';node.style.clear=clear;return node;};CSS.SelectOn=function(doc){doc=doc||document;doc.body.style.MozUserSelect='';doc.body.style.KhtmlUserSelect='';doc.onselectstart=null;};CSS.SelectOff=function(doc){doc=doc||document;doc.body.style.MozUserSelect='none';doc.body.style.KhtmlUserSelect='none';doc.onselectstart=function(){return false};};CSS.AddBack=function(el,insertBefore){var BG=oNode.CreateNode('div');if(el)el.$BG=BG;el&&insertBefore?oNode.InsertBefore(BG,el):oNode.AddNode(BG);with(BG.style){position='absolute';zIndex=el?el.style.zIndex:1;left='0px';top='0px';background='#000';}
this.SetAlpha(BG,15);BG.Show=function(){this.style.width=Global.GetDocWidth()-(Browser.IsGecko&&!Browser.IsSafari?18:0)+'px';this.style.height=Math.max(Global.GetDocHeight(),Global.GetClientHeight())+'px';CSS.SetVisible(this,true);};BG.Hide=function(){CSS.SetVisible(this,false);with(this.style){width='1px';height='1px';}};BG.Show();return BG;};CSS.AddStyle=function(cssText,doc){var s=oNode.CreateNode('style');s.type='text/css';if(s.styleSheet){s.styleSheet.cssText=cssText;}
else{oNode.AddNode(cssText,s);}
oNode.AddNode(s,(doc||document).getElementsByTagName('head')[0]);return s;};$Defined('oNode');var oNode={};oNode.IsNode=function(el){if(el&&typeof el=='object'&&el.nodeType==1)
return true;return false;};oNode.IsTextNode=function(el){if(el&&typeof el=='object'&&el.nodeType==3)
return true;return false;};oNode.CreateNode=function(tag){return document.createElement(tag);};oNode.CreateTextNode=function(str){return document.createTextNode(str);};oNode.AddNode=function(node,target){target=target||document.body;if(this.IsNode(node)||this.IsTextNode(node)){if(node.parentNode&&this.IsNode(node.parentNode))return false;target.appendChild(node);typeof(node.AddToStage)=='function'&&node.AddToStage();}
else{this.AddNode(this.CreateTextNode(node.toString()),target);}
return true;};oNode.RemoveNode=function(node,target){if(!node||!node.parentNode||(node.parentNode&&node.parentNode.nodeType!=1))
return null;return node.parentNode.removeChild(node);};oNode.InsertBefore=function(node,target){target.parentNode.insertBefore(node,target);};oNode.CreateIframe=function(name){var el;try{el=this.CreateNode('<iframe name="'+name+'">');}
catch(e){el=this.CreateNode('iframe');el.name=name;}
el.id=name;return el;};oNode.CreateForm=function(name,method,enctype){var el;try{el=this.CreateNode('<form name="'+name+'"'+(enctype?'enctype="'+enctype+'"':'')+(method?' method="'+method+'"':'')+'>');}
catch(e){el=this.CreateNode('form');method&&(el.method=method);enctype&&(el.enctype=enctype);el.name=name;}
return el;};oNode.CreateInput=function(name){var el;try{el=this.CreateNode('<input name="'+name+'">');}
catch(e){el=this.CreateNode('input');el.name=name;}
return el;};$Defined('Cookie');var Cookie={cookies:{},path:''};Cookie.Get=function(){var cookie=document.cookie;if(!cookie)return;cookie=cookie.replace(/\s+/g,'');cookie=cookie.split(';');for(var i=0;i<cookie.length;i++){if(cookie[i].indexOf('=')==-1)return;var _cookie=cookie[i].split('=');this.cookies[_cookie[0]]=unescape(_cookie[1]);}};Cookie.Set=function(name,value,expiration,path){if(!expiration)
expiration=new Date(new Date().getTime()+25*365*24*60*60*1000);document.cookie=name+'='+escape(value)+';expires='+expiration.toGMTString()+';path='+(path||this.path);};Cookie.Del=function(name){Cookie.Set(name,'',new Date(new Date().getTime()-1));};Cookie.Get();$Defined('Events');var Events={};Events.AttachEvent=function(obj,eventName,func,useCapture,_window){obj=$(obj);if(!obj)return;useCapture=useCapture?true:false;eventName=eventName.toLowerCase();if(obj.addEventListener){obj.addEventListener(eventName,func,useCapture);}
else{var E=this;this._AttachEvent(obj,eventName,func);obj['on'+eventName]=function(e){E._FireEvent(obj,eventName,e,_window);};}};Events.RemoveEvent=function(obj,eventName,func,useCapture){obj=$(obj);if(!obj)return;useCapture=useCapture?true:false;eventName=eventName.toLowerCase();if(obj.removeEventListener){obj.removeEventListener(eventName,func,useCapture);}
else{if(obj.events&&obj.events[eventName]){var evts=obj.events[eventName];for(var i=0,len=evts.length;i<len;i++){if(evts[i]&&func&&evts[i]===func){evts.splice(i,1);break;}}}}};Events._AttachEvent=function(obj,eventName,func){eventName=eventName.toLowerCase();if(!obj.events)obj.events={};if(!obj.events[eventName])obj.events[eventName]=[];var evts=obj.events[eventName];evts[evts.length]=func;};Events._FireEvent=function(obj,eventName,e,_window){e=_window?_window.event:$E(e);eventName=eventName.toLowerCase();if(!obj||!obj.events||!obj.events[eventName])return;var evts=obj.events[eventName];for(var i=0,len=evts.length;i<len;i++)
evts[i]&&evts[i].call(obj,e,obj);};Events.CancelBubble=function(e){if(!e)return;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();};Events.CancelEvent=function(e){if(!e)return;e.returnValue=false;if(e.preventDefault)e.preventDefault();};Events.CancelAll=function(e){this.CancelBubble(e);this.CancelEvent(e);};Events.Button=function(e){if(e.button!=undefined)return e.button;else if(e.which!=undefined)return e.which;};function oAjax(){this.req=null;this.url='';this.content='';this.type='text';this.encode='';this.asyn=true;this.action='get';this.error=false;}
oAjax.prototype.init=function(){if(window.XMLHttpRequest){this.req=new XMLHttpRequest();}
else if(window.ActiveXObject){try{this.req=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{this.req=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){this.req=false;}}}
var self=this;if(this.req){this.req.onreadystatechange=function(){self.listener()};}};oAjax.prototype.listener=function(){if(this.req.readyState==4){if(this.req.status==200){try{this.callback(Browser.IsIE&&this.encode=='gb2312'?oAjax.gb2utf8(this.req.responseBody):(this.type=='text'?this.req.responseText:this.req.responseXML));}
catch(e){this.halt('[callback] '+e.name+':'+e.message);}}
else{this.halt('[callback error] '+this.req.status);}}};oAjax.prototype.send=function(url){this.init();url=this.url=url||this.url||'';this.content=!!this.content?this.content:'';this.encode=this.encode?this.encode.toLowerCase():'';this.asyn=this.asyn==undefined?true:!!this.asyn;this.action=(this.action==undefined||this.action=='get')?'Get':'Post';this.error=this.error==undefined?false:!!this.error;if(!url&&this.error){alert('Ajax请求URL不能为空。');return;}
try{this.req.open(this.action,url,this.asyn);}
catch(e){this.halt('[open] '+e.name+':'+e.message);return;}
try{this.req.setRequestHeader('Connection','close');this.req.setRequestHeader('Accept-Encoding','gzip, deflate');this.req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'+(this.encode?';charset='+this.encode:''));if(this.req.overrideMimeType&&this.encode){this.req.overrideMimeType('text/xml'+(this.encode?';charset='+this.encode:''));}
this.req.send(this.content);}
catch(e){this.halt('[open] '+e.name+':'+e.message+'\n** 检查是否为跨域访问。');}};oAjax.prototype.callback=function(content){};oAjax.prototype.abort=function(){this.req.abort();};oAjax.prototype.halt=function(description){this.error&&alert(description);};oAjax.gb2utf8=function(data){var glbEncode=[];gb2utf8_data=data;execScript("gb2utf8_data = MidB(gb2utf8_data, 1)","VBScript");var t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");t=t.split("@");var i=0,j=t.length,k;while(++i<j){k=t[i].substring(0,4);if(!glbEncode[k]){gb2utf8_char=eval("0x"+k);execScript("gb2utf8_char = Chr(gb2utf8_char)","VBScript");glbEncode[k]=escape(gb2utf8_char).substring(1,6);}
t[i]=glbEncode[k]+t[i].substring(4);}
gb2utf8_data=gb2utf8_char=null;return unescape(t.join("%"));}
$Defined('Url');var Url={l:location};Url.Get=function(){var $_=arguments;if($_.length==1){($_=($_[0]in this.QS())?this.QS()[$_[0]]:'');}
else if($_.length>1){for(var i=0;i<$_.length;i++){$_[i]=$_[i]in this.QS()?this.QS()[$_[i]]:'';}}
else{$_='';}
return $_;};Url.Set=function(name,value){this.QueryString[name]=value;};Url.Retrieve=function(){var _url='';for(var item in this.QueryString){var cur=this.QueryString[item];if(_url!='')_url+='&';if(typeof(cur)=='object'){for(var i=0,len=cur.length;i<len;i++){if(_url!='')_url+='&';_url+=item+'='+encodeURIComponent(cur[i]);}}
else{_url+=item+'='+encodeURIComponent(cur);}}
return _url;};Url.QS=function(){if(typeof this.QueryString=='undefined'){this.QueryString={};var query=this.l.search;query=query.substr(1);query=query.split('&');for(var i=0,len=query.length;i<len;i++){var item=query[i].split('=');var name=item[0];var value=decodeURIComponent(item[1]||'');if(typeof this.QueryString[name]=='undefined'){this.QueryString[name]=value;}
else if(TypeOf(this.QueryString[name])=='array'){this.QueryString[name].push(value);}
else{var _value=this.QueryString[name];this.QueryString[name]=[_value,value];}}}
return this.QueryString;};Url.Reload=function(url){var href=this.ClearAnchor(this.l.href);var arr=/^http(?:s)?:\/\/[^\/]+\:(\d+)\//i.exec(url);var _url='://'+this.l.host+'/'+(arr&&arr[1]?':'+arr[1]:'')+url;var sameUrl=0;(this.ClearAnchor('http'+_url)==href&&(sameUrl=1))||(this.ClearAnchor('https'+_url)==href&&(sameUrl=2))
_url=sameUrl!=0&&((sameUrl==1?'http':'https')+_url);if(sameUrl){var anchor=this.GetAnchor(_url);anchor&&this.GotoAnchor(anchor);this.l.reload(true);}
else{this.l.href=url;}};Url.ClearAnchor=function(url){url=url||this.l.href;var index=url.indexOf('#');return index>1?url.substring(0,url.indexOf('#')):url;};Url.GetAnchor=function(url){url=url||this.l.href;return url.substr((url.lastIndexOf('#')+1)||url.length);};Url.GotoAnchor=function(name){if(name=='')return;this.l.hash=name;};Url.Add=function(url,name,value){if(!value)return url;url+=url.indexOf('?')>-1?'&':'?';url+=name+'='+encodeURIComponent(value);return url;};Url.Escape=function(str){return escape(this.UTF8Encode(str));};Url.UTF8Encode=function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;};Url.UTF8Decode=function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;};Url.QS();if(typeof Number=='undefined')Number={};Number.IsNumber=function(text){if(this.IsInt(text)||this.IsFloat(text))
return true;return false;};Number.IsInt=function(text){if(/^\d+$/.test(text))
return true;return false;};Number.IsFloat=function(text){if(/^\d*\.\d+$/.test(text))
return true;return false;};