$(document).ready(function(){
	
	$(".tabmenu").click(function() {

		// Toggle all tabmenus
		$(".tabmenu").removeClass("on").addClass("off");
		
		// Turn the current one "on"
		$(this).removeClass("off").addClass("on");
		
		// Toggle all tab content blocks
		$(".tabcontent").removeClass("show").addClass("hide");
		
		// Show the selected one
		$("#" + $(this).attr("content")).removeClass("hide").addClass("show");
	});


	// Home Page Image Fader
	if ( $('.second-column').length>0 ) {
		$('.second-column').innerfade({
			animationtype: 'fade',
			speed: 750,
			timeout: 7000,
			type: 'sequence'
		});
	}
	
	// Contact Form Validator
	if ( $('#contact-form').length>0 ) {
		$("#contact-form").validate({
	
		   // Fade In/Out to capture attention
			highlight: function(element, errorClass) {
			
				if ( $(element).hasClass("badinput") ) return;
				
				$(element).fadeOut(function() {
					$(element).fadeIn();
					$(element).addClass('badinput');
				});
		   },
	
		   // Plugin defaults to "error".  this uses the current hamilton form error class.
			errorClass: "badinput",
	
			// Check every field, every time it loses focus.
			onfocusout: function(element) {
				$("#formError").fadeOut();
				if ( !this.checkable(element) ) {
					this.element(element);
				}
			},
	
			// Do not validate every keystroke
			onkeyup: false,
	
			// Remove the "badinput" class while you are editing a field that had an error in it.
			focusCleanup: false,
			focusInvalid: false,
			
			// This hides the error message itself as it's tough to place them properly in an address form.
			// Unless ... it's one of the downloads, in which case we show it above the list.
 

			
		});	
	}

});
