JQ = $; $ = null; 

//=============================================================================
/* 

	v1.0
	2009/06/16

	Headscape
	Written by Ed Merritt (ed.merritt@headscape.co.uk)


*/
//=============================================================================
// Adds a class to the body tag so any elements on the page can be styled differently if the browser supports JS

JQ(document).ready(function() {
if (!jQuery.browser.msie || parseInt(jQuery.browser.version)>6) {
	JQ("body").addClass("fullyFeatured");
}
});

//=============================================================================
// Adds a class to the first and last <li> of every list

JQ(document).ready(function() {
	JQ("ul li:first-child").addClass("firstLi");
	JQ("ul li:last-child").addClass("lastLi");
	JQ("ol li:first-child").addClass("firstLi");
	JQ("ol li:last-child").addClass("lastLi");
});



//=============================================================================
// tabs

JQ(document).ready(function(){
	JQ('.tabGroup .tab').hide(); // Hide all divs
	JQ('.tabGroup .tab:first').show(); // Show the first div
	JQ('.tabGroup .tabs li:first').addClass('current'); // Set the class of the first link to active
	JQ('.tabGroup .tabs li a').click(function(){ //When any link is clicked
		JQ('.tabGroup .tabs li').removeClass('current'); // Remove active class from all links
		JQ(this).parent().addClass('current'); //Set clicked link class to active
		var currentTab = JQ(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
		JQ('.tabGroup .tab').hide(); // Hide all divs
		JQ(currentTab).show(); // Show div with id equal to variable currentTab
		return false;
	});
	if(JQ(window.location.hash).is('.tabGroup .tab')) {
		JQ(window.location.hash).parents('.tabGroup').find('.tabs li a[href='+window.location.hash+']').triggerHandler('click');
	}
});




//=============================================================================
// timeline

JQ(document).ready(function(){
if (!jQuery.browser.msie || parseInt(jQuery.browser.version)>6) {
  JQ(".tlDecade h2").wrapInner("<span></span>");
	JQ('.timeline > h2 + p').after('<hr /><div class="tlTabs"/><hr />').next().next().append(JQ('.tlDecade h2').clone());
	JQ('.tlTabs h2 span a').click(function(){ //When any link is clicked
		JQ('span').removeClass('tlCurrent');
		JQ(this).parent().addClass('tlCurrent');
		var currentTimeline = JQ(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
		JQ('.tlInfo').hide(); // Hide all divs
		JQ(currentTimeline.substring(currentTimeline.indexOf('#'))).show(); // Show div with id equal to variable currentTab
		return false;
	});
  JQ(".tlTabs h2:odd").addClass("tlAlt");
}
});


//=============================================================================
// sub navigation

JQ(document).ready(function() {
	JQ('#subNavigation li.current').prev('li').children('a').css('border', '0');
});


//=============================================================================
// read more on body content

JQ(document).ready(function() {
	JQ('.readMoreColumns2').parent().addClass('hideable');
	JQ('.readMoreColumns2').parent().before('<div class="textColumns2 textColumns2New "></div>');	
	JQ('.readMoreColumns2').prevAll().appendTo(".textColumns2New");
	JQ('.readMoreColumns2').remove();
	JQ('.textColumns2New').after('<hr class="readMoreColumns2" /><a class="readMoreLink2"><span class="readMoreLinkA">Show further information...</span><span class="readMoreLinkB">Hide further information...</span></a>')
	JQ(".hideable").css({'display' : 'none'});
});

JQ(document).ready(function(){
	JQ(".readMoreLink2").click(function(){
	  JQ(".hideable").toggle("fast");
		JQ(this).toggleClass("readMoreActive2");
	});
});


//=============================================================================
// travel writing block links

JQ(document).ready(function(){
	JQ(".travelBlock .cols6").click(function(){
	  window.location=JQ(this).find("a").attr("href"); return false;
	});
});
JQ(document).ready(function(){
	JQ(".statsBlock .cols6").click(function(){
	  window.location=JQ(this).find("a").attr("href"); return false;
	});
});





//=============================================================================
// column margins

JQ(document).ready(function(){
	JQ(".cols5 + .cols13").css('margin-right', '0');
	JQ(".cols13 + .cols13").css('padding-top', '0');
	JQ(".cols18 + .cols10").css('padding-top', '0');
	JQ(".cols18 + .cols10 + .cols8").css('padding-top', '0');
	JQ(".cols13 + hr + .cols13").css('padding-top', '0');
	JQ(".cols13 .cols8 + .cols5").css('margin-right', '0');
	JQ(".cols13 + .cols5").css('margin-right', '0');
	JQ(".cols10 + .cols8").css('margin-right', '0');
	JQ(".cols9 + .cols9").css('margin-right', '0');
	JQ(".cols6_5 + .cols6_5").css('margin-right', '0');
	JQ(".cols8 + .cols5 + .cols5").css('margin-right', '0');
	JQ('.travelBlock .cols6:nth-child(4n)').css('margin-right', '0');
	JQ('.cols5bkg .travelBlock .cols6:nth-child(4n)').css('margin-right', '35px');
	JQ('.cols5bkg .travelBlock .cols6').css('width', '322px');
	JQ('.cols5bkg .travelBlock .cols6:nth-child(2n)').css('margin-right', '0');
	JQ('.statsBlock .cols6:nth-child(3n)').css('margin-right', '0');
	JQ('.cols5bkg .statsBlock .cols6:nth-child(3n)').css('margin-right', '35px');
	JQ('.cols5bkg .statsBlock .cols6').css('width', '322px');
	JQ('.cols5bkg .statsBlock .cols6:nth-child(2n)').css('margin-right', '0');
});


//=============================================================================
// map position fixed

JQ(document).ready(function(){
	if (jQuery(window).height() > 750) {
		JQ('.tPlaces .map').css('position', 'fixed');
	}
});


//=============================================================================
// alt table rows

JQ(document).ready(function(){
  JQ("table tr:odd").addClass("alternate");
});


//=============================================================================
// empty table cells

JQ(document).ready(function(){
  JQ("table td:empty").text(' ');
});



//=============================================================================
// map size

JQ(document).ready(function(){
if (!jQuery.browser.msie || parseInt(jQuery.browser.version)>6) {
  JQ(".mapSize").live("click",function(){
		JQ(this).parent().toggleClass("colsPercent100");
		JQ(this).addClass("mapSizeSmaller").removeClass("mapSize");
	});
}
});
	
JQ(document).ready(function(){
if (!jQuery.browser.msie || parseInt(jQuery.browser.version)>6) {
  JQ(".mapSizeSmaller").live("click",function(){
		JQ(this).parent().toggleClass("colsPercent100");
		JQ(this).removeClass("mapSizeSmaller").addClass("mapSize");
	});
}
});




//=============================================================================
// empty table cells

JQ(document).ready(function(){
  JQ(".mapLanding #tab01 .colRight").clone().insertBefore("#tab02 .cols8");
  JQ(".mapLanding #tab01 .colRight").clone().insertBefore("#tab03 .cols8");
});





