/* <![CDATA[ */  
// slideshows
jQuery('#slides').cycle({
	fx:    'fade', 
	speed:  900,
	timeout: 6000, 
	pager: '#slidernav',
	pagerAnchorBuilder: function(index, slide) {
		var slider_img = jQuery(".fullImgLink", slide).attr('href');

		return '<a href="#"><img src="http://blackgoldcoffee.com/wp-content/themes/blackgold/includes/timthumb.php?src=' + slider_img +'&w=60&h=45" /></a>';
	}
});

jQuery('#big-top-images').cycle({
	fx:    'fade', 
	speed:  900,
	timeout: 0, 
	pager: '#big-top-image-nav',
	pagerAnchorBuilder: function(index, slide) {
		var slider_img = jQuery("img", slide).attr('src');

		return '<a href="#"><img src="http://blackgoldcoffee.com/wp-content/themes/blackgold/includes/timthumb.php?src=' + slider_img +'&w=60&h=45" /></a>';
	}
});

//do things once page is loaded
jQuery(document).ready(function() {
								
	/* Validate contactForm */
	jQuery("#contactForm").validate();


	/* Float main menu options past the logo*/
	jQuery('#menu-header>li:gt(2)').each(function(){
	jQuery(this).css('float','right');
	});


	/*MAIN MENU HOVER ANIMATIONS*/

	var mainMenuCount = jQuery('#menu-header>li').size();
	var zmax = 1010;

	jQuery('#menu-header li').mouseenter(function() { // enter animation
		var offTimeout = jQuery(this).data("offTimeout");
		if(offTimeout){clearTimeout(offTimeout);}
			jQuery(this).data("onTimeout", setTimeout(jQuery.proxy(function() {
			jQuery(this).find('ul:first').each(function(){
				var cur = parseInt(jQuery( this ).css( 'zIndex'));
				if(cur > parseInt(zmax)){zmax=cur;}
				jQuery(this).css( 'zIndex', parseInt(zmax)+1 );
				jQuery(this).slideDown();
				zmax=parseInt(zmax)+1;
			});
		}, this), 100));
	});

	jQuery('#menu-header li').mouseleave(function() { // exit animation
		var onTimeout = jQuery(this).data("onTimeout");
		if(onTimeout){clearTimeout(onTimeout);}
			jQuery(this).data("offTimeout", setTimeout(jQuery.proxy(function() {
			jQuery(this).find('ul:first').slideUp();
		}, this), 300));
	});
	

	
	
	//clear product list divs
	var divs_per_row = 3;
	
	jQuery(".product-list:gt(0)").find('h3').css('border-left','#ffffff 1px solid');
	jQuery(".product-list:nth-child("+divs_per_row+"n + 1)").css('clear','both').find('h3').css('border-left','none');
	
	//make all divs in a row the same height (and their headers too).
	
	var all_headers = jQuery(".product-list h3");


	all_headers.each(function(index, value){
		if(index%divs_per_row==0){

			var heights = new Array();
			
			//get height of h3s until divs_per_row
			for(i=0;i<=divs_per_row-1;i++){
				if(jQuery(".product-list h3:eq("+(index+i)+")").length >0){ 
					heights.push(parseInt(jQuery(".product-list h3:eq("+(index+i)+")").css('height')));
				}
			}
			//console.log(heights);
			var largest = Math.max.apply(Math, heights);
			//console.log(largest);
			for(i=0;i<=divs_per_row-1;i++){
				if(jQuery(".product-list h3:eq("+(index+i)+")").length >0){ 
					jQuery(".product-list h3:eq("+(index+i)+")").css('height', largest);
				}
			}
			
		}
	});
	
	//EMAIL SHARE FORM
	
	jQuery("#email-share-form > #close").click(function()
	{
		jQuery("#email-share-form").fadeOut(400);
		return(false);
	});
	
	
	
	jQuery(".sharebuttons").find('.email').click(function()
	{
		jQuery("#email-share-form").css('z-index','5000');
		jQuery("#email-share-form").fadeIn(400);
		console.log("hey hey");
		return(false);
	});
});






/* ]]> */
