			//<![CDATA[

			//This extends jQuery so that we can control the initial menu state via the querystring
			$.extend({
			  getUrlVars: function(){
				var vars = [], hash;
				var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
				for(var i = 0; i < hashes.length; i++)
				{
				  hash = hashes[i].split('=');
				  vars.push(hash[0]);
				  vars[hash[0]] = hash[1];
				}
				return vars;
			  },
			  getUrlVar: function(name){
				return $.getUrlVars()[name];
			  }
			});
			
			$(document).ready(function() {								
				
				//HIDE ALL MENUS ON HOME PAGE LOAD
				$('div.clsHomeMenu_KCStadium_Children').hide();
				$('div.clsHomeMenu_Gemtec_Children').hide();
				$('div.clsHomeMenu_Events_Children').hide();
				$('div.clsHomeMenu_PremierClub_Children').hide();
				$('div.clsHomeMenu_HullCity_Children').hide();
				$('div.clsHomeMenu_HullFC_Children').hide();
				$('div.clsHomeMenu_Bonus_Children').hide();
				
				//WHICH MENU NEEDS TO BE SHOWN? CHECK THE QUERYSTRING!
				switch ($.getUrlVar('menu')) { 				
				
					case 'hullcity': 
						$("a.clsHomeMenu_HullCity").addClass("clsHomeMenu_MenuSelected");
						$('div.clsHomeMenu_HullCity_Children').fadeIn('slow');
						$('div.clsHomeMenu_HullCity_Children').css("background-image", "url(/site-includes/images/home-page-images/hull-city.jpg)");
						break;

					case 'hullfc': 
						$("a.clsHomeMenu_HullFC").addClass("clsHomeMenu_MenuSelected");
						$('div.clsHomeMenu_HullFC_Children').fadeIn('slow');
						$('div.clsHomeMenu_HullFC_Children').css("background-image", "url(/site-includes/images/home-page-images/hull-fc.jpg)");
						break;
						
					default:
						//DEFAULT MENU IS THE KC STADIUM ONE
						$('div.clsHomeMenu_KCStadium_Children').fadeIn('slow');
						$('div.clsHomeMenu_KCStadium_Children').css("background-image", "url(/site-includes/images/home-page-images/kc-stadium.jpg)");
						$("a.clsHomeMenu_KCStadium").addClass("clsHomeMenu_MenuSelected");	
						break;						
				}

				//SET UP THE EVENT CAROUSEL
				$('#myEventCarousel').jcarousel({
					scroll: 1, //number of items to scroll
					animation: 1000, // speed of auto scroll (milli)		
					vertical: true,
					initCallback: myEventCarousel_initCallback
				});
				
				//SET UP THE IMAGE CAROUSEL
				$('#myImageCarousel').jcarousel({
					scroll: 1, //number of images to scroll
					auto: 3, // seconds to wait before scroll
					animation: 1500, // speed of auto scroll (milli)
					wrap: 'last', //wraps to beginning when it hits the end
					initCallback: mycarousel_initCallback,					
					buttonNextHTML: null, // This tells jCarousel NOT to autobuild prev/next buttons
					buttonPrevHTML: null // This tells jCarousel NOT to autobuild prev/next buttons
				});
				
				//SET THE INTERNAL LINK SCROLL UP
				$.localScroll();
				
				//SET THE SHADOWBOX UP
				Shadowbox.init({
					overlayOpacity: "0.8"
				});
							
				//SET THE HOVER STATES ON THE CLUB BADGES
				$("#aHullCityBadge").qtip({
					
					content: "Visit official Hull City site",
					position:   {
									corner: {
												target: 'bottomMiddle',
												tooltip: 'topMiddle'
											},
									target: 'mouse',
									adjust: { 
												x: 0, y: 25 
											}
															   
								},
					style:      { 
									width: 190,
									padding: 2,
									background: '#ffae00',
									color: '#fff',
									textAlign: 'left',
									border: {
										width: 4,
										radius: 4,
										color: '#ffae00'
									},
									tip: 'topMiddle',
									name: 'cream' // Inherit the rest of the attributes from the preset dark style
								}                  
				});				

				$("#aHullFCBadge").qtip({
					
					content: "Visit official Hull FC site",
					position:   {
									corner: {
												target: 'bottomMiddle',
												tooltip: 'topMiddle'
											},
									target: 'mouse',
									adjust: { 
												x: 0, y: 25 
											}
															   
								},
					style:      { 
									width: 180,
									padding: 2,
									background: '#000',
									color: '#fff',
									textAlign: 'left',
									border: {
										width: 4,
										radius: 4,
										color: '#000'
									},
									tip: 'topMiddle',
									name: 'cream' // Inherit the rest of the attributes from the preset dark style
								}                  
				});	
				
				//THIS DRIVES THE CAROUSEL. CLEVER EH?
				function mycarousel_initCallback(carousel) {							
					$('#aImageCarouselNext').bind('click', function() {
						carousel.next();
						return false;
					});
				 
					$('#aImageCarouselPrevious').bind('click', function() {
						carousel.prev();
						return false;
					});	
			 
					// Pause autoscrolling if the user moves with the cursor over the clip.
					carousel.clip.hover(function() {carousel.stopAuto();}, function() {carousel.startAuto();});					
				};				

				//THIS DRIVES THE EVENT CAROUSEL. CLEVER EH?
				function myEventCarousel_initCallback(carousel) {							
					$('#aEventCarouselNext').bind('click', function() {
						carousel.next();
						return false;
					});
				 
					$('#aEventCarouselPrevious').bind('click', function() {
						carousel.prev();
						return false;
					});	
					
			 		$('#divEventList ul li a').bind('click', function() 
					{
					
						//Remove the selected class from all anchors
						$("[rel=1]").removeClass('aEventSelected');
						$("[rel=2]").removeClass('aEventSelected');
						$("[rel=3]").removeClass('aEventSelected');
						$("[rel=4]").removeClass('aEventSelected');
						$("[rel=5]").removeClass('aEventSelected');
						$("[rel=6]").removeClass('aEventSelected');
						//Add it to the one clicked
						$(this).addClass('aEventSelected');
					
						carousel.scroll($.jcarousel.intval($(this).attr('rel')));
						return false;
					});
				};	
				
				function FadeTheMenus()
				{
					
					//FADE ALL THE MENUS AS WE DONT KNOW WHICH ONE IS SHOWING	
					$('div.clsHomeMenu_KCStadium_Children').fadeOut('slow');
					$('div.clsHomeMenu_Gemtec_Children').fadeOut('slow');
					$('div.clsHomeMenu_Events_Children').fadeOut('slow');
					$('div.clsHomeMenu_PremierClub_Children').fadeOut('slow');
					$('div.clsHomeMenu_HullCity_Children').fadeOut('slow');
					$('div.clsHomeMenu_HullFC_Children').fadeOut('slow');	
					$('div.clsHomeMenu_Bonus_Children').fadeOut('slow');
					
					$("a.clsHomeMenu_KCStadium").removeClass("clsHomeMenu_MenuSelected");
					$("a.clsHomeMenu_Gemtec").removeClass("clsHomeMenu_MenuSelected");
					$("a.clsHomeMenu_Events").removeClass("clsHomeMenu_MenuSelected");
					$("a.clsHomeMenu_PremierClub").removeClass("clsHomeMenu_MenuSelected");
					$("a.clsHomeMenu_HullCity").removeClass("clsHomeMenu_MenuSelected");
					$("a.clsHomeMenu_HullFC").removeClass("clsHomeMenu_MenuSelected");
					$("a.clsHomeMenu_Bonus").removeClass("clsHomeMenu_MenuSelected");
										
				}
				
				//STADIUM MENU CLICKED
				$("a.clsHomeMenu_KCStadium").click(function () 
				{																											
					FadeTheMenus();						
					$("a.clsHomeMenu_KCStadium").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_KCStadium_Children').fadeIn('slow');														
					$('div.clsHomeMenu_KCStadium_Children').css("background-image", "url(/site-includes/images/home-page-images/kc-stadium.jpg)");
				});	
				
				//GEMTEC MENU CLICKED
				$("a.clsHomeMenu_Gemtec").click(function () 
				{																	
					FadeTheMenus();
					$("a.clsHomeMenu_Gemtec").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_Gemtec_Children').fadeIn('slow');
					$('div.clsHomeMenu_Gemtec_Children').css("background-image", "url(/site-includes/images/home-page-images/gemtec.jpg)");
				});						

				//EVENTS MENU CLICKED
				$("a.clsHomeMenu_Events").click(function () 
				{																	
					FadeTheMenus();
					$("a.clsHomeMenu_Events").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_Events_Children').fadeIn('slow');
					$('div.clsHomeMenu_Events_Children').css("background-image", "url(/site-includes/images/home-page-images/events.jpg)");
				});	
				
				//PREMIER CLUB CLICKED
				$("a.clsHomeMenu_PremierClub").click(function () 
				{																	
					FadeTheMenus();
					$("a.clsHomeMenu_PremierClub").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_PremierClub_Children').fadeIn('slow');
					$('div.clsHomeMenu_PremierClub_Children').css("background-image", "url(/site-includes/images/home-page-images/premier-club.jpg)");
				});			

				//HULL CITY CLICKED
				$("a.clsHomeMenu_HullCity").click(function () 
				{																	
					FadeTheMenus();
					$("a.clsHomeMenu_HullCity").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_HullCity_Children').fadeIn('slow');
					$('div.clsHomeMenu_HullCity_Children').css("background-image", "url(/site-includes/images/home-page-images/hull-city.jpg)");
				});	

				//HULL FC CLICKED
				$("a.clsHomeMenu_HullFC").click(function () 
				{																	
					FadeTheMenus();
					$("a.clsHomeMenu_HullFC").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_HullFC_Children').fadeIn('slow');
					$('div.clsHomeMenu_HullFC_Children').css("background-image", "url(/site-includes/images/home-page-images/hull-fc.jpg)");
				});	

				//BONUS MENU CLICKED
				$("a.clsHomeMenu_Bonus").click(function () 
				{																	
					FadeTheMenus();
					$("a.clsHomeMenu_Bonus").addClass("clsHomeMenu_MenuSelected");
					$('div.clsHomeMenu_Bonus_Children').fadeIn('slow');
					$('div.clsHomeMenu_Bonus_Children').css("background-image", "url(/site-includes/images/home-page-images/bonus.jpg)");
				});		
				
			});		
						
			//]]>
