$(document).ready(function(){
		var country;
		
		setEverythingUp();
		
		$("select").change(function () { 
        	$("select option:selected").each(function () { 
            	moveCar($(this).val()); 
				country = $(this).text();
				country = country.replace(/\W/g, "");	
				pageTracker._setVar(country);
				changeBG('flags/' + country + '.jpg');
			});
        }) 
        .trigger('change'); 


	});
	
	$(window).resize(function(){ 
  		setEverythingUp(); 
	});
	
	function setEverythingUp() {
		var carStopY = ($(document).height() / 2) - ($("#car").height() / 2);
  		$("#road").height($(document).height());
		$("#car").animate({marginTop: carStopY}, 3000 ); 
	}
	
	function moveCar(side) {
		switch(side) {
			case "left":
				$("#what-side").text("left");
				$("#car").animate({marginLeft: "-5px"}, 1500 ); 
			break;
			default:
				$("#what-side").text("right");
				$("#car").animate({marginLeft: "355px"}, 1500 ); 
			break;
		}
	}
	
	function changeBG(img) {
		$("#car").css("backgroundImage", "url(" + img + ")");
		$("#car").css("backgroundRepeat", "no-repeat");
		$("#car").css("backgroundPosition", "73px 207px");
	}