
function cxElement(sId, aAttr){
	this._sId = "";
	this._sContent = "";
	this._arrAttr = new Array();
	
	if((typeof(sId)!="undefined")){
		this._sId = sId;
	}
	
	if((typeof(aAttr)!="undefined") && aAttr.length){
		this._arrAttr = aAttr;
	}
	
	if(typeof(cxElement._initialized)=="undefined"){
	
		cxElement.prototype.setId = function(sId){
			if(sId){
				this._sId = sId;
			}
		}
		
		cxElement.prototype.getId = function(){
			return this._sId;
		}
		
		cxElement.prototype.setContent = function(sContent){
			this._sContent += sContent;
		}
		
		cxElement.prototype.getContent = function(){
			return this._sContent;
		}
		
		cxElement.prototype.getAttrStr = function(){
			var sAttrStr = "";
			for(var i=0;i<this._arrAttr.length;i++){
				sAttrStr +=  " "+this._arrAttr[i][0]+"=\""+this._arrAttr[i][1]+"\" ";
			}
			return sAttrStr;
		}
		
		cxElement.prototype.Render = function(){
			alert("cxElement::Render() must be overritten");
		}
		
		cxElement._initialized = true;
	}
}

var cxElem = new Object();
cxElem._strechInTo = null;
cxElem._strechOutTo = null;
cxElem._fadeInTo = null;
cxElem._fadeOutTo = null;
cxElem._showInTo = null;
cxElem._showOutTo = null;

cxElem.setOpacity = function(elem, opacity){
	opacity = (opacity == 100)?99.999:opacity;
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}
		if(isIE){
			el.style.filter = "alpha(opacity:"+opacity+")";
		}else{
			el.style.opacity = opacity/100;
		}
	}
}

cxElem.getOpacity = function(elem){
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}
		
		if(isIE){
			var elFilter = el.style.filter;
			if(el.style.filter.match(/alpha\(opacity:.*\)/)){
				var matches = el.style.filter.match(/alpha\(opacity:(.*)\)/);
				return matches[1];
			}else{
				return 99.9999;
			}
		}else{
			return el.style.opacity*100; 
		}
	}
}

cxElem.fadeIn = function(elem, opacity){
	if(typeof(opacity)=="undefined") opacity = 0;
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}
		if(cxElem._fadeOutTo!=null){
			window.clearTimeout(cxElem._fadeOutTo);
			cxElem._fadeOutTo = null;
		}
		el.style.visibility = "visible";
		el.style.display = "block";
		if(opacity<=100){
			cxElem.setOpacity(elem, opacity);
			opacity+=20;
			cxElem._fadeIntTo = window.setTimeout(function(){cxElem.fadeIn(elem, opacity)}, 20);
		}
	}
}

cxElem.fadeOut = function(elem, opacity){
	if(typeof(opacity)=="undefined") opacity = 80;
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}
		if(cxElem._fadeInTo!=null){
			window.clearTimeout(cxElem._fadeInTo);
			cxElem._fadeInTo = null;
		}
		if(opacity>0){
			cxElem.setOpacity(elem, opacity);
			opacity-=15;
			cxElem._fadeOutTo = window.setTimeout(function(){cxElem.fadeOut(elem, opacity)}, 50);
		}else{
			el.style.visibility = "hidden";
			el.style.display = "none";
		}
	}
}

cxElem.strechIn = function(elem, height){
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}

		if(cxElem._strechOutTo!=null){
			window.clearInterval(cxElem._strechOutTo);
			cxElem._strechOutTo = null;
		}
		el.style.display = "block";
		el.style.overflow = "hidden";
		el.style.visibility = "visible";
		if(typeof(height)=="undefined") {
			if(el.style.height==''||parseInt(el.style.height)==0){
				height = 0;
			}else{
				height = el.clientHeight;
			}
		}
		if(height>=el.scrollHeight){
			el.style.height = el.scrollHeight;
		}else{
			height+=5;
			el.style.height = height;
			this._strechInTo = window.setTimeout(function(){cxElem.strechIn(elem, height)}, 1);
		}
	}
}

cxElem.strechOut = function(elem, height){
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}
		if(cxElem._strechInTo!=null){
			window.clearTimeout(cxElem._strechInTo);
			cxElem._strechInTo = null;
		}
		if(typeof(height)=="undefined") height = el.clientHeight;
		if(height<=0){
			//el.style.visibility = "hidden";
			el.style.display = "none";
			//el.style.height = "0px";
		}else{
			height-=5;
			if(height<0) {
				el.style.visibility = "hidden";
				el.style.display = "none";
				el.style.height = "0px";
				return;
			}
			el.style.height = height;
			cxElem._strechOutTo = window.setTimeout(function(){cxElem.strechOut(elem, height)}, 1);
		}
	}
}

cxElem.showIn = function(elem, opacity, height){
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}

		if(cxElem._showOutTo!=null){
			window.clearInterval(cxElem._showOutTo);
			cxElem._showOutTo = null;
		}
		el.style.display = "block";
		el.style.overflow = "hidden";
		el.style.visibility = "visible";

		var heightInc = parseInt(parseInt(el.scrollHeight)/20);
		if(typeof(height)=="undefined") {
			if(el.style.height==''||parseInt(el.style.height)==0){
				height = 0;
			}else{
				height = el.clientHeight;
			}
		}
		if(typeof(opacity)=="undefined") opacity = 0;
		if(height>=el.scrollHeight){
			el.style.height = el.scrollHeight;
			cxElem.setOpacity(elem, 100);
		}else{
			if(opacity<=100){
				cxElem.setOpacity(elem, opacity);
				opacity+=5;
			}

			height+=heightInc;
			el.style.height = height;
			this._showInTo = window.setTimeout(function(){cxElem.showIn(elem, opacity, height)}, 1);
		}
	}
}

cxElem.showOut = function(elem, opacity, height, heightDec){
	var el = null;
	if(typeof(elem)!="undefined"){
		if($type(elem)=="element"){
			el = elem;
		}else{
			el = $(elem)
		}

		if(cxElem._showInTo!=null){
			window.clearTimeout(cxElem._showInTo);
			cxElem._showInTo = null;
		}
		
		if(typeof(height)=="undefined") {
			heightDec = parseInt(parseInt(el.clientHeight)/20);
			height = el.clientHeight;
		}
		if(typeof(opacity)=="undefined") opacity = 100;
		if(height<=0){
			cxElem.setOpacity(elem, 0);
			el.style.height = "0px";
			el.style.visibility = "hidden";
			el.style.display = "none";

			el.style.visibility = "hidden";
			el.style.display = "none";
		}else{
			el.style.height = height;
			cxElem.setOpacity(elem, opacity);
			opacity-=5;
			height-=heightDec;
			cxElem._showOutTo = window.setTimeout(function(){cxElem.showOut(elem, opacity, height, heightDec)}, 1);
		}
	}
}
