
var curHomeImage = 1; 
var oldHomeImage = 0; 
var frontImageCount = 0; 
var newImage = {}; 
var oldImage = {}; 
var speed = 5000;

frontPageSlideshow = function(){ 

	frontImageCount =  ($('#frontPageSlideShow #homeImageWrapper img').length); 
	if($('#frontPageSlideShow .imgCount').length){  
		$('#frontPageSlideShow .imgCount').html("Showing "+curHomeImage+" of "+frontImageCount);
	} 
	firstImage = $('#homeImageWrapper img.first'); 
	//height = parseInt(firstImage.height()) + parseInt(firstImage.css('margin-top').substr(0,firstImage.css('margin-top').indexOf('px'))) + parseInt(firstImage.css('margin-bottom').substr(0,firstImage.css('margin-bottom').indexOf('px'))); 
	height = 456 + parseInt(firstImage.css('margin-top').substr(0,firstImage.css('margin-top').indexOf('px'))) + parseInt(firstImage.css('margin-bottom').substr(0,firstImage.css('margin-bottom').indexOf('px'))); 
	$('#homeImageWrapper').height(height); 
	if(frontImageCount > 1){
	setInterval(function(){ rotateCurHomeImage(); }, speed); 
	}
}
fadeOutOldImage = function(){ oldImage.fadeOut("slow");	 }
rotateCurHomeImage = function(){ 

	oldHomeImage = curHomeImage;
	curHomeImage++;  

	/* alert(oldHomeImage); */ 

		oldImage = $('#homeImageWrapper img#img'+oldHomeImage); 
		oldImage.css("z-index","98"); 
		if(curHomeImage > frontImageCount){ curHomeImage = 1;  }

		/ * alert(curHomeImage+' - '+oldHomeImage); */ 
		newImage = $('#homeImageWrapper img#img'+curHomeImage); 
		newImage.css("z-index","99"); 
		newImage.fadeIn("slow",function(){ fadeOutOldImage(); });  
		$('.imgCount').html("Showing "+curHomeImage+" of "+frontImageCount); 
}

