/* fade function*/
_in = function(){
	var i = Math.ceil((this.tarOpac-(this.objct.style.opacity*100))/this.speed)+(this.objct.style.opacity*100);
	this.objct.style.opacity = i/100;
	this.objct.style.filter = 'alpha(opacity='+i+')';
	if(i >= this.tarOpac){
		clearInterval(this.fadeIn_int);
	}
}
_out = function(){
	var i = Math.floor((0 - (this.objct.style.opacity*100))/this.speed)+(this.objct.style.opacity*100);
	this.objct.style.opacity = i/100;
	this.objct.style.filter = 'alpha(opacity='+i+')';
	if(i<= 0){
		clearInterval(this.fadeOut_int);
		if(this.remove){
			this.objct.parentNode.removeChild(this.objct);	
		}
	}
}
fadeIn = function(objct, tarOpac){
	this.objct = objct;
	this.speed = 5;
	this.tarOpac = tarOpac;	
	this.objct.style.opacity = 0;
	this.objct.style.visibility = 'visible';
	this.objct.style.filter = "alpha(opacity=0)";	
	tf = this;
	this.fadeIn_int = setInterval("tf._in()", 20);
}
fadeOut = function(objct, remove){
	if(this.fadeIn_int){ clearInterval(this.fadeIn_int);}
	this.objct;
	this.speed = 3;
	tf = this;
	this.remove = remove;
	this.fadeOut_int = setInterval("tf._out()", 20);
}

/* clear default value in input */
clearInput = function(t){
	if(t.defaultValue==t.value){
		t.value = '';
	}
}
resetInput = function(t){
	if(t.value == ''){
		t.value = t.defaultValue;
	}
}
/* simple accordian */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
accordian = function(id, h_fix, padding){
	me = this;
	this.heightfix = null;
	this.toggleheight = padding ? padding : 100;
	this.obj = document.getElementById(id);
	if(this.obj){
		this.togglers = getElementsByClass('toggler', this.obj);
		this.current = this.previous = null;
		this.speed = 7;	
		for(toggle in this.togglers){
			var chld = this.togglers[toggle].nextSibling;
			while(chld.nodeType != 1){
				var chld = chld.nextSibling;
			}
			this.togglers[toggle].child = chld;
			this.heightfix = chld.scrollHeight > this.heightfix ? chld.scrollHeight : this.heightfix;
			this.toggleheight += this.togglers[toggle].scrollHeight;
			if(this.togglers[toggle].className.indexOf('default') == -1){
				this.togglers[toggle].child.style.height = 0; //this.togglers[toggle].child.scrollHeight+'px';				
			}else{
				this.togglers[toggle].child.style.height = this.togglers[toggle].child.scrollHeight+'px';
				me.current = this.togglers[toggle];
			}
			this.togglers[toggle].onclick = function(){
				void(0);
				me.check(this);
			}
			this.togglers[toggle].onmouseover = function(){
				this.className += " hover";	
			}
			this.togglers[toggle].onmouseout = function(){
				this.className = 'toggler';
			}			
		}
	}	
	if(h_fix == 'on'){
		this.obj.style.height = this.heightfix + this.toggleheight + 'px';
	}
}
accordian.prototype = {
	check:function(t){
		if(me.current != t){		
			if(me.current != null){				
				me.previous = me.current;
				ptarget = me.previous.child;
				ptarget.interval2 = setInterval('me.close(ptarget)',1);				
			}						
			me.current = t;
			ctarget = t.child
			ctarget.interval = setInterval("me.open(ctarget)",20);			
		}else{
			me.previous = t;
			ptarget = t.child;
			if(parseInt(ptarget.style.height) > 0){
				ptarget.interval2 = setInterval('me.close(ptarget)',1);
			}else{
				ptarget.interval = setInterval("me.open(ctarget)",20);
			}
		}
	},
	open:function(t){
		me.closeAll();
		targetH = t.scrollHeight;
		t.style.height ? currentH = parseInt(t.style.height) :	currentH = 0;
		i = Math.ceil((targetH - currentH)/6.364) + currentH;
		t.style.opacity = i/targetH;
		t.style.filter = 'alpha(opacity='+((i/targetH)*100)+')';
		t.style.height = i + 'px';
		if(i>=targetH){
			clearInterval(t.interval);		
		}
	},
	close:function(t){
		clearInterval(me.previous.child.interval);
		t.style.height ? currentH = parseInt(t.style.height) :	currentH = 0;
		i = Math.floor((0-currentH)/1.846)+currentH;
		t.style.opacity = i/t.scrollHeight;
		t.style.filter = 'alpha(opacity='+((i/t.scrollHeight)*100)+')';
		t.style.height = i + 'px';
		if(i<=0){
			clearInterval(t.interval2);				
		}
	},
	closeAll:function(){
		for(toggle in me.togglers){
			if(this.togglers[toggle] != me.current && this.togglers[toggle] != me.previous){
				this.togglers[toggle].child.style.height = 0;
			}
		}
	}
}