// JavaScript Document
//Grab the current URL and get the first part of the path after the server name.
url = location.href;
url_array1 = url.split("//");
url_array2 = url_array1[1].split("/");

var section = url_array2[1];
section = section.toLowerCase();

//Generate a random number for this web-request
var	ord=Math.random()*10000000000000000;

// [sectionname, bannerad(true/false), skyad(true/false)]
var sectionWithAds = new Array(
	['accommodation', true, true],
	['download_shop', true, true],
	['bluelist', true, true],
	['journeys',true,true],
	['responsibletravel',true,true],
	['letters',true,true],
	['lptv',true,true],
	['bluelist_winners',true,true],
	['theme',true,true],
	['podcasts',true,true],
	['yearofadventures', true, false]
);

//Only display the Ads on certain sections of the site.
var showAd = false;
var showBanner = false;
var showSkyscraper = false;

var strBannerAdTop = "";
var strBannerAdSkyscraper = "";

function lpAdsInit()
{
	for(i=0;i<sectionWithAds.length;i++)
	{
		if(section == sectionWithAds[i][0])
		{
			showBanner = sectionWithAds[i][1];
			showSkyscraper = sectionWithAds[i][2];
			showAd = showBanner || showSkyscraper;
		}
	}
	
	//Get reference to the global container DIV
	var divGlobal_Container = document.getElementById('global_container');
	divGlobal_Container.style.position = "relative";
	
	if(showSkyscraper)
	{
		divGlobal_Container.style.width = "942px"; // Make the main content wide enough to fit the skyscraper ad
		
		strBannerAdSkyscraper = '<script language="JavaScript" src="http://ad.doubleclick.net/adj/2009.lonelyplanet/' + section + ';sz=160x600;ptile=2;ord=' + ord + '?" type="text/javascript"><\/script>'
	}
	else
	{
		divGlobal_Container.style.width = '762px'; // Otherwise content width is narrow.
	}
	
	if(showBanner)
	{
		divGlobal_Container.style.paddingTop = "110px"; // Push the main content down to accomodate the banner ad.
		
		strBannerAdTop = '<script language="JavaScript" src="http://ad.doubleclick.net/adj/2009.lonelyplanet/' + section + ';dcopt=ist;sz=728x90;ptile=1;ord=' + ord + '?" type="text/javascript"><\/script>';
	}
}
