/*
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
function getEID(newD){
	return document.getElementById(newD);
}

// set or get the current display style of the div
function newdsp(newD,newV){
	if(newV==undefined){
		return newD.style.display;
	}else{
		newD.style.display=newV;
	}
}

// set or get the height of a div.
function newsh(newD,newV){
	// if you are getting the height then display must be block to return the absolute height
	if(newV==undefined){
		if(newdsp(newD)!='none'&& newdsp(newD)!=''){
			return newD.offsetHeight;
		}
		newviz = newD.style.visibility;
		//newD.style.visibility = 'hidden';
		newO = newdsp(newD);
		newdsp(newD,'block');
		newR = parseInt(newD.offsetHeight);
		newdsp(newD,newO);
		//newD.style.visibility = newviz;
		return newR;
	}else{
		newD.style.height=newV;
	}
}
/*
* Variable 'S' defines the speed of the accordian
* Variable 'T' defines the refresh rate of the accordian
*/
newS=7;
newT=10;

//Collapse Timer is triggered as a setInterval to reduce the height of the div exponentially.
function newct(newD){
	newD = getEID(newD);
	if(newsh(newD)>0){
		newV = Math.round(newsh(newD)/newD.newS);
		newV = (newV<1) ? 1 :newV ;
		newV = (newsh(newD)-newV);
		newsh(newD,newV+'px');
		//newD.style.opacity = (v/newD.maxh);
		//newD.style.filter= 'alpha(opacity='+(v*100/newD.maxh)+');';
	}else{
		newsh(newD,0);
		newdsp(newD,'none');
		clearInterval(newD.newT);
	}
}

//Expand Timer is triggered as a setInterval to increase the height of the div exponentially.
function newet(newD){
	newD = getEID(newD);
	if(newsh(newD)<newD.maxh){
		newV = Math.round((newD.maxh-newsh(newD))/newD.newS);
		newV = (newV<1) ? 1 :newV ;
		newV = (newsh(newD)+newV);
		newsh(newD,newV+'px');
		//newD.style.opacity = (v/newD.maxh);
		//newD.style.filter= 'alpha(opacity='+(v*100/newD.maxh)+');';
	}else{
		newsh(newD,newD.maxh);
		clearInterval(newD.newT);
	}
}

// Collapse Initializer
function newcl(newD){
	if(newdsp(newD)=='block'){
		clearInterval(newD.newT);
		newD.newT=setInterval('newct("'+newD.id+'")',newT);
	}
}

//Expand Initializer
function newex(newD){
	if(newdsp(newD)=='none'){
		newdsp(newD,'block');
		newD.style.height='0px';
		clearInterval(newD.newT);
		newD.newT=setInterval('newet("'+newD.id+'")',newT);
	}
}

// Removes Classname from the given div.
function newcc(newN,newV){
	newS=newN.className.split(/\s+/);
	for(newP=0;newP<newP.length;newP++){
		if(newS[p]==newV+newN.newtc){
			newS.splice(newP,1);
			newN.className=newS.join(' ');
			break;
		}
	}
}
//Accordian Initializer
function AccordianX(newD,newS,newtc){
	// get all the elements that have id as content
	newL=getEID(newD).getElementsByTagName('div');
	newC=[];
	for(newI=0;newI<newL.length;newI++){
		newH=newL[newI].id;
		if(newH.substr(newH.indexOf('-')+1,newH.length)=='accontent'){newC.push(newH);}
	}
	newsel=null;
	//then search through acheaders
	for(newI=0;newI<newL.length;newI++){
		newH=newL[newI].id;
		if(newH.substr(newH.indexOf('-')+1,newH.length)=='acheader'){
			newD=getEID(newH.substr(0,newH.indexOf('-'))+'-accontent');
			newD.style.display='none';
			newD.style.overflow='hidden';
			newD.maxh =newsh(newD);
			newD.newS=(newS==undefined)? 7 : newS;
			newH=getEID(newH);
			newH.newtc=newtc;
			newH.newC=newC;
			// set the onclick function for each acheader.
			newH.onclick = function(){
				for(newI=0;newI<this.newC.length;newI++){
					newcn=this.newC[newI];
					newN=newcn.substr(0,newcn.indexOf('-'));
					if((newN+'-acheader')==this.id){
						newex(getEID(newN+'-accontent'));
						newN=getEID(newN+'-acheader');
						newcc(newN,'__');
						newN.className=newN.className+' '+newN.newtc;
					}else{
						newcl(getEID(newN+'-accontent'));
						newcc(getEID(newN+'-acheader'),'');
					}
				}
			}
			if(newH.className.match(/selected+/)!=undefined){ newsel=newH;}
		}
	}
	if(newsel!=undefined){newsel.onclick();}
	
	var temp;
	temp=getEID('basic-accordian');
	temp.style.height='320px';
	temp.style.width='296px';
	
	//temp.style.opacity = 1;
	//temp.style.filter= 1;
	
	newex(getEID('test-accontent'));
	
}