$(document).ready(function(){
	$('ul#Menu li ul li').hover(
		function() { $('> ul', this).show() },
		function() { $('> ul', this).hide() }
	);
});

var OpenSlider = null;
function openSlider( DivID ) {
	/*
	 * If the current open not is the new open, set  a new open
	 */
	if ( DivID != OpenSlider ) {
		var NewOpenSlider = document.getElementById( DivID );
		if( NewOpenSlider ) {
			/*
			 * Make current tab inactive
			 */		
			if ( OpenSlider != null ) {
				
				var OldOpenSlider 		= document.getElementById( OpenSlider );
				if ( OldOpenSlider ) {
					OldOpenSlider.className 	= 'Section';
					/*
					 * Empty ActiveTab, will be set later on
					 */
					OpenSlider 					= null;
				} else {
					throw 'One of the requested objects was not found!';
				}
			}
			
			/*
			 * Make new tab active
			 */
			NewOpenSlider.className 			= 'Section Open';
			
			/*
			 * Was empty, now set new again 
			 */
			OpenSlider 							= DivID;
			
		} else {
			throw 'One of the requested objects was not found!';
		}
	} else {
		/*
		 * If the new open is the same as the open that is open, we want to close it.
		 */
		var OldOpenSlider 		= document.getElementById( OpenSlider );
		if ( OldOpenSlider ) {
			OldOpenSlider.className = 'Section';
			OpenSlider = null;
		}
	}
}


/**
 *  FAQ OPEN ? CLOSE
 * 
 */
var previousCell = null;
var previousAnchor = null;

function OpenClose(anchor, id) {
	
	var ContentObject = document.getElementById( 'Content' );
	var cell = document.getElementById( "item" + id );
	
	if ( previousCell ) {		
		var Height = parseInt( ContentObject.style.height.split("px").join("") );
		
		var CellHoeveelheid = Math.ceil( previousCell.offsetHeight / 20 );
		var CellHeight = ( CellHoeveelheid * 20 );
		
		var NewHeight = Height - CellHeight; 		
		ContentObject.style.height = NewHeight + 'px';
	}
	
	if ( cell != null ){
		
		if ( anchor.className == "Open"  ) {
			anchor.className = "Close";
			cell.style.display = "none";
		} else {
			anchor.className = "Open";
			cell.style.display = "block";
		}
		
		if ( anchor ){
			var Height = parseInt( ContentObject.style.height.split("px").join("") );

			var CellHoeveelheid = Math.ceil( cell.offsetHeight / 20 );
			var CellHeight = ( CellHoeveelheid * 20 );
			
			var NewHeight = Height + CellHeight;
			ContentObject.style.height = NewHeight + 'px';
		}

		if( previousCell != null && previousCell != cell ) previousCell.style.display = "none";
		if( previousAnchor != null && previousAnchor != anchor ) previousAnchor.className = "Close";

		previousCell = cell;
		previousAnchor = anchor;
	}
}

var OpenIndex = null;
function ToggleInfo( id ) {
	var object = document.getElementById( "item" + id );
	if ( object != null ){
		if( object.className == "InfoPopup Hide" ) {
			if( OpenIndex != null ){
				document.getElementById( "item" + OpenIndex ).className = "InfoPopup Hide";
			}
			object.className = "InfoPopup Show";
			OpenIndex = id;
		} else {
			object.className = "InfoPopup Hide";
			OpenIndex = null;
		}
	}

}

function checkTabHeights( Tab1, Tab2 ) {
	var Content_Tab1 = document.getElementById( Tab1 );
	var Content_Tab2 = document.getElementById( Tab2 );
	
	if ( Content_Tab1 && Content_Tab2 ) {
		Height = Math.max( Content_Tab1.clientHeight, Content_Tab2.clientHeight );
		
		if ( Height > 0 ) {
			Content_Tab1.style.height = Height + 'px';
			Content_Tab2.style.height = Height + 'px';
		}
	}
}
