jQuery(document).ready(function($) {
//constant contact link	
	j('#constantcontactwidget-3').hover(function(){
			j('h3', this).toggle();
			j('form', this).fadeToggle();
		},function() {
			j('form', this).toggle();
			j('h3', this).fadeToggle();
	});
//
//banner home link
	j('#branding').click(function() {
		var url = j('#blog-title a').attr("href");
		window.location=url;
	});
//	j(".sf-menu li:not(':last')").filter('.current-menu-item').append('<img src="http://jgarnerhome.com/wp-content/themes/jgh/img/nav_bg_hover-nipple.png" style="margin-left:83px; position:absolute;z-index:-1;">');
	j(".sf-menu li.current-menu-item").append('<img src="http://jgarnerhome.com/wp-content/themes/jgh/img/nav_bg_hover-nipple.png" style="margin-left:83px; position:absolute;z-index:-1;">');


//eyecandy
	j('.hentry').append('<img src="http://jgarnerhome.com/wp-content/themes/jgh/img/grey_close.png" class="entry-close">');
	candyclick=false;
	j('.entry-close').click(function() {
		  j('div.hentry').hide('slide', function() {
			  j('li.current-menu-item img').animate({top:'12px'},500);
			  j('#access').animate({top:'537px'}, 1000);
			  j('#constantcontactwidget-3').slideUp();
			  //j('#branding').fadeTo(3000,0.3);
			  candyclick=true;
		  });
	});
	j('.current-menu-item').click(function(e) {
		e.preventDefault();
		if (candyclick) {
		j('#access').animate({top:'482px'}, 1000, function() {
			  //j('#branding').fadeTo(500,0.85);
			  j('.hentry').show('slide');
			  j('li.current-menu-item img').animate({top:'24px'},500);
			  j('#constantcontactwidget-3').slideDown();
			  candyclick=false;
		  });
		}
	});

//li hover action
	jQuery('.sf-menu li').each(function(index) {
		titleAttr = jQuery('.sf-menu li a').eq(index).attr('title');
		jQuery('a', this).removeAttr('title');
		if ( titleAttr ) {
			jQuery(this).append('<p>'+titleAttr+'</p>');
			jQuery(this).hover(function() {
				jQuery('p', this).delay(200).slideToggle();
			}/*,
			function() {
				jQuery('p', this).delay(100).slideUp();
			}*/
			); 

		}   
	}); 
//   	jQuery('.sf-menu li').each(function(index) {
// 		titleAttr = jQuery('.sf-menu li a').eq(index).attr('title');
// 		if ( titleAttr ) {
// 			jQuery(this).append('<p style="height:0;">'+titleAttr+'</p>');
// 			jQuery(this).hover(function() {
// 				jQuery('p', this).slideToggle();
// 			}); 
// 			jQuery(this).hover( 
// 			function() {
// 			  jQuery('p', this).delay(100).animate({height:'100%'},500);  
// 			},
// 			function() {
// 			  jQuery('p', this).delay(500).animate({height:'0'},500);  
// 			}
// 		  );
// 			jQuery('a', this).removeAttr('title');
// 		}   
// 	});
	
// rollover action on gallery page
	jQuery('.slug-gallery .content2 ul li').each(function(index) {
		jQuery('.hentry').append('<div class=\"entry-content\" style=\"display:none\"> </div>');
		var thisHref = jQuery('a', this).attr('href');
		jQuery('.entry-content').eq(index+1).load(thisHref+' .entry-content p' );
		jQuery('a',this).hover( function() {
			jQuery(this).click( function(e) {e.preventDefault() });
			jQuery('.entry-content').hide();
			jQuery('.entry-content').eq(index+1).show();
		});
	});

/* open single product in fancybox */
	j('.slug-sale .item_image a').fancybox({
		'onStart': function(selectedArray, selectedIndex, selectedOpts) {
			j.fancybox.showActivity();
			j.ajax({
				 async: false,
				 type: 'GET',
				 timeout: 2000,
				 url: selectedArray[selectedIndex].href,
				 success: function(html_page) {
					selectedOpts.content = j('#single_product_page_container', html_page).html() ;
					j.fancybox.hideActivity();
				 }
			});
		}// close onStart()
	});


	
}); //close document.ready()

