/************************************************************************************************************
(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 help_slideSpeed = 10;	// Higher value = faster
var help_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var help_activeId = false;
var help_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(help_slideInProgress)return;
	help_slideInProgress = true;
	
	//change any other divs back to blue
	if(help_activeId != 0){
		var oldQuestionDiv = document.getElementById('help_q' + help_activeId);
		oldQuestionDiv.style.background = 'url(/images/bkg-navRightSlideClosed.gif) no-repeat';
		oldQuestionDiv.style.color='white';
	}
	
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('help_a' + numericId);
	var questionDiv = document.getElementById('help_q' + numericId);
	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(help_activeId &&  help_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(help_activeId,(help_slideSpeed*-1));
			questionDiv.style.background='url(/images/bkg-navRightSlideOpen.gif) no-repeat';
			questionDiv.style.color='#f38028';

		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			questionDiv.style.background='url(/images/bkg-navRightSlideOpen.gif) no-repeat';
			questionDiv.style.color='#f38028';
			
			slideContent(numericId,help_slideSpeed);
		}
	}else{
		slideContent(numericId,(help_slideSpeed*-1));
		help_activeId = false;
		questionDiv.style.background='url(/images/bkg-navRightSlideClosed.gif) no-repeat';
		questionDiv.style.color='white';
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('help_a' + inputId);
	var contentObj = document.getElementById('help_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 + ')',help_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('help_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('help_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,help_slideSpeed);				
			}else{
				help_slideInProgress = false;
			}
		}else{
			help_activeId = inputId;
			help_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='help_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'help_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'help_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='help_answer_content';
			contentDiv.id = 'help_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	
}
window.onload = initShowHideDivs;