// JavaScript Document
	
	var headline_count;
	var headline_interval;
	var old_headline = 0;
	var current_headline = 0;
	var run=1;
	$(document).ready(function(){
	
		if(run==1) {
		$("img.headline").css('top','180px');
		$("img.headline").css('position','absolute');
		$("img.headline").css('width','800px');
		run=0;
	}
	headline_count = $("img.headline").size();
	$("img.headline:eq("+current_headline+")").css('top','0px');
	headline_interval = setInterval(headline_rotate,6000); //time in milliseconds
	$('#headerImages').hover(function() {
	 clearInterval(headline_interval);
	}, function() {
	 headline_interval = setInterval(headline_rotate,6000); //time in milliseconds
	});
	
	for( i=0; i < headline_count; i++){
		bob = i+1;
		$('#navigator').prepend('<a href="#" onclick="scrollto('+i+');return false;">' + bob + '</a>');
		
	}
	
	});
	function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count; 
	$("img.headline:eq(" + old_headline + ")").animate({top: -180},"slow", function() {
	 $(this).css('top','180px');
	});
	$("img.headline:eq(" + current_headline + ")").show().animate({top: 0},"slow");  
	old_headline = current_headline;
	}
	function scrollto(location) {
		clearInterval(headline_interval);
	current_headline = (old_headline) % headline_count;
	
	if(location != current_headline) {
			$("img.headline:eq(" + old_headline + ")").stop(true);
			$(this).stop(true);
			$("img.headline:eq(" + location + ")").stop(true);
			
		   	$("img.headline:eq(" + old_headline + ")").animate({top: -180},"slow", function() {
			 $(this).css('top','180px');
		   });
		   $("img.headline:eq(" + location + ")").show().animate({top: 0},"slow");  
		   old_headline = location;	
	  }	
	}