// Create the tooltips only on document load
$(document).ready(function() 
	{
		// By suppling no content attribute, the library uses each elements title attribute by default
		$('a[href][title]').qtip({
			content: {
				text: false // Use each elements title attribute
			},
			position: {
				corner: {
				target: 'topMiddle',
				tooltip: 'bottomMiddle'
			}
		},

		style: {
			tip: 'bottomMiddle',
			name: 'red'
		}
	});

	// NOTE: You can even omit all options and simply replace the regular title tooltips like so:
	// $('#content a[href]').qtip();
	
	$('.slideshow').bxSlider({
		auto: false,
		autoControls: false,
		controls: false,
		speed: 500,
		pause: 6000
	});
	
	$('.sidebar-carousel').bxSlider({
		auto: true,
		autoControls: false,
		controls: false,
		speed: 500,
		pause: 3000
	});
	
	$('.feature ul').show();	
	$('.feature ul').bxSlider({
		ticker:true,
		tickerSpeed: 2000        
	});	
	
  $('#shop-slide').cycle({
      fx:         'none',
      timeout:     3500
  });
	
	// Mega Dropdown
	function megaHoverOver(){
			$(this).find(".sub").stop().fadeTo('fast', 1).show();

			//Calculate width of all ul's
			(function($) { 
				jQuery.fn.calcSubWidth = function() {
					rowWidth = 0;
					//Calculate row
					$(this).find("ul").each(function() {					
						rowWidth += $(this).width(); 
					});	
				};
			})(jQuery); 

			
		}

		function megaHoverOut(){ 
		  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
			  $(this).hide(); 
		  });
		}


		var config = {    
			 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
			 interval: 50, // number = milliseconds for onMouseOver polling interval    
			 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
			 timeout: 300, // number = milliseconds delay before onMouseOut    
			 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
		};

		$("#sidebar-cart .sub, li.menu .sub, li.cart .sub, .sidebar li .sub").css({'opacity':'0'});
		$("#sidebar-cart, li.menu, li.cart, .sidebar li").hoverIntent(config);
	
	
});
