var FAQlist;
var questions;
var answers;
var displayIndex;


//Classic DOM code here
function initFAQ(objID){

	FAQlist = document.getElementById(objID);

	questions = FAQlist.getElementsByTagName('dt');
	answers = FAQlist.getElementsByTagName('dd');

	hideAll();
	
}

function hideAll(){

	var i = 0;

	for (i=0; i < answers.length; i++){

		if(answers[i].className != 'seperator')
			answers[i].style.display = 'none';
	}	
	for (i=0; i < questions.length; i++){

		if(questions[i].className != null && questions[i].className != ""){
			questions[i].removeAttribute('class');	
			questions[i].removeAttribute('className');	
		}
	}
}

	
function displayAnswer(i){

	hideAll();		
	
	if(i != displayIndex){
		document.getElementById('faq_dd_' + i).style.display = 'block'; 
		document.getElementById('faq_dd_' + i).className = 'dd_open'; 
		document.getElementById('faq_dt_' + i).className = 'dt_open'; 
		displayIndex = i;
		return false;
	}
	else
		displayIndex = null;
}

function ImageSwap(objName, objID, title){

		var targImageObj = document.getElementById('IMS_ImageGallery_' + objName);

		var originalsrc = targImageObj.getAttribute('src');

		var idIndex = originalsrc.indexOf('id=');
		var ampIndex = originalsrc.indexOf('&');
		var imgGUID = originalsrc.substring(idIndex + 3, ampIndex);

		newsrc = originalsrc.replace(imgGUID, objID);

		//set the src alt and title attributes of the target image
		targImageObj.setAttribute("src", newsrc);
		targImageObj.setAttribute("alt", title);
		targImageObj.setAttribute("title", title);
		
		//give the image its caption
		document.getElementById('IMS_ImageTitle_' + objName).innerHTML = title;
}

function imageSelect(obj, interval){

	if(imageIndex < imageLength){
	
		ImageSwap(obj, imagesArray[imageIndex], titlesArray[imageIndex]);
		
		imageIndex ++;

		window.setTimeout('imageSelect(\'' + obj + '\', ' + interval + ')', interval);

	}
	else if(imageIndex == imageLength){

		imageIndex  = 0;
		imageSelect(obj, interval);

	}
	
}