var boxr = 0;
function boxes_fn(direction){
	var boxes = $('#boxes .box');
	if (!direction){
		$('#boxes a').click(function(){
			boxes_fn($(this).attr('class'));
		});

		var boxl = 0;
		boxes.each(function(index){
			$(this).css("left", boxl);
			boxl = boxl + 321;
		});
		
		$('#boxes .boxes').css("width", $("#boxes .boxes").width());
		/*$('#boxes .box').hover(function(){
			$(this).animate({top: "-10px"});
		}, function(){
			$(this).animate({top: "0px"});
		});*/
			
		for (var i=boxr; i<boxr+3; i++)
			$(boxes[i]).css("display", "block");
		return;
	}
	
	
	$("#Burak").html(direction + ", " + boxr);
	if(direction == "prev" && boxr){
		$(boxes[boxr - 1]).fadeIn("slow");
		$(boxes[boxr + 2]).fadeOut("slow");
		$("#boxes .boxes").animate({left: $("#boxes .boxes").position().left + 321});
		boxr--;
	}
	
	if (direction == "next" && boxr <= (boxes.length - 4)){
		$(boxes[boxr]).fadeOut("slow");
		$(boxes[boxr + 3]).fadeIn("slow");
		$("#boxes .boxes").animate({left: $("#boxes .boxes").position().left - 321});
		boxr++;
	}
}


$(function(){ boxes_fn(); });


