$(document).ready(function(){
   
	$(document).bind("contextmenu",function(e){
		alert("Copyright John F Allen. All Rights Reserved");
		return false;
	});

  $.get("/wholesale/marquee.php", function(data){
  		$("#MarqueeContent").html(data);
	});
  
  $("#MatrixDisplay a").hover(function(){
		$(".MatrixPopUp").hide();	
		$(this).next(".MatrixPopUp").show();								   
	}, function(){
		$(this).next(".MatrixPopUp").hide();								   
	});
  
  	$("#searchSite").click(function(event){
		event.preventDefault();
		
		$("#topNavSearch").submit();
	});
	
	
		
	$(function() {
			$("#tree").treeview({
				collapsed: true,
				animated: "medium",
				control:"#sidetreecontrol",
				persist: "location"
			});
		})


 // Checkout form validation
	  
	  
	 $("#apply #billShipSame").click(function(){
		if ($(this).is(":checked")) {
			$("#shipping_input").hide();
		} else {
			$("#shipping_input").show();
		}
	  });

	var validator = $("#apply").validate({
		rules: {
			businessName: "required",
			email: {
				required: true,
				email: true
			},
			phone: "required",
			billingAddress: "required",
			billingCity: "required",
			billingState: "required",
			billingZip: {
				required: true,
				minlength: 5
			},
			billingPhone: {
				required: true,
				minlength: 10
			},
			
			/*,
			shippingAddress: {
				required: "#billShipSame:unchecked",
			}
			,
			shippingCity: {
				required: "#billShipSame:unchecked",
			},
			shippingState: {
				required: "#billShipSame:unchecked",
			},
			shippingZip: {
				required: "#billShipSame:unchecked",
			},
			*/
			agreeToTerms: "required"
			
		},
		messages: {
			
			
			businessName: "Please enter your business name",
			customerTax_ID: "Please select an option",
			billingAddress: "Please enter your billing address",
			billingCity: "Please enter your billing city",
			billingState: "Please enter your billing state",
			billingZip: {
				required: "Please enter your 5 digit billing zip code",
				minlength: "Please enter at least 5 digits"
			}, 
			phone: {
				required: "Please enter your phone, including area code",
				minlength: "Please enter your phone, including area code"
			},
			email: {
				email: "Enter a valid email address",
				required: "Enter a valid email address"
			},
			emailConfirm: {
				required: "Please re-enter your email address",
				equalTo: "Your email address does not match"
			},
			password: {
				required: "Please choose an account password",
				minlength: "Password is too short. Must be atleast 5 characters"
			},
			confirmPassword: {
				required: "Please retype your password",
				equalTo: "Passwords do not match"	
			},
			
			shippingFirstName: "Please enter your first name",
			shippingLastName: "Please enter your last name",
			shippingAddress: "Please enter your shipping address",
			shippingCity: "Please enter your shipping city",
			shippingState: "Please enter your shipping state",
			shippingZip: {
				required: "Please enter your 5 digit shipping zip code",
				minlength: "Please enter at least 5 digits"
			},
			billingPhone: {
				required: "Please enter your phone, including area code",
				minlength: "Please enter your phone, including area code"
			},
			agreeToTerms: "You must agree to our terms and conditions",
			cc: "Please enter a valid 15-16 digit CC #",
			ccExpirationMonth: "Please select your credit card expiration month",
			ccExpirationYear: "Please select your credit card expiration year"
			
			
		},
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().add() );
				
			else if ( element.is(":checkbox") )
				error.appendTo ( element.parent().add() );
			else
				error.appendTo( element.parent().add() );
		},
		errorElement: "div"

	});


});
