//When the page has loaded...
$(document).ready(function() {
	
	//Fix the drop down menu mouse over action for IE 6...
	$('.IE6 #navigation li').mouseenter(function() {
		$('ul', this).css('visibility', 'visible');
	});
	
	//Fix the drop down menu mouse out action for IE 6...
	$('.IE6 #navigation li').mouseleave(function() {
		$('ul', this).css('visibility', 'hidden');
	});
	
	//Start image slideshow...
	$('#slideshow').cycle();
	
	//Menu Fixes
	$("#navigation .menu ul li:first").addClass("nav_home");
	$("#navigation .menu ul li a:last").addClass("nav_last");
	$("#navigation .menu ul li a:last").addClass("nav_last");
	$('#footer-first .menu ul li a:last').addClass("footer_last");
	
//Sidebar Form Handler - overlabel
	
(function($){
$.fn.overlabel = function() {
    this.each(function(){
        var label = $(this);
	$("#"+(this.htmlFor || label.attr('for') || "ID-NOT-FOUND"))
		.focus(function(){ label.css("text-indent", "-1000px"); })
		.blur(function(){ this.value || label.css("text-indent", "0px"); })
		.trigger("focus").trigger("blur")
		.length && 
			label.addClass("overlabel-apply");
    });
}
})(jQuery);
$("label.overlabel").overlabel();


	      $("#order").validate({ 
			rules: {
				firstName:  {required: true},
				lastName: {required: true},
				Phone: {required: true,
                        digits: true},
                altPhone: {digits:true},
				email: {required: true, 
						email: true},
				deliveryAddress: {required: true},
				deliverySuburb: {required: true},
				postCode: {required: true,
						digits:true}
	        }
	      });

		  //Order Calculator
		  
		  function calculateQuote() {
			
			var total = 0;
			$('.product-details').each(function() {
				var subtotal = parseFloat(($('.size', this).val()) * parseInt($('.quantity', this).val()) * 1.1);
				if (!isNaN(subtotal)) {
					$('.subtotal', this).val(subtotal.toFixed(2));
					total += subtotal;
				} else {
					$('.subtotal', this).val('0.00');
				}
			});
			if (total != 0) {
				$('.total').val(total.toFixed(2));
			} else {
				$('.total').val('0.00');
			}
		  }
		  
		  $('.quantity, .size').change(function () {
			
			calculateQuote();
			
		  });	

});
