$(function(){
	
	$("#MFieldImperial").hide();
	$(".MSystemSelect").click(function(){
		if($(this).val() === "Metric"){
			$("#MFieldMetric").show();
			$("#MFieldImperial").hide();
		}
		if($(this).val() === "Imperial"){
			$("#MFieldImperial").show();
			$("#MFieldMetric").hide();
		}
	});
	
	$("#GVRedeemSuccess").hide();
	$("#GiftVoucherForm").validate({

		submitHandler:function(form){
			
			$(form).ajaxSubmit();
			
			$("#GiftVoucherForm").hide();
			$("#GVRedeemSuccess").fadeIn(2000);
		},
		errorLabelContainer: "#GVErrorContainer", wrapper: "li",
		rules:{
			VoucherNumber:{
				required:true
			},
			FullName:{
				required:true
			},
			EmailAddress:{
				email:true,
				required:true
			},
			AddressLine1:{
				required:true
			},
			AddressLine2:{
				required:true
			},
			PhoneNumber:{
				required:true,
				digits:true
			}
		},
		
		messages:{
			VoucherNumber:"Please enter your voucher number",
			FullName:"Please provide your full name",
			EmailAddress:{
				required:"Please provide your email address",
				email:"Enter a valid email address"
			},
			AddressLine1:"Please fill in 'Address Line 1'",
			AddressLine2:"Please fill in 'Address Line 2'",
			PhoneNumber:{
				required:"Please enter your phone number",
				digits:"Enter a valid phone number"
			}
		}
	});
	// http://sorgalla.com/projects/jcarousel/#Configuration
	jQuery('.PCarousel').jcarousel({
		wrap:'circular',
		scroll:4,
		animation:1100
	});
	jQuery('.PDCarousel').jcarousel({
		wrap:'circular',
		scroll:6,
		animation:700
	});
	jQuery('.PDDollysDealsCarousel').jcarousel({
		wrap:'circular',
		scroll:4,
		animation:700
	});
	jQuery('.PWhiteCollectionCarousel').jcarousel({
		wrap:'circular',
		scroll:4,
		animation:1100,
		buttonNextHTML:null,
		buttonPrevHTML:null
	});
	jQuery('.DDUnderwearCarousel').jcarousel({
		wrap:'circular',
		scroll:4,
		animation:1100,
		buttonNextHTML:null,
		buttonPrevHTML:null
	});
	
	$('a.NewWindow').click(function(){
		window.open(this.href);
		return false;
	});
});
