/* Jugs Global Javascript Functions

By Will Moore - ISITE Design


*/

//start the jQuery functions
$(document).ready(function() {


	/* clears default text from input boxes. applied to the header search input - add as needed*/
	$("#search_term").inputClear();

	/*add class of 'over' to :hovered items to help IE6 and earlier get with the program*/
	if(document.all){
	    $("button, #nav li").hover(
	            function() { $(this).addClass("over");},
	            function() { $(this).removeClass("over");}
	    );
	}// if document.all

	//add class "even" to every other product list item for proper wrapping
	$('ul#products li:even').addClass('even');
	
    //lists - add .first & .last to all lists
    $("ul, ol").find("li:last").addClass('last');
	
	//lists - add .first & .last to all th's/td's
	$("table.order-detail thead tr").find("th:first").addClass('first');
    $("table.order-detail thead").find("th:last").addClass('last');
	$("table.order-detail thead tr.even").find("th:first").addClass('first');
    $("table.order-detail thead tr.even").find("th:last").addClass('last');	
	$("table.order-detail thead tr.even").find("th:first").addClass('first');
	
	
$("dl.faq dd").hide();
$("dl.faq dt").click(function(){
    $(this).next("dd").slideToggle();
}).css("cursor","pointer");


// Hide all large images except the first one
$('.product-photo img').hide().filter(':first').show();

// Select all thumb links
$('.product-thumb a').hover(function(event) {

		// Hide all large images except for the one with the same hash as our thumb link
		$('.product-photo img').hide().filter(this.hash).show();
	},
	function () {} // Because the hover method has a mouseout state we need to define too
);

// coaches bio 
 $('.bio').hide();
 $('#intro h2').toggle(
	function() {
	   $(this).next('.bio').fadeIn();
		 $(this).addClass('close');
	},
	function() {
		  $(this).next('.bio').fadeOut();
			$(this).removeClass('close');
	 }
	); // end toggle for coaches bio

$("input[name='order']").hide();
});// document ready / end jquery functions


	/*clear search field on click - made into plugin so it can easily be used more than once.*/
	jQuery.fn.inputClear = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};