$(document).ready(function(){

/*************************************
	HOMEPAGE GALLERY
**************************************/

if ($("#gallery_container").length) { //Check to see if element is on the page

/*If element is on the page then execute function*/

/*-------------------------------------
	CYCLE THROUGH THE DIVS
-------------------------------------*/

$('#gallery_items').cycle({ 
    fx:     'none',    // leave effect set to 'none'
    timeout:  5000,    // milliseconds between slide transitions (0 to disable auto advance)
    pause:    1,       // pause on hover
	autostop: 1,       // autostop...
	autostopCount: 4,   // ... after 4 slides (3 slots, then back to first)
	before: function(currSlideElement, nextSlideElement, options, forwardFlag) { 
				$(".hover").hide();
				$("#" + nextSlideElement.id.replace("item","thumb") + " .hover").show();
				$(".gallery_thumb").css('opacity',0.4);
				$("#" + nextSlideElement.id.replace("item","thumb")).css('opacity',1.0);
				
			}
});

/*-------------------------------------
	GALLERY THUMBNAIL HOVER LOGIC
-------------------------------------*/

$("#thumb_one").hover(
	function(){
		$(this).addClass("hover");
		$(".gallery_thumb").css('opacity',0.4);
		$("#thumb_one .hover").show();    $("#thumb_one").css('opacity',1.0);
		$("#thumb_two .hover").hide();
		$("#thumb_three .hover").hide();
		$("#item_one").show();
		$("#item_two").hide();
		$("#item_three").hide();
		$('#gallery_items').cycle('pause');
	},
	function(){
		//$(this).removeClass("hover");
		//$(".hover").hide();
		//$('#gallery_items').cycle('resume');
	});
$("#thumb_two").hover(
	function(){
		$(this).addClass("hover");
		$(".gallery_thumb").css('opacity',0.4);
		$("#thumb_one .hover").hide();
		$("#thumb_two .hover").show();	 $("#thumb_two").css('opacity',1.0);
		$("#thumb_three .hover").hide();
		$("#item_one").hide();
		$("#item_two").show();
		$("#item_three").hide();
		$('#gallery_items').cycle('pause');
	},
	function(){
		//$(this).removeClass("hover");
		//$(".hover").hide();
		//$('#gallery_items').cycle('resume');	
	});
$("#thumb_three").hover(
	function(){
		$(this).addClass("hover");
		$(".gallery_thumb").css('opacity',0.4);
		$("#thumb_one .hover").hide();
		$("#thumb_two .hover").hide();
		$("#thumb_three .hover").show(); $("#thumb_three").css('opacity',1.0);
		$("#item_one").hide();
		$("#item_two").hide();
		$("#item_three").show();
		$('#gallery_items').cycle('pause');
	},
	function(){
		//$(this).removeClass("hover");
		//$(".hover").hide();	
		//$('#gallery_items').cycle('resume');
	});
/*-------------------------------------
	GALLERY ITEM HOVER LOGIC
-------------------------------------*/
$("#item_one").hover(
	function(){
		$("#thumb_one .hover").show();
		$("#thumb_two .hover").hide();	
		$("#thumb_three .hover").hide();
	},
	function(){
		//$(".hover").hide();
	});
$("#item_two").hover(
	function(){
		$("#thumb_one .hover").hide();
		$("#thumb_two .hover").show();	
		$("#thumb_three .hover").hide();
	},
	function(){
		//$(".hover").hide();
	});
$("#item_three").hover(
	function(){
		$("#thumb_one .hover").hide();
		$("#thumb_two .hover").hide();	
		$("#thumb_three .hover").show();
	},
	function(){
		//$(".hover").hide();
	});
	
}

/*************************************
	MEGA MENUS
**************************************/
/*-------------------------------------
	BY CATEGORY MEGA MENU
-------------------------------------*/	

$("#by_category").hover(
	function(){
		$(this).addClass("by_category_hover");
		$("#by_category .mega").show();
	},
	function(){
		$(this).removeClass("by_category_hover");
		$("#by_category .mega").hide();
	});
	
/*-------------------------------------
	BY AGE MEGA MENU
-------------------------------------*/

	$("#by_age").hover(
	function(){
		$(this).addClass("by_age_hover");
		$("#by_age .mega").show();
	},
	function(){
		$(this).removeClass("by_age_hover");
		$("#by_age .mega").hide();
	});

/*-------------------------------------
	TOP RATED MEGA MENU
-------------------------------------*/

	$("#top_rated").hover(
	function(){
		$(this).addClass("top_rated_hover");
		$("#top_rated .mega").show();
	},
	function(){
		$(this).removeClass("top_rated_hover");
		$("#top_rated .mega").hide();
	});
	
/*-------------------------------------
	CURRENT SPECIALS MEGA MENU
-------------------------------------*/

	$("#current_specials").hover(
	function(){
		$(this).addClass("current_specials_hover");
		$("#current_specials .mega").show();
	},
	function(){
		$(this).removeClass("current_specials_hover");
		$(" #current_specials .mega").hide();
	});
	
/*************************************
	REMOVE DEFAULT INPUT VALUES
**************************************/
/*
 * 	Modified on: 12-01-2009
 * 			 by: dan@creeksmarts.com
 * 
 * 	- Commented out all input value removal on page load
 * 	- because it was not allowing checkbox forms on alerts page to function properly
 * 	- form values ended up blank even when checked on post back
 
	$('input, textarea').focus(function() {
		value=$(this).val();
		$(this).attr("value","");
	});
	$('input, textarea').blur(function() {
		if($(this).val()=="") {
			$(this).val(value);
		}
	});
*/
	// Only need the input value clearing on some fields
	// Site search field
	$("#sli_search_1").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	// Store locator zip code search field
	$("#ctl00_ContentPlaceHolder1_txtZipCode").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	// Header login fields
	$("#userName").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	$("#password").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
});/*CLOSING BRACKETS*/

/*************************************
	LEFT MENU
**************************************/

jQuery().ready(function(){//Check to see if element is on the page
if ($("#navigation").length) {
    /*If element is on the page then execute function*/
	$('#navigation').accordion({
		autoheight: false,
		active: false,
		header: '.head',
		navigation: true,
		fillSpace: false,
		animated: 'easeslide'
	});
}
});/*CLOSING BRACKETS*/

/*************************************
	jCAROUSEL SETTINGS
**************************************/

jQuery(document).ready(function() {//Check to see if element is on the page
if ($("#mycarousel").length) {
	/*If element is on the page then execute function*/
    jQuery('#mycarousel').jcarousel({
        vertical: true,
        scroll: 3,
        visible: 3,
		itemLoadCallback:     carousel_LoadItemCallback
    });
}
});/*CLOSING BRACKETS*/

