/*
	
	Project Name Global Javascript Functions
	By  - ISITE Design

*/

//start the jQuery functions
$(document).ready(function() {

	// add class to drop downs and buttons for IE <6
	if(document.all){
	    $("#nav li, button").hover(
			function() { $(this).addClass("over"); },
			function() { $(this).removeClass("over"); }
	    );
	}// if document.all
	
	// Input Setter - see documentation below
	$("#newsletter-signup input, #sitesearch input").inputSetter(1);

	// apply internal span to buttons for backgrounding
	$("button").wrapInner('<span></span>');
	
	if($('.home-page').length>0) {
		var flashvars = { xmlPath: "_resources/xml/menulinks.xml" };
		var params = { wmode: 'transparent' };
		var attributes = {};
		
		swfobject.embedSWF("_resources/flash/home.swf", "flashreplace", "940", "319", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	}

});// document ready / end jquery functions


// clean console.log
function cl(logit){ if(window.console&&window.console.firebug) { console.log(logit) } };//cl()
// example: cl("If you use cl() instead of console.log(), it won't break IE when you forget to take it out.");

/*

	12.19.08 - pdf
	
	Input Setter
	pull label and insert as field. clear with click.	
	optional lower param if == 1, string toLowerCase	

	ex: $("#sitesearch input").inputSetter(1); // makes default text lowercase
		$("#sitesearch input").inputSetter(); // no lowercasing

*/

jQuery.fn.inputSetter = function(lower) {	
	return this.each(function() {
		var $input = $(this);
		var $label = $("label[for='"+$input.attr("id")+"']");
		var labeltext = lower && lower==1 ? $label.text().toLowerCase() : $label.text();
		$label.hide();	
		$input.val(labeltext);		
		$input.focus(function() { if (this.value == labeltext) { this.value = ""; }	})
			  .blur(function() { if (!this.value.length) { this.value = labeltext; } });		
	});
};
