/*
DezinerFolio.com Simple Accordians.

Author  : G.S.Navin Raj Kumar
Website : http://dezinerfolio.com

*/

/*
* The Variable names have been compressed to achive a higher level of compression.
*/

// Prototype Method to get the element based on ID

// set or get the current display style of the div
function dsp2(d2,v){
	if(v==undefined){
		return d2.style.display;
	}else{
		d2.style.display=v;
	}
}

// set or get the height of a div.
function sh2(d2,v){
	// if you are getting the height then display must be block to return the absolute height
	if(v==undefined){
		if(dsp2(d2)!='none'&& dsp2(d2)!=''){
			return d2.offsetHeight;
		}
		viz = d2.style.visibility;
		d2.style.visibility = 'hidden';
		o = dsp2(d2);
		dsp2(d2,'block');
		r = parseInt(d2.offsetHeight);
		dsp2(d2,o);
		d2.style.visibility = viz;
		return r;
	}else{
		d2.style.height=v;
	}
}
/*
* Variable 'S' defines the speed of the accordian
* Variable 'T' defines the refresh rate of the accordian
*/
s=7;
t=10;

//Collapse Timer is triggered as a setInterval to reduce the height of the div exponentially.
function ct2(d2){
	d2 = $(d2);
	if(sh2(d2)>0){
		v = Math.round(sh2(d2)/d2.s);
		v = (v<1) ? 1 :v ;
		v = (sh2(d2)-v);
		sh2(d2,v+'px');
		d2.style.opacity = (v/d2.maxh);
		d2.style.filter= 'alpha(opacity='+(v*100/d2.maxh)+');';
	}else{
		sh2(d2,0);
		dsp2(d2,'none');
		clearInterval(d2.t);
	}
}

//Expand Timer is triggered as a setInterval to increase the height of the div exponentially.
function et2(d2){
	d2 = $(d2);
	if(sh2(d2)<d2.maxh){
		v = Math.round((d2.maxh-sh2(d2))/d2.s);
		v = (v<1) ? 1 :v ;
		v = (sh2(d2)+v);
		sh2(d2,v+'px');
		d2.style.opacity = (v/d2.maxh);
		d2.style.filter= 'alpha(opacity='+(v*100/d2.maxh)+');';
	}else{
		sh2(d2,d2.maxh);
		clearInterval(d2.t);
	}
}

// Collapse Initializer
function cl2(d2){
	if(dsp2(d2)=='block'){
		clearInterval(d2.t);
		d2.t=setInterval('ct2("'+d2.id+'")',t);
	}
}

//Expand Initializer
function ex2(d2){
	if(dsp2(d2)=='none'){
		dsp2(d2,'block');
		d2.style.height='0px';
		clearInterval(d2.t);
		d2.t=setInterval('et2("'+d2.id+'")',t);
	}
}

// Removes Classname from the given div.
function cc2(n,v){
	s=n.className.split(/\s+/);
	for(p=0;p<s.length;p++){
		if(s[p]==v+n.tc){
			s.splice(p,1);
			n.className=s.join(' ');
			break;
		}
	}
}
//Accordian Initializer
function Accordian2(d2,s,tc){
	// get all the elements that have id as content
	l=$(d2).getElementsByTagName('div');
	c=[];
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='content2'){c.push(h);}
	}
	sel=null;
	//then search through headers
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='header2'){
			d2=$(h.substr(0,h.indexOf('-'))+'-content2');
			d2.style.display='none';
			d2.style.overflow='hidden';
			d2.maxh =sh2(d2);
			d2.s=(s==undefined)? 7 : s;
			h=$(h);
			h.tc=tc;
			h.c=c;
			// set the onclick function for each header.
			h.onclick = function(){
				for(i=0;i<this.c.length;i++){
					cn=this.c[i];
					n=cn.substr(0,cn.indexOf('-'));
					if((n+'-header2')==this.id){
						ex2($(n+'-content2'));
						n=$(n+'-header2');
						cc2(n,'__');
						n.className=n.className+' '+n.tc;
					}else{
						cl2($(n+'-content2'));
						cc2($(n+'-header2'),'');
					}
				}
			}
			if(h.className.match(/selected+/)!=undefined){ sel=h;}
		}
	}
	if(sel!=undefined){sel.onclick();}
}