// Internet Strateges (UK) Ltd 
// Clerk Maxwell Home Header Scroller > Developed by Gary Pacitti

$(document).ready(function() {
	$arl = $(".headertitles > li").length;
	$currentheader=1;
	
	// Set Idents
	var x = 0; // Counter
	var idents =  ''; // Default Ident Var
	// Loop Through Total Children and Set Idents
	while (x<$arl) {
		// Build Idents
		if(x!=0) {
			idents = idents+('<div class="homeId" id="homeId'+x+'"></div>');
		}
		x++
	}
	// Now add first Item to the Start, add Sel class.  This makes the Ident loop go in correct order
	idents = ('<div class="homeId homeIdSel" id="homeId0"></div>')+idents;
	//alert(idents);
	// Write out the Idents on the page
	//document.getElementById("homeIdent").innerHTML = idents;
	
 	// Set Interval Timer Function
	function myInterval() {
		setInterval( "showheaders()", 3500 );
	}
	//showheaders();
	myInterval(); // Run the Interval Function
});

function showheaders(){
	// Show > Hide
	$(".headertitles").children('li').eq($currentheader-1).fadeOut(800, function() {
		// Show Current
		$(".headertitles").children('li').eq($currentheader).fadeIn(800);																				  
		// Set Ident
		//$(".homeId").removeClass('homeIdSel'); // Remove
		//$("#homeId"+$currentheader).addClass('homeIdSel'); // Add Selected
		//alert('Current > '+$currentheader+'      |      Previous > '+($currentheader-1));
		// Increment
		$currentheader++;
	});

		// Reset Increment if Required
	if($currentheader==$arl){
		$currentheader=0;
	}
}


