var box_slideSpeed = 15;	// Higher value = faster
var box_timer = 5;	// Lower value = faster

			var objectIdToSlideDown = false;
			var box_activeId = false;
			var box_slideInProgress = true;
			function showHideContent(e,inputId)
			{
				if(box_slideInProgress)return;
				box_slideInProgress = true;
				if(!inputId)inputId = this.id;
				inputId = inputId + '';
				var numericId = inputId.replace(/[^0-9]/g,'');
				var answerDiv = document.getElementById('box_a' + numericId);

			objectIdToSlideDown = false;
	
			if(!answerDiv.style.display || answerDiv.style.display=='none'){		
			if(box_activeId &&  box_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(box_activeId,(box_slideSpeed*-1));
			}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,box_slideSpeed);
			}
			}else{
			slideContent(numericId,(box_slideSpeed*-1));
			box_activeId = false;
			}	
			}

			function slideContent(inputId,direction)
			{
	
		var obj =document.getElementById('box_a' + inputId);
		var contentObj = document.getElementById('box_ac' + inputId);
		height = obj.clientHeight;
		if(height==0)height = obj.offsetHeight;
		height = height + direction;
		rerunFunction = true;
		if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
		}
		if(height<=1){
		height = 1;
		rerunFunction = false;
		}

		obj.style.height = height + 'px';
		var topPos = height - contentObj.offsetHeight;
		if(topPos>0)topPos=0;
		contentObj.style.top = topPos + 'px';
		if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',box_timer);
		}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('box_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('box_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,box_slideSpeed);				
			}else{
				box_slideInProgress = false;
			}
		}else{
			box_activeId = inputId;
			box_slideInProgress = false;
		}
		}
		}



		function initShowHideDivs()
		{
		var divs = document.getElementsByTagName('DIV');
		var divCounter = 1;
		for(var no=0;no<divs.length;no++){
		if(divs[no].className=='topbox'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'box_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'box_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			//contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='bottombox_content';
			contentDiv.id = 'box_ac' + divCounter;

			divCounter++;
		}		
		}	
		}
		window.onload = initShowHideDivs;
		
function changeBgImage (image, that) {
	var box = that.firstChild;
	while (box.className != "topbox")
		box = box.nextSibling;
		
	//box.style.backgroundImage='url('+image+')';
	//box.style.backgroundRepeat = 'no-repeat';
	//box.style.backgroundPosition = 'right';
}

