/*
File is maintained in PVCS: SCRIPTS:CWD:ISSAIC:JS
Version 1.1
*/
/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}


/*Function will toggle display of div if only id is passed, or you can specify show or hide.
		   	To toggle just pass a comma seperated list of ids:
		   		showHideDivs('one','two','three','four');
			To specify show or hide list id then use * as a token, then show or hide
				showHideDivs('one*hide','two*show','three*hide','four*show');
		*/
		function showHideDivs() {
		var element = '';
		var arrayDivFunction = '';
			for (var i=0; i<showHideDivs.arguments.length; i++) {
				if(showHideDivs.arguments[i].indexOf('*')>0){
					arrayDivFunction=showHideDivs.arguments[i].split('*');
					element = document.getElementById(arrayDivFunction[0]);
					if(arrayDivFunction[1]=='hide'){
						element.style.display = 'none';
					}else if(arrayDivFunction[1]=='show'){
						element.style.display = 'block';
					}
				}else{
					element = document.getElementById(showHideDivs.arguments[i]);
					element.style.display = (element.style.display == 'none') ? 'block' : 'none';
				}
			}
		}

/*Function will toggle display of div if only id is passed, or you can specify show or hide.
		   	To toggle just pass a comma seperated list of ids:
		   		showHideDivs('one','two','three','four');
			To specify show or hide list id then use * as a token, then show or hide
				showHideDivs('one*hide','two*show','three*hide','four*show');
		*/
		function showHideInline() {
		var element = '';
		var arrayDivFunction = '';
			for (var i=0; i<showHideInline.arguments.length; i++) {
				if(showHideInline.arguments[i].indexOf('*')>0){
					arrayDivFunction=showHideInline.arguments[i].split('*');
					element = document.getElementById(arrayDivFunction[0]);
					if(arrayDivFunction[1]=='hide'){
						element.style.display = 'none';
					}else if(arrayDivFunction[1]=='show'){
						element.style.display = 'inline';
					}
				}else{
					element = document.getElementById(showHideInline.arguments[i]);
					element.style.display = (element.style.display == 'none') ? 'inline' : 'none';
				}
			}
		}
		
/***********************************************		
// This is the primary function for the FAQ list
// This was developed by Ben Lawless with help from Rich Reano
// v0.1 beta
// June 28, 2006
***********************************************/

function faqFinder()
{

	var intDLCount = 0;
	var allDLTags = new Array(); 
	//grab all of the DL elements
	allDLTags=document.getElementsByTagName('DL');
	
	for (var x=0; x<allDLTags.length; x++) {
	//Pick out the tags with our class name
		if (allDLTags[x].className=='faqList') {
//			alert(allDLTags[x].className);
//			alert(allDLTags[x].id);
			listEnumerator(allDLTags[x].id,x);
		}//end if
	}//end for

}//end function

function listEnumerator(currentListId,listnumber)
{
	var faqQuestions = document.getElementById(currentListId).getElementsByTagName('DT');
	var faqAnswers = document.getElementById(currentListId).getElementsByTagName('DD');
	//on the current parent
	var intQuestionNumber = 1;
	for (i=0; i < faqQuestions.length; i++) {
	
		if(faqQuestions[i].className == 'expand'){
	
			//format the inner html of the dt element
			var newString = "<a href='#' id='list" + parseInt(listnumber) + "q" + parseInt(i+1) + "' onClick='toggleAnswer(this.id); return false'  title='open / close'>Q" + intQuestionNumber + ". " + faqQuestions[i].innerHTML + "</a>";
					
			faqQuestions[i].innerHTML = newString;
					
			faqQuestions[i].id = 'list' + parseInt(listnumber) + 'question' + parseInt(i+1);
		
			faqAnswers[i].id = 'list' + parseInt(listnumber) + 'answer' + parseInt(i+1);
				
			intQuestionNumber ++;	
				
		}else{
		
//			alert('no match');
			continue;
			
		}//end if
				
	}//end for
	
}//end function
	
	/* addEvent handler for IE and other browsers */
	function addEvent(elm, evType, fn, useCapture)
	{
	// addEvent and removeEvent
	// cross-browser event handling for IE5+,  NS6 and Mozilla
	// By Scott Andrew
	 if (elm.addEventListener){
	   elm.addEventListener(evType, fn, useCapture);
	   return true;
	 } else if (elm.attachEvent){
	   var r = elm.attachEvent('on'+evType, fn);
	   return r;
	 }
} 

//toggle code for open/close functionality
function toggleAnswer(answer) {
	//set temp id = to the id passed back to it which will be q#
	var tempID = answer;
	//replace q with answer so we can reference the dd answer element
	var tempID = tempID.replace('q', 'answer');
	//id the dd element (answer) is closed (not displaying), then open it (set it to display)
	if (document.getElementById(tempID).className == 'hide'){
	
		document.getElementById(tempID).className = 'show';
		//change the class of the DD
		var tempID = tempID.replace('answer', 'question');
		document.getElementById(tempID).className = 'collapse';
		
	}else{//otherwise, if it is open (displaying) close it
	
		document.getElementById(tempID).className = 'hide';
		var tempID = tempID.replace('answer', 'question');
		document.getElementById(tempID).className = 'expand';
	
	}//end if	
	
}//end function

function toggleAll(faqList){//we open all of them
	var listHead = faqList.replace('List', '');
	var blnOpen;
	if(document.getElementById(listHead).className == 'expandAll'){
		blnOpen = true;
		document.getElementById(listHead).className = 'collapseAll';
	}else{
		blnOpen = false;
		document.getElementById(listHead).className = 'expandAll'
	}//end if
	
	var faqQuestions = document.getElementById(faqList).getElementsByTagName('DT');
	var faqAnswers = document.getElementById(faqList).getElementsByTagName('DD');
  
	for (i=0; i < faqQuestions.length; i++) {
		if(blnOpen){
			faqQuestions[i].className='collapse';
			faqAnswers[i].className = 'show';
		}else{
			faqQuestions[i].className='expand';
			faqAnswers[i].className = 'hide'
		}//end if
	
		//alert(" OPEN - DT class = " + faqQuestions[i].id + " DD class = " + faqAnswers[i].id);
     
	}//end for
return false;
}//end function

function expandMaster(){//we open all of them
var allDTTags = document.getElementsByTagName('DT');  
var allDDTags=document.getElementsByTagName('DD');
	
	for (var x=0; x<allDDTags.length; x++) {
	//Pick out the tags with our class name
		if (allDDTags[x].className=='hide') {
			var tempId = 'faq'+x;
			if(document.getElementById(tempId)){
				document.getElementById(tempId).className = 'collapseAll';
			}//end if
			allDTTags[x].className='collapse'; 	
			allDDTags[x].className='show';
			
		}//end if
	}//end for

return false;
}//end function

function collapseMaster(){//we open all of them
var allDTTags = document.getElementsByTagName('DT');  
var allDDTags=document.getElementsByTagName('DD');
	
	for (var x=0; x<allDDTags.length; x++) {
	//Pick out the tags with our class name
		if (allDDTags[x].className=='show') {
			var tempId = 'faq'+x;
			if(document.getElementById(tempId)){
				document.getElementById(tempId).className = 'expandAll';
			}//end if
			allDTTags[x].className='expand'; 	
			allDDTags[x].className='hide';
			
		}//end if
	}//end for

return false;
}//end function

/* attach the wrapper function to the window's onload event */
addEvent(window,'load',faqFinder);
//addEvent(window,'load',closeAll);

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		//alert(opacStart + " > " + opacEnd);
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
