$(document).ready(function(){
	var timer = 0;
	var disable = 0;
	$("#habercount li:first").addClass("selected");
	jQuery.easing.def = "easeOutQuad";
	$.preload( ['haberbg.png'], {
		base:'images/',
		onFinish:function( data ){
			startanim();
		}
	});


	function startanim(){
		$("#haberlercont").animate({height:"137px"},1000,function(){
			timer=setInterval(sh,4000);
		});
}

function sh(){
	disable = 1;
	$(".selected").addClass("goout");
	if ($(".selected").next().html()){
		$(".selected").next().addClass("selected");
	}
	else
		$("#habercount li:first").addClass("selected");
		$(".goout").removeClass("goout selected");

	$(".haber:first").animate({opacity:"0",height:"0px"},1000,function(){

		$(".haber:first").appendTo("#haberler");
		$(".haber:last").css("opacity","100");
		$(".haber:last").css("height","104px");
		disable = 0;
	});

}

$("#habercount li").css("cursor","pointer");

$("#habercount li").click(function(){
	if (disable == 0){
		clearInterval(timer);
		timer=setInterval(sh,4000);
		var selno = $(".selected").html();
		var thisno = $(this).html();
		var times = thisno - selno;
		if (thisno < selno){
			times = 5 - selno - (-thisno);
		}
	
		for(i=0;i<times;i++)
		{
			$(".haber:first").appendTo("#haberler");
		}
	
		$("#habercount li").removeClass("selected");
		$(this).addClass("selected");
	}
});

});

