$().ready(function() {

	$('#wheelImages a').lightBox({
		overlayBgColor: '#000000',
		overlayOpacity: 0.8,
		imageLoading: '../../js/plugins/lightbox/loading.gif',
		imageBtnClose: '../../js/plugins/lightbox/close.gif',
		imageBtnPrev: '../../js/plugins/lightbox/prev.gif',
		imageBtnNext: '../../js/plugins/lightbox/next.gif',
		containerResizeSpeed: 350,
		txtImage: 'Photo',
		txtOf: 'of'
	});
	
	$("#enquiryForm").validate({
	event: "keyup",
		rules: {
			email: {
				required: true,
				email: true
			},
			name: "required",
			state: "required",
			phone: "required"
		},
	messages: {
			email: "Email address incorrect",
			name: "Name is required",
			state: "Please choose a state",
			phone: "Contact number required"
		},
	submitHandler: function(form) {
			$('input[@name=human]').val('yup');
			form.submit();
		}
	});
	
	$("#wheelCheckMake").change( function() {
		optionValue = $(this).children("option:selected").attr("value");
		if(optionValue) {
			studs = $('input[@name=wheelCheck_studs]').val();
			spacing = $('input[@name=wheelCheck_spacing]').val();
			url = '../ajax_check_wheel_fitment/make_pk/' + optionValue + '/studs/' + studs + '/spacing/' + spacing;
			$("#wheelCheckShowMakes").slideDown('slow');
			$.getJSON(url, function(json){
				$("#wheelCheckShowMakes").hide();
				count = json.length;
				if(count) {
					// Success
					var models = '<h3>Suitable models</h3><ul class="clearfix">';
					for (var i = 0; i < json.length; i++) {
						models += '<li>' + json[i].model_name + '</li>';
					}
					models += '</ul>';
				} else {
					models = '<h3>No suitable models found</h3>';
				}
			    $("#wheelCheckShowMakes").html(models);
				$("#wheelCheckShowMakes").slideDown('slow');
			});
		}
	});

});

