$(document).ready(function() {
	$("div#nav ul li.primary a.primary").mouseover(function() {
		// hide all subnav lists
		$("div#nav ul li.primary").removeClass("show");
		// show selected list
		$(this).parent().addClass("show");		
	});
	
	// add pipes between footer links, then remove last pipe
	$("div#footer ul li").each(function() { $(this).html($(this).html() + "|"); });
	$("div#footer ul li:last").each(function() { $(this).html($(this).html().replace(/\|/,""));	});
	
	var gallerySelect = $("body#videogallery").find("select#ctl00_c_order option");
	var galleryName = $("body#videogallery").find("input[@name=gallery]").val();
	var galleryOrder = "<ul id=\"order\">";	
	$(gallerySelect).each(function() {	    
	    var galleryOptionClass = "";
	    if ($(this).attr("selected")) {
	        galleryOptionClass = "selected";	        
	    }
	    galleryOrder += "<li class=\"order" + $(this).attr("value") + "\"><a href=\"videogallery.aspx?gallery=" + galleryName + "&ctl00$c$order=" + $(this).attr("value") + "\" class=\""+galleryOptionClass+"\">" + $(this).text() + "</a></li>";	    
	});
	galleryOrder += "</ul>";
	
	$("body#videogallery a.seeall").each(function(){
	    $(this).click(function() {
	        var galleryToShow = $("#ctl00_c_" + $(this).attr("class").replace(/seeall cta /, "").replace(/ /, ""));
	        //alert($(galleryToShow).css("display"));
	        $(galleryToShow).slideToggle("slow");
	        return false;
	    });
	});
	
	$("body#videogallery form").before(galleryOrder);
	$("body#videogallery form").remove();
	
	$("#rangeimage a").each(function(){
	    $(this).click(function() {
	        $(".flavourdetails").hide();
	        var flavour = $(this).attr("href");
	        $("#ctl00_c_" + flavour.split("=")[1]).show();
	        return false;
	    });
	});	
	
	$("#trivgames a").each(function(){
        var current = $("img", this);
        var source = $("img", this).attr("src");	
        var pId = "div#" + $(this).parent("li").attr("class");

        $(this).mouseover(function(){
            $(pId).show();
        });
        $(this).mouseout(function(){
           
            $(pId).hide();
        });        
	});
	
	$("#mobilePC li a").each(function(){
	    $(this).click(function() {
	        var mobilePCID = $(this).text();
            if(mobilePCID=='Mobile'){
               $("#pc").hide();            
               $("#mobile").show();
               $("#mobilelink").css("color","#ffcc00");
               $("#pclink").css("color","#ffffff");
            } else {
               $("#mobile").hide();
               $("#pc").show();
               $("#pclink").css("color","#ffcc00");
               $("#mobilelink").css("color","#ffffff");             
            } 
	        return false; 
	    });	
	});	
     
		
	

	
	
		
});