// Jquery Functions 
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
// Preload images function
//
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
$(document).ready(function(){
	
	/* Tooltip Custom Styles */	
	$.fn.qtip.styles.ggsmall = { 
		border: 3,
		padding: 15,
		background: '#FFF',
		color: '#666666',
		textAlign: 'left'
	}	
	$.fn.qtip.styles.gglarge = {
	   background: '#FFF',
	   color: '#666666',
	   textAlign: 'left',	   
	   width: 300,
	   border: {
		  width: 3,
		  radius: 12,
		  color: '#008D00'
	   },
	   tip: 'bottomLeft',
	   name: 'green' 
	}
	
	/* SSL Seal Tooltip #9E6D4C*/
	$('#footer .left').qtip({
		   content: {
   		   text: 'Our website uses industry-standard 128 bit SSL encryption from GeoTrust. Click on the security seal below to verify..',
		   title: { text: 'Secure Shopping at Garden Goodies' }
		   },
		   position: { 
		   		corner: {
					 target: 'topMiddle',
					 tooltip: 'leftBottom'
				  }
			},
		   style: /*{			   
		   	  tip: 'bottomLeft',
			  color: '#666666',
			  background: '#FFF',
			  padding: 15,
			  border: {
				 width: 3,
				 radius: 12,
				 color: '#008D00'
			  },     		
		   },
		   name:*/ 'gglarge'
	});
	
	/* Shipping Options Tooltip */
	$('#ship-opt').qtip({
		   content: {
   		   text: 'This Shipping rate has been automatically selected based on your cart contents. If available, alternative shipping methods can be selected on the following checkout pages...',
		   title: { text: 'Shipping Options' }
		   },
		   position: { 
		   		corner: {
					 target: 'topMiddle',
					 tooltip: 'rightBottom'
				  }
			},
		   style: {			   
		   	  tip: 'bottomRight',
			  color: '#666666',
			  background: '#FFF',
			  padding: 15,
			  border: {
				 width: 3,
				 radius: 12,
				 color: '#008D00'
			  }   		
		   }
	});
	
	/* Best Sellers Sidebar */	
	$('#bestSellersSidebar').serialScroll({
			target:'#bssViewport',
			items:'ul>li', // Selector to the items ( relative to the matched elements )
			prev:'div.prev',// Selector to the 'prev' button
			next:'div.next',// Selector to the 'next' button
			axis:'x',// The default is 'y' scroll on both ways
			duration:1000,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
			cycle:false,
			interval:8000, // It's the number of milliseconds to automatically go to the next
			constant:true, // constant speed
			easing:'easeOutQuart',
			exclude:0,			
			onBefore:function( e, elem, $pane, $items, pos ){
				 //those arguments with a $ are jqueryfied, elem isn't.
				e.preventDefault();
				if( this.blur )
					this.blur();
			},
			onAfter:function( elem ){
				//'this' is the element being scrolled ($pane) not jqueryfied
			}
		}).hover(function(){ $(this).stop().trigger('stop'); },
			function(){ $(this).stop().trigger('start'); 
	});
	//$('#bestSellersSidebar div.prev').qtip({ style: { name: 'green', tip: true } });
	//$('#bestSellersSidebar div.next').qtip({ style: { name: 'green', tip: true } });
	
	/* New Products Sidebar */	
	$('#npSidebar').serialScroll({
			target:'#npViewport',
			items:'ul>li', // Selector to the items ( relative to the matched elements )
			prev:'div.prev',// Selector to the 'prev' button
			next:'div.next',// Selector to the 'next' button
			axis:'x',// The default is 'y' scroll on both ways
			duration:1000,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
			cycle:false,
			interval:8000, // It's the number of milliseconds to automatically go to the next
			constant:true, // constant speed
			easing:'easeOutQuart',
			exclude:0,			
			onBefore:function( e, elem, $pane, $items, pos ){
				 //those arguments with a $ are jqueryfied, elem isn't.
				e.preventDefault();
				if( this.blur )
					this.blur();
			},
			onAfter:function( elem ){
				//'this' is the element being scrolled ($pane) not jqueryfied
			}
		}).hover(function(){ $(this).stop().trigger('stop'); },
			function(){ $(this).stop().trigger('start'); 
	});
	//$('#npSidebar div.prev').qtip({ style: { name: 'green', tip: true } });
	//$('#npSidebar div.next').qtip({ style: { name: 'green', tip: true } });

	/* Search box highlight */	
	$("#searchtable").hover(function() { //On hover
		$(this).find(".searchinput").addClass("fieldFocus");
	} , function() { //on hover out...
		$(this).find(".searchinput").removeClass("fieldFocus");
	});

	
	/* Address Tooltip */
	/*
	$('#address').qtip({
		   content: 'Click for a map and directions to our offices..',
		   position: { 
		   		corner: {
					 target: 'topMiddle',
					 tooltip: 'bottomRight'
				  }
			},
		   style: {
		   	  tip: 'bottomRight',
			  color: '#666666',
			  background: '#FFF',
			  padding: 15,
			  border: {
				 width: 1,
				 radius: 10,
				 color: '#9E6D4C'
			  },
			  name: 'light'
		   }
	});
	*/
	/*#30B0FF*/
	
	
	
	/* sitewide tooltips */
	//$('a[title]').qtip({ style: { name: 'cream', tip: true } })

/*
// pdf links:
$('#copy a[href$=.pdf]').addClass('pdf');
*/

// Dynamically set all text input field styles
/*	
$(".checkoutForms * input:text").addClass("checkoutFormsInput"); 
*/
	
// Checkout forms input highlight
/*	
$(".checkoutForms input:text").focus(function () {
     $(this).toggleClass("fieldFocus");
});
$(".checkoutForms input:text").blur(function () {
     $(this).removeClass("fieldFocus");       
});
*/

/* external links examples */
/*
$('#copy a').filter(function() {
	return this.hostname && this.hostname !== location.hostname;
}).addClass('external');

$('#copy a').filter(function() {
 return this.hostname && this.hostname !== location.hostname;
  }).after(' <img src="../img/external-link.png" alt="external link"/>');
*/

}); /* EOF Jquery Functions */ 

function jemail(user, domain, suffix){
document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}
