$(document).ready(
	function() {
	
	// Droppy Settings
		$('#page-nav').droppy({
			speed: 500,
			hideSpeed: 250
		});

	// Media Settings
		if($('.media').length) {
			$('.media').media();
		};

	// Cycle Settings
		// Homepage Slideshow
		if ($('#slideshow').length) {
			$('#slideshow').cycle({
				timeout: 4500,
				fx: 'cover,fade,fade,growX,growY,scrollUp,scrollDown,scrollLeft,scrollRight,turnUp,turnDown,turnLeft,turnRight,uncover,wipe',
				randomizeEffects: 1,
				speed: 1500,
				random: 1,
				delay: -2000
			});
		};

	// Kwicks image menus
		if ($('#kwicks-current-nav').length) {
			$('#kwicks-current-nav').kwicks({
				max: 350,
				spacing: 2,
				duration: 300
			});
		};
		if ($('#kwicks-completed-nav').length) {
			$('#kwicks-completed-nav').kwicks({
				max: 350,
				spacing: 2,
				duration: 300
			});
		};

	// Validate Settings
		// Visibility of related id's based on selected option
		$('select').change(function() {
			if ($(this).val() == '') {$("#recipient-detail").children().hide();}
			else {$('#' + $(this).val()).show().siblings().hide();}
		// Build e-mail addresses in contact form using ID from select menu
			var partUser = $(this).val();
			var partDomain = 'severinotrucking.com';
			var fullAddr = partUser + '@' + partDomain;
				$('span.email').html('<a h' + 'ref=' + '"mai' + 'lto:' + fullAddr + '">' + fullAddr + '</a><br />');
		});
		// Persist visibility
		$('select').change();
		// Add phone number validation
		if ($('#form-contact').length) {
		jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
			phone_number = phone_number.replace(/\s+/g, ""); 
			return this.optional(element) || phone_number.length > 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");
		
		// Validate contact form on keyup and submit
			var validator = 
			$("#form-contact").bind("invalid-form.validate", function() {
				$("#error-summary").addClass('error center').html("Please at least complete the " + validator.numberOfInvalids() + " highlighted fields below.");
			}).validate({
				errorContainer: $("#error-summary"),
				rules: {
					email: { email: true },
					phone: { phoneUS: true }
				},
				errorPlacement: function(error, element) {
				},
				// Submit using Ajax
				submitHandler: function(form) {
					$("#result").addClass('success');
					$(form).ajaxSubmit({ 
						target: '#result',
						resetForm: true
					});
				},
				debug:false
			});
		};
		// Validate employee login form on keyup and submit
		if ($('#ee-login').length) {
			var validator = 
			$("#ee-login").bind("invalid-form.validate", function() {
				$("#error-summary").addClass('error center').html("Please enter a valid password");
			}).validate({
				errorContainer: $("#error-summary"),
				rules: {
				},
				errorPlacement: function(error, element) {
				},
				debug:false
			});
		};
	
	});
