
var footerLinks_slideSpeed = 10;	// Higher value = faster
var footerLinks_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var footerLinks_activeId = false;
var footerLinks_slideInProgress = false;
var footerLinks_slideInProgress = false;
var footerLinks_expandMultiple = false; // true if you want to be able to have multiple items expanded at the same time.

function showHideContent(e,inputId)
{
	if(footerLinks_slideInProgress)return;
	footerLinks_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var OpenDiv = document.getElementById('footerLinks_a' + numericId);

	objectIdToSlideDown = false;

	if(!OpenDiv.style.display || OpenDiv.style.display=='none'){
		if(footerLinks_activeId &&  footerLinks_activeId!=numericId && !footerLinks_expandMultiple){
			objectIdToSlideDown = numericId;
			slideContent(footerLinks_activeId,(footerLinks_slideSpeed*-1));
		}else{
             setCookie("FOOTER_MENU_STATE", "open");
			OpenDiv.style.display='block';
			OpenDiv.style.visibility = 'visible';
            document.getElementById('imgFooterPanel').src = 'images/Brands/GENERIC/btn_footerPnlUp.gif';
			slideContent(numericId,footerLinks_slideSpeed);
		}
	}else{
	    setCookie("FOOTER_MENU_STATE", "closed");
		slideContent(numericId,(footerLinks_slideSpeed*-1));
		document.getElementById('imgFooterPanel').src = 'images/Brands/GENERIC/btn_footerPnlDown.gif';
		footerLinks_activeId = false;
	}
}

function slideContent(inputId,direction)
{

	var obj =document.getElementById('footerLinks_a' + inputId);
	var contentObj = document.getElementById('footerLinks_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 + ')',footerLinks_timer);
	}else{
		if(height<=1){
			obj.style.display='none';
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('footerLinks_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('footerLinks_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,footerLinks_slideSpeed);
			}else{
				footerLinks_slideInProgress = false;
			}
		}else{
			footerLinks_activeId = inputId;
			footerLinks_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
    var footerMenuState = getCookie("FOOTER_MENU_STATE");
    if (footerMenuState == null) footerMenuState = "open";
    
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='footerLinks_Closed'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'footerLinks_q'+divCounter;
			var Open = divs[no].nextSibling;
			while(Open && Open.tagName!='DIV'){
				Open = Open.nextSibling;
			}
			Open.id = 'footerLinks_a'+divCounter;
			contentDiv = Open.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
			contentDiv.className='footerLinks_Open_content';
			contentDiv.id = 'footerLinks_ac' + divCounter;
			Open.style.display='none';
			Open.style.height='1px';
			if (footerMenuState == "open")
			{
			    initiallyOpen = true;
			}
			else
			{
			   initiallyOpen = false;
			}
			divCounter++;
		}
	}
	if (initiallyOpen) 
	{
	    showHideContent(null, 'footerLinks_q1');
	}
}
window.onload = initShowHideDivs;
