jQuery(document).ready(function($) {
	
	$("a.current").append('<img src="/wp-content/themes/epress0.1/img/arrow.png" class="arrow" />');
	
	function autoclick() {
	setTimeout( function() {
		if (pause == 1)
		{
			return;
		}
		$(".story_button-"+i+" a").click();
		i++;
		if (i == 6) 
		{
			i = 1;
		}
		autoclick();
		}, 5000);
	}
	
	$(".story_button a").each(function() {
		$(this).click(function( event ) {
			event.preventDefault();
			var num = $(this).attr('rel');
			var pos = $(this).parent().parent().position();
			$(".story_button a").removeClass('current');
			$(this).addClass('current');
			$(".arrow").animate({top:pos.top+"px"},'fast','swing');
			$(".top_story").removeClass("top-z");
			$("#top_story-"+num).addClass("top-z");
		});
	});
	i = 2;
	pause = 0;
	
	$(".search #submit").mouseover(function() {
		$(this).css('background-position','-20px 0px');
	}).mouseout(function() {
		$(this).css('background-position','0px 0px');
	});
});