

	var total = 3;
	var smalltotal = 3;

	$().ready(function() {
		total--;
		$("#container5").append("<ul id='slideshow'><li><img src='/images/newhp_02.jpg' /></li><li><img src='/images/newhp_03.jpg' /></li><li><img src='/images/newhp_01.jpg' /></li></ul>");
		homepagerotatorsetup();
	});
	
	function homepagerotatorsetup(){
		 $('#slideshow').children('li').each( function (i) {
			  $(this).css({'zIndex': 14-i});
		 });
		theloop();
	}
	
	function theloop() {
		var whichisactive = 1;
		var smallactive = 1;
		$('#slideshow').children('li:eq('+ whichisactive +')').animate({'opacity': '1'}, 1300);
		$('.header-overlay').delay(1500).animate({'opacity': '1'}, 1300);
		thehomepageloop = setInterval (function(){
			var me = $('#slideshow').children('li:eq('+ whichisactive +')');
			$('#slideshow').children('li:eq('+ whichisactive +')').delay(1000).animate({'opacity': '0'}, 1300);
			if (whichisactive < total)
				whichisactive++;
			else
				whichisactive = 0;
			$('#slideshow').children('li:eq('+ whichisactive +')').delay(1000).animate({'opacity': '1'}, 1300);
			
			// top image
			$('.header-overlay').animate({'opacity': '0'}, 1300, function() {
				if (smallactive < smalltotal)
					smallactive++;
				else
					smallactive = 1;
				var src = "/images/newhp_0" + smallactive + "_overlay.jpg";
				$('.header-overlay img').attr("src", src);
				$('.header-overlay').delay(1500).animate({'opacity': '1'}, 1300);
			});
		
		}, 8500); //thehomepageloop
	} //theloop
