$(function(){
    if ($('.layout-textarea-1').length > 0) {
        moveSeoText($('.layout-textarea-1'));   
    }
    if ($('#header-text').length > 0) {
       moveSeoText($('#header-text'));
    }
    function moveSeoText(ele) {
        seotext = $(ele).html();
        $(ele).remove();
        headerContent = '<div id="header-text">'+seotext+'</div>';
        $(headerContent).insertBefore('#footer');
    }
    
    $('.product-scroll').each(function(){
        productScroll($(this));
    });
	//addtofavs($("#add-to-favs"), 'http://www.superstores.co.uk', 'co-op superstores'); //add to favourites
	//topnav($('#top-nav')); // top navigation 		
	/*
	$('#banner') 
		.after('<div id="banner-pagination">') 
		.cycle({ 
			fx:     'fade', 
			speed:  'slow', 
			timeout: 5000, 
			pager:  '#banner-pagination' 
	}); // banner			
	*/
	
    if ($('#floating-menu').length) {
        floatingMenu($('#floating-menu'));
    }
	
  $('#top-navigation .top-nav').find('ul li:first').addClass('toppadding');		
		$('#top-navigation .top-nav').hover(	
			function () {
				
				menuID = $(this).attr('id');
				
				$(this).find('ul').stop();
				
				totalItems = $(this).find('ul li').length;				
				totalHeight = totalItems * 22;
				totalHeight = totalHeight + 15;

				$(this).find('ul').animate({
					height: totalHeight   
				}, 500, 'easeOutExpo', function(){})				
			},
			function () {		
				$('other-stuff-menu').find('ul').removeClass('ie7-height');
				$(this).find('ul').stop();
				$(this).find('ul').animate({
					height: '0px'    
				}, 500, 'easeOutExpo', function(){})			
			}
		);  
	

//$('#slideshow-wrapper #next2').css('z-index', '9300');
    
	<!--	
		if (navigator.userAgent.indexOf("Chrome")!= -1 && navigator.platform.indexOf("Win")!= -1)
		{
		var cssNode = document.createElement("link");
		cssNode.setAttribute("rel", "stylesheet");
		cssNode.setAttribute("type", "text/css");
		cssNode.setAttribute("href", "css/compatibility/chrome.css");
		document.getElementsByTagName("head")[0].appendChild(cssNode);
		}
		
		if (navigator.userAgent.indexOf("Firefox")!= -1 && navigator.platform.indexOf("Mac")!= -1)
		{
		var cssNode = document.createElement("link");
		cssNode.setAttribute("rel", "stylesheet");
		cssNode.setAttribute("type", "text/css");
		cssNode.setAttribute("href", "css/compatibility/firefox-mac.css");
		document.getElementsByTagName("head")[0].appendChild(cssNode);
		}
		
		if (navigator.userAgent.indexOf("Safari")!= -1 && navigator.platform.indexOf("Mac")!= -1)
		{
		var cssNode = document.createElement("link");
		cssNode.setAttribute("rel", "stylesheet");
		cssNode.setAttribute("type", "text/css");
		cssNode.setAttribute("href", "css/compatibility/safari-mac.css");
		document.getElementsByTagName("head")[0].appendChild(cssNode);
		}
				
	//-->				
    $('.slideshow').cycle({
        fx:     'scrollHorz',         
	    // timeout: 3000, 
	    speedIn:  1000,
	    speedOut: 1000,
	    // delay:   -4000, 
	    next:   '#next2',     
	    prev:   '#prev2'
	});

	function megaHoverOver(){
		$(this).find(".dropdown").stop().fadeTo(100, 1).show();
			};

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

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

	$("ul.top-level .dropdown").css({'opacity':'0'});
	$("ul.top-level li").hoverIntent(config);

    $('.img-swap').mouseover(function() {
        this.src = this.src.replace("-off","-on");
    });
    $('.img-swap').mouseout(function() {
        this.src = this.src.replace("-on","-off");
    });

	 var imgSwap = [];
	 $(".img-swap").each(function(){
		imgUrl = this.src.replace("-off","-on");
		imgSwap.push(imgUrl);
	});
	if(imgSwap.length > 0){
    	$(imgSwap).preload();
    }

	$("#floating-menu img, .product-box .body img, #add-to-basket-form .tipaddress").tooltip({
		showURL: false,
		showBody: " - ",
		/* fade: 50, */
		track: true,
		top: 0,
		extraClass: "background",
		positionLeft: true,
		left: -10
	});

    // Display preview image on mouseover
    $('a.product-enlarge-trigger img').productEnlarge();
    
    // Top header search
    $('#search_term_field').focus(function() {
        if ($(this).val() == 'Search') { $(this).val(''); }
    });
    $('#search_term_field').blur(function() {
        if ($(this).val() == '') { $(this).val('Search'); }
    });
});

$.fn.preload = function() {
    this.each(function(){
        $('<img/>')[0].src = this;
    });
}

