var itemCount;
var itemInterval;
var oldItemNum = 0;
var currentItemNum=0;

function rotateTo(toWhat){
	$(".big_item").hide();
	switch(toWhat) {
		case "big1":
		  $("#big1").show();
		  document.getElementById("smalls").className = "select1";
		  currentItemNum = 0;
		  break;
		case "big2":
		  $("#big2").show();
		  document.getElementById("smalls").className = "select2";		  
		  currentItemNum = 1;		  
		  break;
		case "big3":
		  $("#big3").show();
		  document.getElementById("smalls").className = "select3";		  
		  currentItemNum = 3;		  
		  break;
		case "big4":
		  $("#big4").show();
		  document.getElementById("smalls").className = "select4";		  
		  currentItemNum = 4;		  
		  break;		  
		default:
		//  code to be executed if n is different from case 1 and 2
	}
	clearInterval(interval);
	interval = setInterval(rotate,4500);
}

function startRotate(){
	//alert("test");
	itemCount = $(".big_item").size(); 
	interval = setInterval(rotate,4500);
	$('.big_item').hover(function() {
		clearInterval(interval);
	}, function() {
		interval = setInterval(rotate,4500);
		rotate();
	});
}
function rotate() {
	currentItemNum = (oldItemNum + 1) % itemCount;
	var smallsPrevClass = 'select' + (oldItemNum+1);
	$("#smalls").removeClass(smallsPrevClass);
	var smallsCurrentClass = 'select' + (currentItemNum+1);
	$("#smalls").addClass(smallsCurrentClass);
	$(".big_item:eq(" + oldItemNum + ")").fadeOut("fast",function(){
		$(".big_item:eq(" + currentItemNum + ")").fadeIn("slow");
	})
	oldItemNum = currentItemNum;
}

function moveBanner() {
	var content = $("#pageWrap");
	var banner = $("#banner_meaning");
	var offsetVar  = content.offset();
	var leftPoint = offsetVar.left;
	var contentWidth = content.width();
	offsetTotal = leftPoint + contentWidth + 5;
//	alert(offsetTotal);
	banner.attr("style","left:"+offsetTotal+"px;");
//	alert("test");
	banner.show();
}

$(document).ready(function() {
	
	startRotate();

	moveBanner();

});

$(window).resize(function() {
  moveBanner();
});




