$(document).ready(function(){
// Do not instantiate elements until the document has finished loading

		// Accordion - uses jQuery UI includes
		$("#accordion").accordion({ header: "h5", autoHeight: false });
		// OLD ---- $("#accordion").accordion({ header: "#accordion .headings a", autoHeight: false });
		
		// Main Navigation Drop Down Menu
		$('li.sitenavTab').hover(function() {
			$(this).find('.sitenavDropDown').show();
			//$(this).find('a.sitenavLink').css('backgroundColor', '#c1d34b');
			$(this).find('a.sitenavLink').addClass("sitenavHover");

		}, function() {
			$(this).find('.sitenavDropDown').hide();
			//$(this).find('a.sitenavLink').css('backgroundColor', '#830136');
			$(this).find('a.sitenavLink').removeClass("sitenavHover");
		});
	});
	
	// Wine Shop 4 Panel Feature - uses jQuery UI includes
	$(function() {
		$("#tabs").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 7000);
		
	
			
	// Search Results - Mouseover Image - looks for small image something_s.jpg and shows
	// large image something_l.jpg in the mouse over. Settings can be found in jquery.thumbhover.js
//	$("img[src*='.jpg']").thumbPopup({
//				imgSmallFlag: "",
//				imgLargeFlag: ""
//		});
//	});
	$("img[title*='product-case-img']").thumbPopup({
				imgSmallFlag: "",
				imgLargeFlag: ""
		});
	});
	
$(document).ready(function() {

$.validator.setDefaults({
	success: "valid"
});

jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    //phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 7 &&
		phone_number.match(/^[0-9]+$/);
		//phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number - no spaces");

jQuery.validator.addMethod("select_suburb",function(value, element) 
        { 
            if ((element.value == "")|| (element.value == "Please enter your postcode") || (element.value == "Please enter your post code") || (element.value == "Please Click here to select suburb"))
            {
            return false;
            }
            else
            {
            return true;
            }
        }, 
        "Please select a suburb."); 
	
	// Registration Form Validation - using jquery.validate.min.js			
	$(".registration #aspnetForm").validate({
		rules: {
			ctl00$cphMaster$txtFirstName: "required",
			ctl00$cphMaster$txtLastName: "required",
			ctl00$cphMaster$txtEmailID: {
    			email: true,
    			required:true
    		},
    		ctl00$cphMaster$txtConfirmEmailID: {
    			equalTo: "#ctl00_cphMaster_txtEmailID",
    			email: true,
    			required: true
    		},
    		ctl00$cphMaster$txtPassword: {
    			minlength: 6,
    			required: true
    		},
    		ctl00$cphMaster$txtConfirmPassword: {
      			equalTo: "#ctl00_cphMaster_txtPassword",
      			minlength: 6,
      			required: true
    		},
    		ctl00$cphMaster$txtAddress1: {
    			required: true
    		},
    		ctl00$cphMaster$txtCity: {
    			required: true
    		},
    		ctl00$cphMaster$ddlState: {
    			required: true
    		},
    		ctl00$cphMaster$PostCode: {
    		    digits: true,
    			required:true,
    			minlength: 4   
    		},
    		ctl00$cphMaster$txtPhone: {
    			required: true,
      			phoneUS: true
    		},
    		city1:{
    		    select_suburb: true  		    
    		},
    		Selctl00_cphMaster_spnCity:{    		   
    		    select_suburb: true  
    		},
    		spnCity:{    		   
    		    select_suburb: true  
    		}
  		},
  		messages: {
  		ctl00$cphMaster$txtFirstName: "Please specify your first name",
  		ctl00$cphMaster$txtLastName: "Please specify your last name",
  		ctl00$cphMaster$txtConfirmEmailID: "Please confirm your email address",
  		ctl00$cphMaster$txtPassword: {
  		required: "Please enter a password",
  		minlength: "Your password needs to be at least 6 letters"
  		},
  		ctl00$cphMaster$txtConfirmPassword: {
  		required: "Please confirm your password",
  		minlength: "Your password needs to be at least 6 letters"
  		},
  		ctl00$cphMaster$txtAddress1: "Please enter your address",
  		ctl00$cphMaster$txtCity: "Please enter your city",
  		ctl00$cphMaster$txtZipCode: "Please enter your zip code",
  		city1: "Please select the suburb",
  		Selcity1: "Please select the suburb",
  		Selctl00_cphMaster_spnCity: "Please select the suburb",
  		spnCity: "Please select the suburb"
  		}
	});
	
   
   function fnValidateJquery(){
	$(".shipping-address-form #aspnetForm").validate({debug: true});
   }
	
});
	
	
