// JavaScript Document

function switchMenu(targetId, imgSrc)
{
	$("#"+targetId+"").css('background','url(library/images/menu/'+imgSrc+'.jpg) no-repeat left');
}

function setLocation(url)
{
	window.location.href = url;
}

function animatePreview(num)
{
	littleTruckAnime();
	var speed = 1000;
	if(num != 1)
	{
		$('#home_preview_1').animate({opacity: 0},speed, function(){
			$('#home_preview_1').animate({width: 'toggle'},speed, function(){
				$('#home_preview_sep_1').animate({width: 'toggle'},speed/2);
			})
		});
	}
	
	if(num != 2)
	{
		$('#home_preview_2').animate({opacity: 0},speed, function(){
			$('#home_preview_2').animate({width: 'toggle'},speed, function(){
				$('#home_preview_sep_2').animate({width: 'toggle'},speed/2);
			})
		});
	}
	
	if(num != 3)
	{
		$('#home_preview_3').animate({opacity: 0},speed, function(){
			$('#home_preview_3').animate({width: 'toggle'},speed, function(){
				$('#home_preview_sep_3').animate({width: 'toggle'},speed/2);
			})
		});
	}
	
	if(num != 4)
	{
		$('#home_preview_4').animate({opacity: 0},speed, function(){
			$('#home_preview_4').animate({width: 'toggle'},speed, function(){
				
			})
		});
	}
}

function littleTruckAnime()
{
	var truckW = $('#littleTruck').css('width');
	truckW = truckW.split('px');
	truckW = truckW[0];
	var trackW = $('#truck_track').css('width');
	trackW = trackW.split('px');
	trackW = trackW[0];
	
	var trackLen = trackW-truckW;
	
	$('#littleTruck').fadeIn(300, function(){
		$('#littleTruck').animate({left: trackLen+'px' }, 4000, function(){
			$('#littleTruck').fadeOut(300);
		})
	});
}
