$(document).ready(function() {                
	
	
	/*email protect*/
	$("span.mailto").each(function(){
		exp = $(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
		match = exp.exec($(this).text());
		addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
		link = match[2] ? match[2] : addr;
		subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
		$(this).after('<a href="mailto:'+addr+subject+'">'+ link + '</a>');
		$(this).remove();
	});    




	 $('#slideshow').cycle({fx: 'fade', timeout: 5000, speed: 2000});
	
	  $("ul li a img").hover(function () {
	    $(this).fadeTo("slow", 0.50);
	    $(this).fadeTo("fast", 0.90);
	  });

		$('form#contact-form').validate(); 
		

    $("#orderform").submit(function() {
 		  popup_creditcard();
		  return true;
     });
	
	
	
		$('form#checkout-form').validate({

	    // tell the validation plugin to check the following inputs
			// documentation: http://docs.jquery.com/Plugins/Validation
	    rules: {
	      // BILLING
	      Billing_FirstName: "required",
	      Billing_Surname: "required",
	      Billing_Phone: {required: true, digits: true},
			  Billing_Email: {required: true, email: true},
	      Billing_Address1: "required",
	      Billing_Suburb: "required",
	      Billing_Postcode: {required: true, digits: true},
	      Billing_State: "required",
	      Billing_Country: "required",

	      // DELIVERY
	      Delivery_FirstName: "required",
	      Delivery_Surname: "required",
	      Delivery_Phone: {required: true, digits: true},
			  Delivery_Email: {required: true, email: true},
	      Delivery_Address1: "required",
	      Delivery_Suburb: "required",
	      Delivery_Postcode: {required: true, digits: true},
	      Delivery_State: "required",
	      Delivery_Country: "required"
	    },
	    messages: {

	      // BILLING
	      Billing_Phone: {digits: "Please enter numbers only"},
	      Billing_Postcode: {digits: "Please enter numbers only"},

	      // DELIVERY
	      Delivery_Phone: {digits: "Please enter numbers only"},
	      Delivery_Postcode: {digits: "Please enter numbers only"}
	    },
	    success: function(label) { 
	      // inform user their input is valid
	      label.html(" ").addClass("correct"); 
	    }

	  });
	

	// Open links in new window when rel="external" is applyed to a tag
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	




});