function switchCase( sVar ){
	
	// Does the show & hide for the cases on home

	var caseItem = $(".box-cases div.case-item:eq(" + (sVar) + ")");
	var caseItemOther = $(".box-cases div.case-item:not(" + (sVar) + ")");
	
	var navItem = $(".box-cases .case-navigation li:eq(" + (sVar) + ")");
	var navItemOther = $(".box-cases .case-navigation li:not(" + (sVar) + ")");
	
	// Hide other cases, show the active one
	caseItemOther.hide();
	caseItem.show();
	
	// Change the active and inactive navigation items styles
	$("a", navItemOther).removeClass('active');
	$("a", navItem).addClass('active');
		
};


function buildCaseNav(){
	
	// Builds a <li>-listing
	// based upon the number of DIV's with class 'case-item' in 'DIV.box-cases'

	var sHTML = '';
	var sElm = $(".box-cases");
	var sElmCount = $(".box-cases > div.case-item").length;
	var sListing = '';
	
	// When there are cases found
	if( sElmCount > 0 ){
		for( var i = 0; i < sElmCount; i++ ){
			var sClass = (i == 0) ? 'active' : ''; // Give the <a> in the first <li> the class 'active'
			sListing += '<li><a href="javascript:;" onclick="switchCase(\'' + i + '\')" class="' + sClass + '">' + (i + 1) + '</a></li>';
		}
	
		// Set the navigation container structure	
		sHTML += '<div class="case-navigation">';
		sHTML += '<ul>';
		sHTML += sListing;
		sHTML += '</ul>';
		sHTML += '</div>';
						
		sElm.append( sHTML );
		sElm.prepend( '<div class="photo-overlay"></div>' );
		
		// Make photo overlay	clickable
		// Use the HREF-property of the active case
		$(".photo-overlay").click( function(){
			//$("div.case-item:visible p:first a", sElm).attr('href');
			document.location.href = $("div.case-item:visible p:first a", sElm).attr('href');
		});
		
		// Set the first case-item visible
		var sFirstCase = $(".box-cases .case-item:eq(0)").show();
		
		// Add see-more-link to the cases box
		sElm.append( '<a href="wm.cgi?id=265" class="fl">Bekijk alle referenties</a>' );
	}
	
};


/*
// DOM ready - Execute onLoad scripts
*/ 
$(document).ready(function(){
	
	if( $(".home").length > 0 ) buildCaseNav();

});