
/************************************************************************************************************
(C) www.dhtmlgoodies.com, November 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/

var dhtmlgoodies_slideSpeed_bfn = 300;	// Higher value = faster
var dhtmlgoodies_timer_bfn =1;	// Lower value = faster

var objectIdToSlideDown_bfn = 1;
var dhtmlgoodies_activeId_bfn = false;
var dhtmlgoodies_slideInProgress_bfn = false;
function showHideContent_bfn(e,inputId)
{
	if(dhtmlgoodies_slideInProgress_bfn)return;
	dhtmlgoodies_slideInProgress_bfn = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_bfn_a' + numericId);

	objectIdToSlideDown_bfn = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(dhtmlgoodies_activeId_bfn &&  dhtmlgoodies_activeId_bfn!=numericId){			
			//alert(document.getElementById(inputId))
			//document.getElementById(inputId).className='dhtmlgoodies_question_active_sub';

			objectIdToSlideDown_bfn = numericId;
			slideContent_bfn(dhtmlgoodies_activeId_bfn,(dhtmlgoodies_slideSpeed_bfn*-1));
		}else{
			//alert(document.getElementById(inputId))
			//document.getElementById(inputId).className='dhtmlgoodies_bfn_question_active';
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent_bfn(numericId,dhtmlgoodies_slideSpeed_bfn);
		}
	}else{
		slideContent_bfn(numericId,(dhtmlgoodies_slideSpeed_bfn*-1));
		dhtmlgoodies_activeId_bfn = false;
	}	
}

function slideContent_bfn(inputId,direction)
{
	
	if(direction==-10)
	{
	document.getElementById('dhtmlgoodies_bfn_q'+inputId).className='dhtmlgoodies_bfn_question';
	}
	var obj =document.getElementById('dhtmlgoodies_bfn_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_bfn_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_bfn(' + inputId + ',' + direction + ')',dhtmlgoodies_timer_bfn);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown_bfn && objectIdToSlideDown_bfn!=inputId){
				document.getElementById('dhtmlgoodies_bfn_a' + objectIdToSlideDown_bfn).style.display='block';
				document.getElementById('dhtmlgoodies_bfn_a' + objectIdToSlideDown_bfn).style.visibility='visible';
				slideContent_bfn(objectIdToSlideDown_bfn,dhtmlgoodies_slideSpeed_bfn);				
			}else{
				dhtmlgoodies_slideInProgress_bfn = false;
			}
		}else{
			dhtmlgoodies_activeId_bfn = inputId;
			dhtmlgoodies_slideInProgress_bfn = false;
		}
	}
}



function initShowHideDivs_bfn()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dhtmlgoodies_bfn_question'){
			divs[no].onclick = showHideContent_bfn;
			divs[no].id = 'dhtmlgoodies_bfn_q'+divCounter;
			
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_bfn_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='dhtmlgoodies_bfn_answer_content';
			contentDiv.id = 'dhtmlgoodies_bfn_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	
	showHideContent_bfn(false,1)
}
// JavaScript Document
