_isOpera=window.opera?true:false
_isIE=document.all&&!_isOpera?true:false
if(!self.HTMLElement){
	HTMLElement=function(){}
	__IE={
		inherits:function( CH, P, p){
			if (CH&&P&&CH != self[P]&&!CH['has'+P]) {
			    for(p in self[P].prototype)
					if (typeof self[P].prototype[p] == "function" && !CH[p]) 
						CH[p] = self[P].prototype[p];
				CH = __IE.doHtmlElement(CH);
				CH['has'+P] = true;
			}
			return CH
		},
		doHtmlElement:function(o,d,ce,gId,gTag){
			ce = o.createElement?o.createElement:!1;gId = o.getElementById;gTag = o.getElementsByTagName;
			if(ce)o.createElement = function(tag){return __IE.inherits(ce(tag),'HTMLElement');}
			o.getElementById = function(id)	{return __IE.inherits(gId(id),'HTMLElement')}
			o.getElementsByTagName = function(tag,a,i,t)	{for(a=gTag(tag),i=0;t=a[i++];)__IE.inherits(t,'HTMLElement');return a;}
			return o;
		}
	};
	__IE.doHtmlElement(document,document);
}
function gTarget(E,R){E=E||event;E=E.target||E.srcElement;if(_isIE)__IE.inherits(E,'HTMLElement');return R&&!R.test(E[_nN])?!1:E;}
function addClass(x,c){if(!(new RegExp(' ?'+c).test(x[_c])))x[_c]+=' '+c;return x;}
function rmClass(x,c,r){r=new RegExp(' ?'+c,'g');x[_c]=x[_c].replace(r,'');return x;}
function hasClass(X,C){return(X[_c].indexOf(C)!=-1);}
function setStyle(O,S,i){for(i in S)O[_s][i] = S[i];return O;}
function swapClass(X,C1,C2){rmClass(X,C1);addClass(X,C2);return X;}
function addEvent(e,o,f){(o.a=o.addEventListener)?o.a(/wheel$/.test(e)?'DOMMouseScroll':e,f,1):(o.a=o.attachEvent)?o.a('on'+e,f):!1;return o;}
function rmEvent(o,e,f){(o.r=o.removeEventListener)?o.r(e,f,1):(o.r=o.detachEvent)?o.r('on'+e,f):!1;return o;}
function callEvent(O,E,x){return(x=O['on'+E])?x():!1;}
function $(){var t,i=(a=arguments).length,r=[];while(i)if(t=document.getElementById(t=a[--i])||t&&!/^st/i.test(typeof t))r.push(t);return!r[1]?t:r}
function handleSpanTips(e){if((e=gTarget(e,/^span/i)))showInsideTooltip(0,e,e.innerHTML.replace(/^\(|\)$/g, ''));}
function show(o,t){
	o=o&&$(o)||this;
	t = {table:'table',tr:'table-row',td:'table-cell',th:'table-cell'}
	o[_s][_di] = ( !_isIE && ( o.nodeName.toLowerCase() in t ) ) ? t[ o.nodeName.toLowerCase() ] : 'block'
	return o;
}

function hide(o,s){o=o&&$(o)||this;o[_s][_di]='none';return o;}

HTMLElement.prototype.show = show;
HTMLElement.prototype.hide = hide
HTMLElement.prototype.visible=function(){this[_s].visibility='visible';return this;}
HTMLElement.prototype.hidden=function(){this[_s].visibility='hidden';return this;}
HTMLElement.prototype.addClass = function(c){return addClass(this,c);}
HTMLElement.prototype.setClass = function(c){this.className=c;return this;}
HTMLElement.prototype.getClass = function(c){return this.className;}
HTMLElement.prototype.rmClass = function(c){return rmClass(this,c);}
HTMLElement.prototype.hasClass = function(c){return hasClass(this,c);}
HTMLElement.prototype.swapClass = function(C1,C2){rmClass(this,C1);return addClass(this,C2);}
HTMLElement.prototype.addEvent = function(e,f){return addEvent(e,this,f);}
HTMLElement.prototype.getCssProperty = function(s,r){
	if (this.currentStyle&&!_isOpera)r = this.currentStyle[s.cssPropIntoJsStyle()];
	else
	  try {
		r = document.defaultView.getComputedStyle(this,null).getPropertyValue(s);
	  } catch(e) { }
	return r; 
}
HTMLElement.prototype.getCssIntProperty = function(s,r){return isNaN(r=parseInt(this.getCssProperty(s)))?-1:r}
HTMLElement.prototype.setBgImage = function(img){this[_s].backgroundImage='url('+img+')';return this;}
HTMLElement.prototype.getBgImage = function(s){return (s=this.getCssProperty('background-image'))?s.replace(/^url\("?|"?\)$/g,''):'';}
HTMLElement.prototype.setBgColor = function(c){this[_s].backgroundColor=c;return this;}
HTMLElement.prototype.getBgColor = function(s){return this.getCssProperty('background-color');}
HTMLElement.prototype.setPosition = function(t,l){if(t!=null)this[_s].top=t+'px';if(l!=null)this[_s].left=l+'px';return this;}
HTMLElement.prototype.setDimensions = function(w,h){if(w>=0)this[_s].width=w+'px';if(h>=0)this[_s].height=h+'px';return this;}
HTMLElement.prototype.clip = function(t,r,b,l,s){s=s||'rect';this[_s].clip=s+'('+t+'px '+r+'px '+b+'px '+l+'px)';return this;}
HTMLElement.prototype.addEvent = function(e,f){return addEvent(e,this,f);}
HTMLElement.prototype.rmEvent = function(e,f){return rmEvent(this,e,f);}
String.prototype.ucFirst=function(){return this.substring(0,1).toUpperCase()+this.substring(1);}
String.prototype.cssPropIntoJsStyle = function(t,s){
	for(var i=0,a=this.match( /-[\w]/g )||0;t=a[i++]; )
		s=this.replace( /-[\w]/, t.charAt(1).toUpperCase());
	return s||this;
}
var _d=document,_E=_d.documentElement, _b=_d.body,_s='style',_di='display', _iH='innerHTML', _c='className', _pN='parentNode',_nN='nodeName', _oP='offsetParent';
_d.gTag=_d.getElementsByTagName;
_d.gId=_d.getElementById;
_d.w=_d.write;
_d.aE=_d.appendChild
_d.cE=function(t,id,clas){t=_d.createElement(t);if(id)t.id=id;if(clas)t[_c]=clas;return t;}

// fade 
var _stopFadeIn=false, _stopFadeOut=false;

var _fadeSpeed = .015*1000

HTMLElement.prototype.fadeIn = function(s,f,t){
	t=this
	t.fadeSpeed=s||_fadeSpeed;
	t.onfadeinend=f||''
	t.fadeInStep = 0
	t.setOpacity(0);
	t.fadeInInterval=setInterval(function(){
		t.setOpacity(++t.fadeInStep)
		if(t.fadeInStep>=10) { 
			t.fadeInInterval=clearInterval(t.fadeInInterval);
			if(t.onfadeinend)t.onfadeinend()
		}
	},s||_fadeSpeed);
}
HTMLElement.prototype.fadeInStop = function(){this.fadeInInterval=clearInterval(this.fadeInInterval);}
HTMLElement.prototype.fadeOutStop = function(){this.fadeOutInterval=clearInterval(this.fadeOutInterval)}
function _fadeIn(o,i,s){
	s=arguments.callee;
	if(o.stopFadeIn){setOpacity(o[_s],0);o.stopFadeIn=!1;i=20;}
	if((i|=i)>10)return(o.onfadeinend&&o.onfadeinend());
	o.setOpacity(i)
	setTimeout(function(){s(o,++i)},o.fadeSpeed||_fadeSpeed)
}
HTMLElement.prototype.fadeOut = function(s,f){
	t=this
	t.fadeSpeed=s||_fadeSpeed;
	t.onfadeoutend=f||''	
	t.fadeOutStep = 10
	t.fadeOutInterval=setInterval(function(){
		t.setOpacity(--t.fadeOutStep)
		if(t.fadeOutStep<=0) { 
			t.fadeOutInterval=clearInterval(t.fadeOutInterval);
			if(t.onfadeoutend)t.onfadeoutend()
		}
	},s||_fadeSpeed);
}
function _fadeOut(o,i,s){
	s=arguments.callee;
	if(o.stopFadeOut){setOpacity(o[_s],0);o.stopFadeOut=i=0;}
	if((i=(i==undefined?10:i))<0)return(o.onfadeoutend&&o.onfadeoutend());
	setOpacity(o[_s],i)
	setTimeout(function(){s(o,--i)},o.fadeSpeed||_fadeSpeed)
}

function setOpacity(s,i){with(s){opacity=i/10;filter='alpha(opacity='+(i*10)+')';}return s;}
HTMLElement.prototype.setOpacity=function(i){return setOpacity(this[_s],i);}

window.getSize=window.clientSize=function() {
	if (window.innerHeight >= 0) {
		return [window.innerWidth+window.pageXOffset, window.innerHeight+window.pageYOffset];
	} else if (document.documentElement) {
		E=document.documentElement
		return [E.clientWidth+E.scrollLeft,E.clientHeight+E.scrollTop]
	} else if (document.body.clientHeight >= 0) {
		E=document.body
		return [E.clientWidth+E.scrollLeft,E.clientHeight+E.scrollTop]
	} else {
		return [0, 0]
	}
}
function highlightAll(N){N.focus();N.select();}
function stopBubbling(e){
	e=e||event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

// interval registry
var _intervalRegistry = {};
function addInterval( N, F, T ) {
	_intervalRegistry[N] = setInterval( F, T );
	return _intervalRegistry[N]; 
}
function rmInterval( N ) {
	_intervalRegistry[N] = clearInterval( _intervalRegistry[N] ); 
}
