(function(){var isOpera=window.Opera||navigator.userAgent.toLowerCase().indexOf("opera")>-1;xBase={isOpera:isOpera,isIE:(document.all&&!isOpera),clone:function(source,addprop){var clone={};if(source){this.copy(clone,source)}if(addprop){this.copy(clone,addprop)}return clone},copy:function(target,source){for(var i in source){target[i]=source[i]}},extend:function(subClass,superClass){var f=function(){};f.prototype=superClass.prototype;var subProto=subClass.prototype;subClass.prototype=new f();subClass.prototype.constructor=subClass;if(superClass.prototype.constructor==Object.prototype.constructor){superClass.prototype.constructor=superClass}for(var i in subProto){subClass.prototype[i]=subProto[i]}subClass._super=superClass.prototype},dumpHtml:function(obj){if(typeof obj=="object"){var txt='{<div style="margin-left:2em;">';for(var i in obj){txt+="["+i+"] : "+this.dumpHtml(obj[i])}txt+="</div>}";return txt}else{if(typeof obj=="function"){return(obj+"").replace(/[\r\n\s]+/g," ")+"<br />"}else{if(typeof obj=="string"){return'"'+obj+'"<br />'}else{return obj+"<br />"}}}},dump:function(obj,indent){if(!indent){indent=""}if(typeof obj=="object"){var childIndent=indent+"    ";var txt="{\n";for(var i in obj){txt+=childIndent+"["+i+"] : "+this.dump(obj[i],childIndent)+"\n"}txt+=indent+"}";return txt}else{if(typeof obj=="function"){return(obj+"").replace(/[\r\n\s]+/g," ")}else{if(typeof obj=="string"){return'"'+obj+'"'}else{return obj}}}}};if(typeof Array.prototype.splice=="undefined"){Array.prototype.splice=function(p,d){if(!p){p=0}if(!d){d=this.length-p}var len=this.length,res=this.slice(p,p+d),bak=this.slice(p+d),i=p,cnt=0,j;if(!!arguments){cnt=arguments.length-2;for(i=0;i<cnt;i++){this[p+i]=arguments[i+2]}i+=p}for(j=0;j<bak.length;j++){this[i++]=bak[j]}this.length=len-d+cnt;return res}}if(typeof Array.prototype.indexOf=="undefined"){Array.prototype.indexOf=function(item,start){if(typeof start!="number"){start=0}for(var i=start;i<this.length;i++){if(this[i]==item){return i}}return -1}}Function.prototype.bind=function(){var __method=this;var object=arguments[0];var args=arguments;for(var i=1;i<args.length;i++){args[i-1]=args[i]}args.length--;return function(){return __method.apply(object,args)}};Function.prototype.bindAsEventListener=function(object){var __method=this;return function(e){var args=[],i;if(e){args.push(e);i=1}else{args.push(window.event);i=0}while(i<arguments.length){args.push(arguments[i++])}return __method.apply(object,args)}};$=function(){var elements=new Array();for(var i=0;i<arguments.length;i++){var element=arguments[i];if(typeof element=="string"){element=document.getElementById(element)}if(arguments.length==1){return element}elements.push(element)}return elements};(function(){var COLLECTION_NAME="_xEvent_listenerCollection";xEvent={onLoadListeners:new Array(),initialize:function(target){var proto=this.EventDispatcher.prototype;if(typeof target=="function"&&target.prototype){xBase.copy(target.prototype,proto)}else{xBase.copy(target,proto)}},listenerToFunction:function(name,listener){var type=typeof listener;if(type=="function"){return listener}if(listener instanceof Array){if(listener.length<2){throw new Error("listener type error (listener type:"+(typeof listener)+", event:"+name+")")}var obj=listener[0],funcName=listener[1],func=funcName;if(typeof obj!="object"){throw new Error("listener[0] is not object (listener[0] type:"+(typeof obj)+"), event:"+name)}if(typeof func=="string"){func=obj[func]}if(typeof func!="function"){throw new Error("listener[1] type error (listener[1] type:"+(typeof funcName)+"), event:"+name)}return func.bindAsEventListener(obj)}if(typeof listener!="object"){throw new Error("listener type error type:"+type)}if(typeof(listener[name])=="function"){return listener[name].bindAsEventListener(listener)}throw new Error('listener has not method "'+name+'"')},addListener:function(target,name,listener,useCapture){var lc=this.getListenerCollection(target);if(!lc){lc=this.createListenerCollection(target)}lc.addListener(target,name,listener,useCapture)},addLoadListener:function(listener){var lfunc=this.listenerToFunction("load",listener);if(this.onLoadListeners instanceof Array){this.onLoadListeners.push(lfunc)}else{lfunc()}},removeListener:function(target,name,listener,useCapture){var lc=this.getListenerCollection(target);if(!lc){return false}var res=lc.removeListener(target,name,listener,useCapture);if(!lc.hasItem()){this.clearAllListeners(target)}return res},clearAllListeners:function(target){try{delete target[COLLECTION_NAME]}catch(e){try{target[COLLECTION_NAME]=null}catch(e){}}},getListenerCollection:function(target){if(typeof target[COLLECTION_NAME]!="object"){return false}return target[COLLECTION_NAME]},createListenerCollection:function(target){target[COLLECTION_NAME]=new xEvent.ListenerItemCollection();return target[COLLECTION_NAME]},getXY:function(e){var p;if(document.all){var elm=document.compatMode&&document.compatMode.match(/CSS/i)?document.documentElement:document.body;p=[elm.scrollLeft+event.clientX,elm.scrollTop+event.clientY]}else{p=[e.clientX+window.scrollX,e.clientY+window.scrollY]}p.x=p[0];p.y=p[1];return p},getX:function(e){return this.getXY(e).x},getY:function(e){return this.getXY(e).y},stopEvent:function(e){this.stopPropagation(e);this.preventDefault(e)},stopPropagation:function(e){if(typeof e.stopPropagation=="function"){e.stopPropagation()}else{e.cancelBubble=true}},preventDefault:function(e){if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}},toString:function(){return"[object xEvent]"}}})();(function(){var UE=xEvent;xEvent.EventDispatcher=function(){};xEvent.EventDispatcher.prototype={addListener:function(name,listener,useCapture){return UE.addListener(this,name,listener,useCapture)},removeListener:function(name,listener,useCapture){return UE.removeListener(this,name,listener,useCapture)},dispatch:function(name,obj,evtCtg){var collection=UE.getListenerCollection(this);if(!collection){return}var listeners=collection.getListeners(name);if(!listeners||listeners.length==0){return}if(!obj){obj=new Object()}if(this.dispatchEvent){var evt=(evtCtg&&document.createEvent(evtCtg)||document.createEvent("Events")||document.createEvent("UIEvents"));try{evt.initEvent(listeners[0].useName,true,true);for(var i in obj){evt[i]=obj[i]}evt.element=function(){return this.target};return this.dispatchEvent(evt)}catch(e){}}else{if(this.fireEvent){var evt=document.createEventObject();for(var i in obj){evt[i]=obj[i]}evt.element=function(){return this.srcElement};try{eval("return this.fireEvent('on'+listeners[0].useName, evt)")}catch(e){}}}try{obj.type=name}catch(e){}try{obj.target=this}catch(e){}obj.element=function(){return this.target};var lsns=listeners.concat();for(var i=0;i<lsns.length;i++){lsns[i].func(obj)}}}})();xEvent.ListenerItemCollection=function(){this.collection=new Object()};xEvent.ListenerItemCollection.prototype={addListener:function(target,name,listener,useCapture){if(this.getIndex(target,name,listener,useCapture)!=-1){return}if(!this.collection[name]){this.collection[name]=new Array()}var listeners=this.collection[name];var li=new xEvent.ListenerItem(target,name,listener,useCapture);listeners[listeners.length++]=li;if(target.attachEvent){return target.attachEvent("on"+li.useName,li.func)}else{if(target.addEventListener){return target.addEventListener(li.useName,li.func,li.useCapture)}else{if(target.dispatch){return true}}}li.target["on"+li.useName]=function(evt){this.dispatch(li.name,evt,li.useCapture)};return true},removeListener:function(target,name,listener,useCapture){var index=this.getIndex(target,name,listener,useCapture);if(index==-1){return false}var listeners=this.collection[name];var li=listeners[index];listeners.splice(index,1);if(listeners.length==0){delete this.collection[name]}if(target.detachEvent){target.detachEvent("on"+li.useName,li.func)}else{if(target.removeEventListener){target.removeEventListener(li.useName,li.func,li.useCapture);return"removeEventListener"}else{if(target.dispatch){}else{if(target["on"+li.useName]){delete target["on"+li.useName]}else{return false}}}}return true},getListeners:function(name){if(!this.collection[name]){return false}return this.collection[name]},hasItem:function(){for(var i in this.collection){return true}return false},getIndex:function(target,name,listener,useCapture){if(!this.collection[name]){return -1}var listeners=this.collection[name];for(var i=0;i<listeners.length;i++){if(listeners[i].equals(target,name,listener,useCapture)){return i}}return -1},clear:function(){delete this.collection;this.collection=new Object()}};xEvent.ListenerItem=function(target,name,listener,useCapture){this.target=target;this.name=name;if(name=="keypress"&&!xBase.isOpera&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||target.attachEvent)){this.useName="keydown"}else{if(name=="mousewheel"&&!target.attachEvent){this.useName="DOMMouseScroll"}else{this.useName=name}}this.listener=listener;this.useCapture=!!useCapture;try{this.func=xEvent.listenerToFunction(name,listener)}catch(e){}};xEvent.ListenerItem.prototype={equals:function(target,name,listener,useCapture){if(this.name!=name||this.target!=target){return false}if(this.useCapture!=(!!useCapture)){return false}if(typeof listener=="function"&&this.listener!==listener){return false}if(typeof listener=="object"&&listener instanceof Array){if(listener.length!=2){return false}return(this.listener[0]===listener[0]&&this.listener[1]===listener[1])}return(this.listener===listener)}};xEvent.addListener(window,"load",function(evt){var lsn=this.constructor;setTimeout(function(){var f;while(f=xEvent.onLoadListeners.shift()){f(evt)}xEvent.onLoadListeners=false;xEvent.removeListener(window,"load",lsn)},0)})})();
