$(document).ready(function () {

			//open links in new window with rel of external
			$('a').each(function () {
				type = $(this).attr('rel');
				if( type == 'external'){
					$(this).attr('target', '_blank');	
				}
			});			
			
			//Remove no js warnings
			$('#jsWarning').remove();
			$('.slideShowEntry').css('height', '300px');
			
			//Gameflavor Home page tabs
			var tabContainers = $('div#tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div#tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div#tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
			
			//Gameflavor Home page slideshow			
    	$(".ss").jCarouselLite({
    			visible: 1,
    			auto: 8000,
        	btnNext: "#ssNavRight",
        	btnPrev: "#ssNavLeft"
    	});
    	
    	//Random remove padding etc from last/first items
    	$("div.boardLatestInner:first > ul li:last").css('padding-bottom', '0px');
    	
    	//Insert Board Ad in GF home page review blocks
    	var here = $('div.gameReview')[4];
    	if(($('div.gameReview').length) < 10) {
    		var lngth = ($('div.gameReview').length);    		
    		here = $('div.gameReview')[lngth-2];	
    		$(here).after('<div class="gBoardsMedium clear"><img class="imgLeft" src="build/img/board-badge-medium.png" alt="Join the GameFlavor Boards" /><p>Tasty Talk. Join the conversation on the <a href="">GameFlavor Boards!</a></p></div>');
    	}
    	else {    	
    		$(here).after('<div class="gBoardsMedium clear"><img class="imgLeft" src="build/img/board-badge-medium.png" alt="Join the GameFlavor Boards" /><p>Tasty Talk. Join the conversation on the <a href="">GameFlavor Boards!</a></p></div>');
    	}			
    	
    	//Email subscribe
    	$("a#emailSubBox").fancybox({ 
    		'hideOnContentClick': false,
    		'frameHeight': 100, 
    		'frameWidth': 350
    	});  
    	
    	//Test and switch highlight image
    	$('.ssImg').css('display', 'none');
    	$('#slideShow .ssImg').css('display', 'block');
    	
    	//Hide slide show navigation apart from on hover of img
    	$('#ssNavLeft img').css('visibility', 'hidden');    	
    	$('#ssNavRight img').css('visibility', 'hidden');
    	
    	$('#slideShow img').hover(
				function () {
	        $('#ssNavLeft img').css('visibility', 'visible');
	        $('#ssNavRight img').css('visibility', 'visible');
		    }, 
		    function () {
		        $('#ssNavLeft img').css('visibility', 'hidden');
    				$('#ssNavRight img').css('visibility', 'hidden');
      	}
    	);
    	
    	//center ads shown in slideshow    	
    	var ssAdHeight = $('.ssInlineAdContainer').height();    	
    	var adPad = (300-ssAdHeight)/2;    	
    	$('.ssInlineAdContainer').css('margin-top', adPad);
    	$('.ssInlineAdContainer').css('margin-bottom', adPad);
    	
    	//check for header ad, and set background image accrodingly
    	if( $('#adHeader').children().length > 0 ){
    		//get the height of the ad
    		var setHeight = $('#adHeader').height();
    		//set new background position
    		setHeight = -200 + setHeight + 5;
    		$('body').css('background-position', '0px '+setHeight+'px');
    		$('#adHeader').css('padding-top', '5px');
     	}
    	
}); //end of doc ready


function removeMe() {
	$('#fancy_overlay').hide();
  $('#fancy_wrap').hide();    
}

function showMe() {
	$('#fancy_overlay').show();
	$('#fancy_wrap').show();
}