var i;
var footour_count;
var top_promotion_count;
var width_nums = 4;
var current = 0;
var img_width = 155;
var offset = 0;

var global_count = 0;

function refresh(){

	num = Math.random();

	if(global_count < top_promotion_count)
		global_count++;
	else
		global_count = 0;

	$(".large_top_promotion").hide();
	$(".large_top_promotion").eq(global_count).show();

	setTimeout('refresh()', 5500);
}


$(document).ready(function(){

	top_promotion_count = $(".large_top_promotion").size() - 1;
	refresh();

	$(".large_top_promotion").click(function () { 
		document.location.href = $(this).children('h3').children('a').attr('href');
	});

	

	footour_count = $(".scrollitem").size();
	current = footour_count;

	for(i=0;i<=footour_count;i++){
			$(".scrollitem:eq("+i+")").css('left',((i*img_width)+offset)+'px');		
	}

	

		$('.scrollright').click(function() {
			
			var j;
			for(j=1;j<=width_nums;j++){
				if(current > width_nums){

					offset += -img_width;
					current--;
				}

			}

				for(i=0;i<=footour_count;i++){
					$(".scrollitem:eq("+i+")").animate({left: ((i*img_width)+offset)+'px'}, 1000);
				}

			return false;
		});

		$('.scrollleft').click(function() {

			var j;
			for(j=1;j<=width_nums;j++){
				if(current >= width_nums && current < footour_count){

					offset += img_width;
					current++;
				}

			}
				for(i=0;i<=footour_count;i++){
					$(".scrollitem:eq("+i+")").animate({left: ((i*img_width)+offset)+'px'}, 1000);		
				}

			return false;
		});


});
