function test()
{
//	var sPath = window.location.pathname;
	var sPage = window.location.pathname.substring(sPath.lastIndexOf('/') + 1);
//	alert(sPage);
}

function populateBottomFrame()
{
	var sPath = window.location.pathname;
	var currPage = window.location.pathname.substring(sPath.lastIndexOf('/') + 1);
	var myWidth = 0, myHeight = 0;
	if (currPage == "index.htm" || currPage == "")
		return;
	if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	
	var theFooter = parent.document.getElementById('footerFrame');
	theFooter.style.width = (myWidth - 280) + "px";
	theFooter.innerHTML = "<BR /><BR /><font face='verdana' size='-2' >Wessex Young Athletes Track and Field League 2010</font>";

}

function populateFrontPage()
{
	populateFrames();
	frontPageImage();
} 

function populateFrames()
{
	populateLeftFrame();
	populateTopFrame();
	populateBottomFrame();
}
function populateTopFrame()
{
	var sPath = window.location.pathname;
	var currPage = window.location.pathname.substring(sPath.lastIndexOf('/') + 1);
	var tf;
	if (currPage == "thumbs.htm")
		tf = "<CENTER><img src='../../resources/header/wessex_league.png'><BR>";
	else
		tf = "<CENTER><img src='./resources/header/wessex_league.png'><BR>";
	
	if (currPage == "fixtures.htm")
	{
		tf = tf + "<img src='./resources/header/fixtures.png'>";
	}
	else if (currPage == "results.htm")
	{
		tf = tf + "<img src='./resources/header/results.png'>";
	}
	else if (currPage == "league_table.htm")
	{
		tf = tf + "<img src='./resources/header/league_table.png'>";
	}
	else if (currPage == "timetable.htm")
	{
		tf = tf + "<img src='./resources/header/timetable.png'>";
	}
	else if (currPage == "photos.htm")
	{
		tf = tf + "<img src='./resources/header/photos.png'>";
	}
	else if (currPage == "thumbs.htm")
	{
		tf = tf + "<img src='../../resources/header/photos.png'>";
	}
	else if (currPage == "clubs.htm")
	{
		tf = tf + "<img src='./resources/header/clubs.png'>";
	}
	else if (currPage == "downloads.htm")
	{
		tf = tf + "<img src='./resources/header/downloads.png'>";
	}
	else if (currPage == "league_info.htm")
	{
		tf = tf + "<img src='./resources/header/league_info.png'>";
	}
	else if (currPage == "records.htm")
	{
		tf = tf + "<img src='./resources/header/records.png'>";
	}
	else if (currPage == "past_winners.htm")
	{
		tf = tf + "<img src='./resources/header/past_winners.png'>";
	}
	else
	{
		tf = tf + "<img src='./resources/header/home.png'>";
	}
	tf = tf + "</CENTER>";
	var theTopFrame = parent.document.getElementById('headerFrame');
	theTopFrame.innerHTML = tf;

}
function populateLeftFrame()
{
	var sPath = window.location.pathname;
	var currPage = window.location.pathname.substring(sPath.lastIndexOf('/') + 1);
	var lf = "<H1>";
	var levelsUp = "./"
	if (currPage == "thumbs.htm")
		levelsUp = "../../"
	
	//  Home
	if (currPage == "index.htm" || currPage == "")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Home";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "index.htm'>Home</a>";
	}
	lf = lf + "<P>";
	//  Fixtures
	if (currPage == "fixtures.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Fixtures";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "fixtures.htm'>Fixtures</a>";
	}
	lf = lf + "<P>"
	//  Results
	if (currPage == "results.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Results";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "results.htm'>Results</a>";
	}
	lf = lf + "<P>";
	//  League Table
	if (currPage == "league_table.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>League Table";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "league_table.htm'>League Table</a>";
	}
	lf = lf + "<P>";
	//  Photos
	if (currPage == "photos.htm" || currPage == "thumbs.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>";
		if (currPage == "thumbs.htm")
			lf = lf + "<a href='" + levelsUp + "photos.htm'>Photos</a>";
		else
			lf = lf + "Photos";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "photos.htm'>Photos</a>";
	}
	lf = lf + "<P>";
	//  Timetable
	if (currPage == "timetable.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Timetable";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "timetable.htm'>Timetable</a>";
	}
	lf = lf + "<P>";
	//  Clubs
	if (currPage == "clubs.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Clubs";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "clubs.htm'>Clubs</a>";
	}
	lf = lf + "<P>";
	//  Downloads
	if (currPage == "downloads.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Downloads";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "downloads.htm'>Downloads</a>";
	}
	lf = lf + "<P>";
	//  League Info
	if (currPage == "league_info.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>League Info";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "league_info.htm'>League Info</a>";
	}
	lf = lf + "<P>";
	//  Records
	if (currPage == "records.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Records";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "records.htm'>Records</a>";
	}
	lf = lf + "<P>";
	//  Past Winners
	if (currPage == "past_winners.htm")
	{
		lf = lf + "<img src='" + levelsUp + "resources/arrow.jpg'>Past Winners";
	}
	else
	{
		lf = lf + "<a href='" + levelsUp + "past_winners.htm'>Past Winners</a>";
	}
	lf = lf + "</H1>";
	lf = lf + "<BR><BR><img src='" + levelsUp + "resources/sd-advert.gif'>";
	var theLeftFrame = parent.document.getElementById('leftFrame');
	theLeftFrame.innerHTML = lf;
//	alert('done');
}

function frontPageImage()
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	var theContent = parent.document.getElementById('content');
	var thePhoto = parent.document.getElementById('front_page_image');
	thePhoto.style.top = "" + (myHeight - 120 - 540) + "px";
	thePhoto.style.left = "" + (myWidth - 270 - 682) + "px";
	//  Choose a Random Photo
	var randnum = Math.random();
	if (randnum < 0.14)
	{	
		thePhoto.src = "./resources/front_page/001.jpg";
	}
	else if (randnum < 0.29)
	{
		thePhoto.src = "./resources/front_page/002.jpg";	
	}
	else if (randnum < 0.43)
	{
		thePhoto.src = "./resources/front_page/003.jpg";	
	}
	else if (randnum < 0.57)
	{
		thePhoto.src = "./resources/front_page/004.jpg";	
	}
	else if (randnum < 0.71)
	{
		thePhoto.src = "./resources/front_page/005.jpg";	
	}
	else if (randnum < 0.86)
	{
		thePhoto.src = "./resources/front_page/006.jpg";	
	}
	else
	{
		thePhoto.src = "./resources/front_page/007.jpg";	
	}
}

function ToggleSpan(SpanId, ImgID)
{
	var Rollup = document.all.item(SpanId);
	var RollupImg = document.all.item(ImgID);
	var ToggleExpand = './resources/ToggleExpand.gif';
	var ToggleCollapse = './resources/ToggleCollapse.gif';
	Rollup.style.display = (Rollup.style.display=='none' ? 'block' : 'none');
	RollupImg.src = (Rollup.style.display=='none' ? ToggleExpand : ToggleCollapse);
}

function LoadIFrameMaps()
{
	var clickToShowDiv = parent.document.getElementById('clickToShowMaps');
	clickToShowDiv.style.display = 'none';	
	var pleaseBePatientDiv = parent.document.getElementById('pleaseBePatient');
	pleaseBePatientDiv.style.display = 'block';	

	setTimeout("LoadMap('andoverMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.218954030812%2C-1.511092185974121&mlatlng=51.218758%2C-1.512647&maddress1=W%20Portway&maddress2=Andover%2C%20Hampshire%20SP10%2C%20UK&zoom=16&mtitle=Andover%20Track');", 500);
	
	setTimeout("LoadMap('basingstokeMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.249224227187305%2C-1.1274504661560059&mlatlng=51.249355%2C-1.126844&maddress1=Pack%20Ln&maddress2=Basingstoke%2C%20Hampshire%20RG22%205%2C%20UK&zoom=16&mtitle=Basingstoke%20Track');", 500);

	setTimeout("LoadMap('bournemouthMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.73373899598955%2C-1.836090087890625&mlatlng=50.732717%2C-1.835787&maddress1=Kings%20Park%20Dr&maddress2=Bournemouth%2C%20Dorset%20BH7%2C%20UK&zoom=16&mtitle=Bournemouth%20Track');", 500);
	
	setTimeout("LoadMap('portsmouthMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.82522684279047%2C-1.084449291229248&mlatlng=50.824346%2C-1.084921&maddress1=Twyford%20Ave&maddress2=Portsmouth%2C%20Hampshire%20PO2%2C%20UK&zoom=16&mtitle=Portsmouth%20Track');", 500);
	 
	setTimeout("LoadMap('iowMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.658752134660084%2C-1.1670398712158203&mlatlng=50.657991%2C-1.167078&maddress1=Sandown%20PO36%209JH&maddress2=UK&zoom=16&mtitle=Isle%20of%20Wight%20Track');", 500);
	
	setTimeout("LoadMap('marlboroughMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.41390247722688%2C-1.7402386665344238&mlatlng=51.414588%2C-1.740743&maddress1=Marlborough%2C%20Wiltshire%20SN8%201PA&maddress2=UK&zoom=16&mtitle=Marlborough%20Junior%20Track');", 500);
	
	setTimeout("LoadMap('newburyMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.380580217022185%2C-1.2517547607421875&mlatlng=51.379994%2C-1.249523&maddress1=Thatcham%2C%20Berkshire%20RG19%208ET&maddress2=UK&zoom=16&mtitle=Newbury%20Track');", 500);
	
	setTimeout("LoadMap('oxfordMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.737509%2C-1.188052&mlatlng=51.737509%2C-1.188052&maddress1=Oxford%20OX4%202RR&maddress2=UK&zoom=16&mtitle=Oxford%20City%20Track');", 500);
	
	setTimeout("LoadMap('pooleMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.74885232011317%2C-1.96929931640625&mlatlng=50.748574%2C-1.968184&maddress1=Poole%2C%20Dorset%20BH17%208PY&maddress2=UK&zoom=16&mtitle=Poole%20Track');", 500);
	
	setTimeout("LoadMap('pooleRunnersMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.74885232011317%2C-1.96929931640625&mlatlng=50.748574%2C-1.968184&maddress1=Poole%2C%20Dorset%20BH17%208PY&maddress2=UK&zoom=16&mtitle=Poole%20Track');", 500);
	
	setTimeout("LoadMap('sloughMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.49497121591795%2C-0.596308708190918&mlatlng=51.495192%2C-0.594747&maddress1=Windsor%2C%20Berkshire%20SL4%206HN&maddress2=UK&zoom=16&mtitle=Slough%20Junior%20Track');", 500);
	
	setTimeout("LoadMap('teamKennetMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.380580217022185%2C-1.2517547607421875&mlatlng=51.379994%2C-1.249523&maddress1=Thatcham%2C%20Berkshire%20RG19%208ET&maddress2=UK&zoom=16&mtitle=Team%20Kennet%20Track');", 500);
	
	setTimeout("LoadMap('teamSouthamptonMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.941150260423946%2C-1.41923189163208&mlatlng=50.940124%2C-1.420444&maddress1=Southampton%2C%20Hampshire%20SO16%207AY&maddress2=UK&zoom=16&mtitle=Team%20Southampton%20Track');", 500);
	
	setTimeout("LoadMap('weymouthMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=50.6075367889526%2C-2.4669456481933594&mlatlng=50.607741%2C-2.466779&maddress1=Weymouth%2C%20Dorset%20DT4%200HS&maddress2=UK&zoom=16&mtitle=Weymouth%20St%20Pauls%20Track');", 500);
	
	setTimeout("LoadMap('winchesterMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.05451946197769%2C-1.3032746315002441&mlatlng=51.054503%2C-1.305975&maddress1=Winchester%2C%20Hampshire%20SO23%209NP&maddress2=UK&zoom=16&mtitle=Winchester%20Track');", 500);
	
	setTimeout("LoadMap('wokingMapFrame', 'http://www.google.com/uds/modules/elements/mapselement/iframe.html?maptype=hybrid&latlng=51.33483474362762%2C-0.5317425727844238&mlatlng=51.334848%2C-0.5323&maddress1=Woking%2C%20Surrey%20GU21%205NW&maddress2=UK&zoom=16&mtitle=Woking%20Track');", 500);
	
	
	setTimeout("HidePleaseBePatient();", 2000);
}

function LoadMap(mapID, mapSRC)
{
	var aMap = parent.document.getElementById(mapID);
	aMap.src=mapSRC;
}

function HidePleaseBePatient()
{
	var pleaseBePatientDiv = parent.document.getElementById('pleaseBePatient');
	pleaseBePatientDiv.style.display = 'none';
}

