$(document).ready(function() {

	// Cufon
	Cufon.replace('#middle h2', { fontFamily: 'ArnoProItalic' });
	
	// Navigation
	$("ul#nav li").click( function() {
		if ($(this).hasClass(':not(.active)')) {
			var number = $(this).attr("class").split("_");
			var position = (number[1]*960)-970;
			if (position > 0) { position = '-'+position-10+'px'; } else { position = 0; }
			$("#pages").animate({ left: position }, 300);
					
			$("ul#nav li").removeClass("active");
			$(this).addClass("active");
		
			var name = $(this).attr('name');
			$("#bottom_title span").fadeOut(150, function() {
				$(this).text(name);
				$(this).fadeIn(150);
			});

			if ($(this).hasClass('.page_1')) {
				$("#bottom #currency_toggle").fadeIn();
			} else {
				$("#bottom #currency_toggle").fadeOut();
			}
		}
	});
	
	// Form
	$("form input.text, form textarea").focus( function() {
		if ($(this).attr('value') == $(this).attr('name')) {
			$(this).attr('value','');
		}
	});
	$("form input.text, form textarea").blur( function() {
		if ($(this).attr('value') == "") {
			$(this).attr('value',$(this).attr("name"));
		}
	});
	
	$("form input.submit").bind('click', function(){
		$("#testform").serialize
		$.post("submit.php", $("form").serialize(), function() {
			$("form").fadeOut(function() {
				$(".thankyou").fadeIn();
			});
		});
	});
	
	// UK/US Slider
	$("#bottom #currency_toggle li.track span.slider").draggable({
		containment: 'parent',
		axis: 'x',
		snap: 'li.track',
		snapMode: 'inner',
		snapTolerance: 10,
		stop: function(event,ui) {
			if (ui.position.left > 10) {
				$("li.label.uk").removeClass('active');
				$("li.label.us").addClass('active');
				$("h4 .uk_price").fadeOut(function(){
					$("h4 .us_price").fadeIn();
					$("p .uk_price").hide();
					$("p .us_price").show();
				});
			} else {
				$("li.label.uk").addClass('active');
				$("li.label.us").removeClass('active');
				$("h4 .us_price").fadeOut(function(){
					$("h4 .uk_price").fadeIn();
					$("p .us_price").hide();
					$("p .uk_price").show();
				});
			}
		}
	});
	
	// Grid
    $(document).bind('keydown', function(e) {
        var code = (e.keyCode ? e.keyCode : e.which);
        var modifier = (e.altKey ? e.altKey : false);
		if (modifier && (code == 71)) {
			$("#guides").toggle();
		}
    });
 

	
});