// JavaScript Document
$(document).ready(function()
{
	// Break-out of Frames
//	if (!(parent && parent.WebPlayer) && top.location != location) {
//		top.location.href = document.location.href;
//	}

	// Share This Button (onclick instead of onhover)
	addthis_config = {
		ui_click: true
	}

	// quick/product search
	$('.search-form').submit(function() {
		$(this).find('input[type=image]').attr('disabled', 'disabled');
	});

	// Prevent Double Click
	jQuery.fn.preventDoubleSubmit = function() {
		  jQuery(this).submit(function() {
			  if (this.beenSubmitted) {
				  return false;
			  }
		      
			  this.beenSubmitted = true;
		  });
	};
	
	jQuery('.general-form').preventDoubleSubmit();
	
	// Top Drop Down Navigation
	var megaConfig = {
		//interval: 150,
		interval: 0,
		sensitivity: 4,
		over: addMega,
		//timeout: 400,
		timeout: 0,
		out: removeMega
	};

    $megaDropDown = $("li.mega"); 
    
    if ($megaDropDown.hoverIntent) {
        $megaDropDown.hoverIntent(megaConfig);   
    }

	function addMega(){
		$(this).children('div').addClass("hovering");
		hoverWidth= $('.hovering').parent().width();
		hoverWidth = (hoverWidth/2);
		hoverWidth = hoverWidth-75;
		$('.hovering').css({'left':hoverWidth+39+'px'})
	}

	function removeMega() {
		$(this).children('div').removeClass("hovering");
	}


	// Navigation Link Hover Colour Trails
	$('#navigation a[class!=current]').mouseenter(function() {
		$(this).animate({'color':'#f0ec45'},75)
	}).mouseleave(function() {
		$(this).animate({'color':'#b0b1b3'},150)
	});

	$('#footer ul li > a[class!=current], #footer-details a').mouseenter(function() {
		$(this).animate({'color':'#f0ec45'},75)
	}).mouseleave(function() {
		$(this).animate({'color':'#515151'},150)
	});
	
	$('#left-column > ul li:not(".title") a').each(function() {
		$(this).prepend('<div class="green-link-circle">&nbsp;</div>');
		$('.green-link-circle').css({'display':'block','opacity':'0'});
	});

	//$('#left-column a').css({'background-image':'none'});

	/*$('#left-column a').mouseenter(function() {
		if(!$(this).hasClass('disabled'))
			$(this).clearQueue().animate({'color':'#f0ec45'},75);
		//$(this).children('.green-link-circle').animate({'opacity':'1'},75);
	}).mouseleave(function() {
		if(!$(this).hasClass('disabled'))
			$(this).animate({'color':'#B0B1B3'},150)
		//$(this).children('.green-link-circle').animate({'opacity':'0'},150);
	});*/

	// Cufon
	/*if(Cufon) {
		Cufon.replace('h1.home', {
			color: '-linear-gradient(white, grey)',
			fontFamily:'arial'
		});
		Cufon.now();
	}*/

	// Country Selector
	var countrySelectionConfig = {    
		interval: 150,
		sensitivity: 4,
		over: openCountrySelector,
		timeout: 400,
		out: closeCountrySelector
	};

	var countryHeight = $('#language-selector').children().size();
	countryHeight = $('.language').height() * countryHeight;
	
    if ($("#language-selector").hoverIntent) {
        $("#language-selector").hoverIntent(countrySelectionConfig);   
    }
	
	function openCountrySelector() {
		$('#language-selector').animate({'height':countryHeight+'px'});	
	}

	function closeCountrySelector() {
		$('#language-selector').animate({'height':$('.language').height()+'px'});	
	}

	// Our Story: Heritage Slider
	if ($('#slider').length != 0) {
		$('#slider').slider({
				value:00,
				min: 0,
				max: 30,
				//max: 35,
				step: 1});
	}
	
	//basket hover
	$("#basketheader").hover(function() {
		if ($("#baskettotal a").length > 0) {
			$(this).find(".basket-dropdown").stop(true, true).fadeIn(1000);
		}
	} , function() { 
		$(this).find(".basket-dropdown").stop(true, true).fadeOut(1000); 
	});

	
	$('#return-to-basket').click(function(event){
	   alert('hello');
	   event.preventDefault();
	})
});
	
function addProductShowBasket() {
	$('.basket-dropdown').fadeIn(1500).delay(3400).fadeOut(1500);
}

