var contact_slideSpeed = 10;	// Higher value = faster
var contact_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var contact_activeId = false;
var contact_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(contact_slideInProgress)return;
	contact_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var infoDiv = document.getElementById('contact_a' + numericId);

	objectIdToSlideDown = false;
	
	if(!infoDiv.style.display || infoDiv.style.display=='none'){		
		if(contact_activeId &&  contact_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(contact_activeId,(contact_slideSpeed*-1));
		}else{
			
			infoDiv.style.display='block';
			infoDiv.style.visibility = 'visible';
			
			slideContent(numericId,contact_slideSpeed);
		}
	}else{
		slideContent(numericId,(contact_slideSpeed*-1));
		contact_activeId = false;
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('contact_a' + inputId);
	var contentObj = document.getElementById('contact_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 + ')',contact_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('contact_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('contact_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,contact_slideSpeed);				
			}else{
				contact_slideInProgress = false;
			}
		}else{
			contact_activeId = inputId;
			contact_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='contact_naam'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'contact_q'+divCounter;
			var info = divs[no].nextSibling;
			while(info && info.tagName!='DIV'){
				info = info.nextSibling;
			}
			info.id = 'contact_a'+divCounter;	
			contentDiv = info.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='contact_info_content';
			contentDiv.id = 'contact_ac' + divCounter;
			info.style.display='none';
			info.style.height='1px';
			divCounter++;
		}		
	}	
}
window.onload = initShowHideDivs;


