/* PRELOAD IMAGE PLUGIN */

jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
    	jQuery("<img>").attr("src", arguments[i]);
  	} //for
} //preloadImages

/* FEATURE BOX FUNCTIONS */

function displayFeature(name,copy) {
	$("#image-box").removeClass("def-feature");
	$("#image-box").addClass(name);
	$("#image-box").html(copy);
} //displayFeature()

function hideFeature(name) {
	$("#image-box").html("");
	$("#image-box").removeClass(name);
	$("#image-box").addClass("def-feature");
} //hideFeature

$(document).ready(function() {

	/*******************************************
	FEATURE BOX
	********************************************/
	
	// Preload images
	$.preloadImages("/assets/templates/xhair/img/feature_no-hardware-simulator.jpg","/assets/templates/xhair/img/feature_non-intrusive-testing.jpg","/assets/templates/xhair/img/feature_powerful-interface.jpg","/assets/templates/xhair/img/feature_process-level-access.jpg");
	
	$("#powerful-interface").hover(function() {
		// Change the background of the feature box by adding a class
		displayFeature("powerful-interface", "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla facilisis, tortor vitae iaculis imperdiet, justo quam lacinia neque, ut aliquet nisl lectus et nibh. In diam ipsum, congue nec vehicula a, bibendum vitae dui.</p>");
	}, function() {
		hideFeature("powerful-interface");
	}); //#powerful-interface
	
	$("#non-intrusive-testing").hover(function() {
		// Change the background of the feature box by adding a class
		displayFeature("non-intrusive-testing", "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla facilisis, tortor vitae iaculis imperdiet, justo quam lacinia neque, ut aliquet nisl lectus et nibh. In diam ipsum, congue nec vehicula a, bibendum vitae dui.</p>");
	}, function() {
		hideFeature("non-intrusive-testing");
	}); //#non-intrusive-testing
	
	$("#no-hardware-simulator").hover(function() {
		// Change the background of the feature box by adding a class
		displayFeature("no-hardware-simulator", "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla facilisis, tortor vitae iaculis imperdiet, justo quam lacinia neque, ut aliquet nisl lectus et nibh. In diam ipsum, congue nec vehicula a, bibendum vitae dui.</p>");
	}, function() {
		hideFeature("no-hardware-simulator");
	}); //#no-hardware-simulator
	
	$("#process-level-access").hover(function() {
		// Change the background of the feature box by adding a class
		displayFeature("process-level-access", "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla facilisis, tortor vitae iaculis imperdiet, justo quam lacinia neque, ut aliquet nisl lectus et nibh. In diam ipsum, congue nec vehicula a, bibendum vitae dui.</p>");
	}, function() {
		hideFeature("process-level-access");
	}); //#process-level-access
	
	/******************************************
	Clear form fields
	*******************************************/
	
	// Need to clear input boxes of any existing text when they're clicked.
	$("#search-form-qry").click(function() {
		// The search box
		if($("#search-form-qry").val() == "SEARCH SITE") {
			// Only clear the value if it hasn't been changed already
			$("#search-form-qry").val("");
		} //if
	}); //#search-form-qry
	
	/******************************************
	Clear email input form
	*******************************************/
	
	$("#email-address").click(function() {
		// The search box
		if($("#email-address").val() == "ENTER YOUR EMAIL ADDRESS HERE") {
			// Only clear the value if it hasn't been changed already
			$("#email-address").val("");
		} //if
	}); //#search-form-qry
	
	/******************************************
	Set up the pullout contact box
	*******************************************/
	
	// Set up the pullout box
	$("#pullout-contact").removeClass("hidden");
	$("#pullout-contents").hide(); // Hide the contents
	
	$("#pullout-button").click(function() {
		// Show the contents
		$("#pullout-contents").show("medium");
	});
	
	$("#hide-button").click(function() {
		// Hide the contents
		$("#pullout-contents").hide();
	});
	
});