var currentBigScroll = 0;





function autoPlay()
{

		nextBig(true);
	
}

function autoPlaySmall()
{

		nextSmall(true);

}

function nextBig(autoPlay)
{
	if(currentBigScroll < 4)	
		scrollToBig(currentBigScroll + 1,autoPlay);
		return false;
	
}

function prevBig(autoPlay)
{
	if(currentBigScroll > -1)	
		scrollToBig(currentBigScroll - 1,autoPlay);
	
		return false;
}

function updateBigControl(target)
{
for(i = 0; i < 4; i++)
	{
		$('#bigControl'+i).addClass('hover');
		$('#bigControl'+i).attr('src',  $('#bigControl'+i).attr('src').replace('02','01'));
	}
	if($('#bigControl'+target).length > 0){
	$('#bigControl'+target).attr('src',  $('#bigControl'+target).attr('src').replace('01','02'));
	$('#bigControl'+target).removeClass('hover');
	}else{
	$('#bigControl3').attr('src',  $('#bigControl3').attr('src').replace('01','02'));
	$('#bigControl3').removeClass('hover');
	}
}

var afterAnimationFix = function(element)
{
	
	if(currentBigScroll > 3)
	{
		$('#bigSlider').animate({"marginLeft": "-800px"}, 0);
		currentBigScroll = 0;
	}
	
	if(currentBigScroll < 0)
	{
		$('#bigSlider').animate({"marginLeft": "-3200px"}, 0);
		currentBigScroll = 3;
	}
	
}

function scrollToBig(target,autoPlay)
{
	updateBigControl(target % 4);
	
	if(!autoPlay)
		clearInterval(timer);
	currentBigScroll = target;
	var value = target * -800 - 800;
	$('#bigSlider').animate({"marginLeft": value+"px"}, "slow",afterAnimationFix);
	return false;
}

var currentSmallScroll = 0;

function nextSmall(autoPlay)
{
	if(currentSmallScroll < 5)
		scrollToSmall(currentSmallScroll + 1,autoPlay);
	return false;
}

function prevSmall(autoPlay)
{
	if(currentSmallScroll > -1)
		scrollToSmall(currentSmallScroll - 1,autoPlay);
		return false;
}

var afterAnimationFixSmall = function(element)
{
	
	if(currentSmallScroll > 4)
	{
		$('#smallSlider').animate({"marginLeft": "-456"}, 0);
		currentSmallScroll = 0;
	}
	
	if(currentSmallScroll < 0)
	{
		$('#smallSlider').animate({"marginLeft": "-1824px"}, 0);
		currentSmallScroll = 4;
	}
	
}

function updateSmallControl(target)
{
	for(i = 0; i < 5; i++)
	{
		$('#smallControl'+i).addClass('hover');
		$('#smallControl'+i).attr('src',  $('#smallControl'+i).attr('src').replace('02','01'));
	}

	if($('#smallControl'+target).length > 0){
	$('#smallControl'+target).attr('src',  $('#smallControl'+target).attr('src').replace('01','02'));
	$('#smallControl'+target).removeClass('hover');
	}else{
	$('#smallControl3').attr('src',  $('#smallControl3').attr('src').replace('01','02'));
	$('#smallControl3').removeClass('hover');
	}
}

function scrollToSmall(target,autoPlay)
	{
	updateSmallControl(target % 5);
	if(!autoPlay)
		clearInterval(smallTimer);
	currentSmallScroll = target;
	var value = target * -456 - 456;
	$('#smallSlider').animate({"marginLeft": value+"px"}, "slow",afterAnimationFixSmall);
	return false;
}




$(document).ready(function() {
 $(".right-tab").hover(
 function right(){
 $(this).animate({ left: "0" }, {queue:false, duration:"normal"} );
 },
 function right(){
 $(this).animate({ left: "-170" }, {queue:false, duration:"normal"} );
 });
 


$('.hover').hover(
 function right(){
 if($(this).attr('class') == 'hover')
 $(this).attr('src',  $(this).attr('src').replace('01','02'));
 },
 function right(){
 if($(this).attr('class') == 'hover')
 $(this).attr('src',  $(this).attr('src').replace('02','01'));
 });
});

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


