function popUp(URL) 
{
	day = new Date();
	id = day.getTime();
	window.open(URL, '','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=500 ');
}

function frontPageLoad()
{
	generateHeader('');
	var newsDiv = document.getElementById('latestNewsDiv');
	if (newsDiv)
		newsDiv.innerHTML = giveLatestNews();
		
	var updatesDiv = document.getElementById('latestUpdatesDiv');
		updatesDiv.innerHTML = giveLatestUpdates();
		
	var trackFixturesDiv = document.getElementById('nextFixturesDiv');
	{
		if (giveUpcomingFixtures() != "")
			trackFixturesDiv.innerHTML = "<b><font face='verdana' size='-1'>Upcoming Track Fixtures:</font></b><BR>" + giveUpcomingFixtures();
	}
}

function newsArchivesLoad()
{
	generateHeader('BAC : News Archives', 1);
	var archivesDiv = document.getElementById('newsArchivesDiv');
	if (archivesDiv)
		archivesDiv.innerHTML = giveNewsArchives();	
}

//  MENU FUNCTIONS

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id, spanID, levelsUp)
{	
	// cancel close timer
	mcancelclosetime();

	document.getElementById(spanID).style.background = '#FFFF00 url(' + levelsUp + 'resources/navrh-article.gif) right top no-repeat';

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	if (ddmenuitem)
		ddmenuitem.style.visibility = 'visible';
	
}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	giveInfo('');

}

// go close timer
function mclosetime(spanID, levelsUp)
{
	closetimer = window.setTimeout(mclose, timeout);
	var spanIDEl = document.getElementById(spanID);
	if (spanIDEl)
		spanIDEl.style.background = '#0000FF url(' + levelsUp + 'resources/navr-article.gif) right top no-repeat';
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

function giveInfo(theSection)
{
	var theInfoBox = document.getElementById('InfoBox');
	if (theInfoBox == null)
		return;
	var theInfo = "<!-- img src='./front_page/frontpage_photo1.jpg' -->";
	if (theSection == "club_news")
		theInfo = "<B>News Archives</B><BR>Latest club news from BAC (for results see the track or Road / XC results sections)";
	else if (theSection == "membership")
		theInfo = "<b>Membership</b><br>Membership forms, Training Details and Fees";
	else if (theSection == "training")
		theInfo = "<b>Training Details</b><br>Training at Kings Park Athletic Centre";
	else if (theSection == "sportshall")
		theInfo = "<b>Sportshall Information & Results</b><br>BAC competes in the Dorset Sportshall league";
	else if (theSection == "photos")
		theInfo = "<b>Photos</b><BR>Photos of BAC Athletes in action <i>(Currently awaiting Content)</i>";
	else if (theSection == "about_club")
		theInfo = "<b>About the Club</b><br>A Brief history of the club and the current club organisation.";
	else if (theSection == "find_us")
		theInfo = "<b>Find Us</b><br>Location and Map to Kings Park Athletic Centre";
	else if (theSection == "history")
		theInfo = "<b>History</b><br>A detailed history of Bournemouth Athletic Club";
	else if (theSection == "codes_of_conduct")
		theInfo = "<b>Codes of Conduct</b><br>Bournemouth AC policies for Sport Equality and Codes of Conduct";
	else if (theSection == "constitution")
		theInfo = "<b>Constitution & Rules</b><br>Bournemouth AC Commitment to its members";
	else if (theSection == "track_fixtures")
		theInfo = "<b>Track Fixtures</b><br>This year's track fixtures for all leagues BAC competes in and select championships";
	else if (theSection == "track_results")
		theInfo = "<b>Track Results</b><br>Comprehensive results for BAC athletes";
	else if (theSection == "track_standings")
		theInfo = "<b>League Standings</b><br>Position of BAC in the leagues in which it competes";
	else if (theSection == "track_rankings")
		theInfo = "<b>Annual Rankings</b><br>Ranked performances of BAC athlets.  More inclusive and dedicated than Power of 10";
	else if (theSection == "track_topscorers")
		theInfo = "<b>Top Scorers</b><br>Highest scoring athletes for BAC in league competitions";
	else if (theSection == "track_openmeetings")
		theInfo = "<b>Open Meetings</b><br>Local open meeting entry forms and timetables which may be of interest to members";
	else if (theSection == "track_records")
		theInfo = "<b>Club Records</b><br>Bournemouth AC track records";
	else if (theSection == "track_alltime")
		theInfo = "<B>All Time Track Lists</b><BR>All Time Best BAC Track results";
	else if (theSection == "track_progression")
		theInfo = "<b>Track Progression</b><br>Charting BAC Athletes' performances over time";
	else if (theSection == "track_liveresults")
		theInfo = "<b>Live Results</b><br>Results from selected matches hosted by <font color='#0000FF'>Bournemouth AC</font> will be available in real time from this page";
	else if (theSection == "jon_sharkey")
		theInfo = "<b>Jon Sharkey's Page</b><BR>Up until April 2010 the best source of BAC Road and Cross Country News and Results";
	else if (theSection == "cross_country")
		theInfo = "<b>Cross Country</b><BR>Results and other information about our Cross Country Teams";
	else if (theSection == "road")
		theInfo = "<b>Road Running</b><BR>Results and other information about our Road Running Teams";
	else if (theSection == "road-championships")
		theInfo = "<b>Road Running</b><BR>Club Championships, 10k, Ten Mile and Half Marathon";
	else if (theSection == "road-latestresults")
		theInfo = "<b>Road Running Latest Results</b><BR>Quick link to the Road Running page but be taken directly to the latest (non league) results";
	else if (theSection == "marathon_bests")
		theInfo = "<b>Marathon Bests</b><BR>BAC all time marathon times";

	theInfoBox.innerHTML="" + theInfo;
}

// close layer when click-out
//document.onclick = mclose;

function generateHeader(headerText, nLevelsUp)
{
	return generateHeaderThreeLine(headerText, "", "", true, nLevelsUp);
}

//  HEADER FUNCTIONS
function generateHeaderThreeLine(lineOne, lineTwo, lineThree, singleLine, nLevelsUp)
{
var CURRENT_YEAR = "2012";

var levelsUp = "./"
while (nLevelsUp > 0)
{
	levelsUp = levelsUp + "../";
	nLevelsUp--;
}

//  Populates the Header
var head = "";
head = head + "<table border='0' width='100%'>";
head = head + "<tr><td rowspan='2' valign='top' width=87>";
head = head + "<a href='" + levelsUp + "index.htm'><img src='" + levelsUp + "resources/logo_big.jpg'></a></td><td valign='top' width=744>"
if (lineOne == "")
	head = head + "<img src='./front_page/head_frontpage.png'>";
else if (singleLine)
	head = head + "<div style='font-size:40pt; font-weight:bold; font-family:Tahoma, arial; color:#0000FF'><nobr>" + lineOne + "</nobr></div>";
else
{
	head = head + "<div style='font-size:15pt; padding-left:60px; font-weight:bold; font-family:Tahoma, arial; color:#0000FF'>" + lineOne + "<BR>";
	head = head + lineTwo + "<BR>";
	head = head + lineThree + "</div>";
}
head = head + "</td>";
head = head + "</tr>";
head = head + "<tr><td valign='center'>";
head = head + "<ul id='sddm'>";
head = head + "<li><span id='hs_home'><a href='" + levelsUp + "index.htm' target='_top' onmouseover=\"mopen('head_home', 'hs_home', '" + levelsUp + "')\" ";
head = head + "onmouseout=\"mclosetime('hs_home', '" + levelsUp + "')\">HOME</a></span></li>";
head = head + "<li><span id='hs_club'><a href='#'";
head = head + "onmouseover=\"mopen('head_club', 'hs_club', '" + levelsUp + "')\"";
head = head + "onmouseout=\"mclosetime('hs_club', '" + levelsUp + "')\">The Club</a></span>";
head = head + "		<P>";
head = head + "<div id='head_club'";
head = head + "onmouseover=\"mcancelclosetime()\"";
head = head + "onmouseout=\"mclosetime('', '" + levelsUp + "')\">";
head = head + "<a href='" + levelsUp + "news/index.htm' target='_top' onmouseover=\"giveInfo('club_news')\">News Archives</a>";
head = head + "<a href='" + levelsUp + "membership/index.htm' target='_top' onmouseover=\"giveInfo('membership')\">Membership</a>";
head = head + "<a href='" + levelsUp + "training/index.htm' target='_top' onmouseover=\"giveInfo('training')\">Training</a>";
head = head + "<a href='" + levelsUp + "sportshall/index.htm' target='_top' onmouseover=\"giveInfo('sportshall')\">Sportshall</a>";
head = head + "<a href='" + levelsUp + "photos/index.htm' target='_top' onmouseover=\"giveInfo('photos')\">Photos</a>";
head = head + "<a href='" + levelsUp + "about/index.htm' target='_top' onmouseover=\"giveInfo('about_club')\">About the Club</a>";
head = head + "<a href='" + levelsUp + "location/index.htm' target='_top' onmouseover=\"giveInfo('find_us')\">Find Us</a>";
head = head + "<a href='" + levelsUp + "history/index.htm' target='_top' onmouseover=\"giveInfo('history')\">History</a>";
head = head + "<a href='" + levelsUp + "codes_of_conduct/index.htm' target='_top' onmouseover=\"giveInfo('codes_of_conduct')\">Codes of Conduct</a>";
head = head + "<a href='" + levelsUp + "constitution/index.htm' target='_top' onmouseover=\"giveInfo('constitution')\">Constitution</a>";
head = head + "</div>";
head = head + "</li>";
head = head + "<li><span id='hs_tf'><a href='#' ";
head = head + "onmouseover=\"mopen('head_tf', 'hs_tf', '" + levelsUp + "')\" ";
head = head + "onmouseout=\"mclosetime('hs_tf', '" + levelsUp + "')\">Track & Field</a></span>";
head = head + "		<P>";
head = head + "<div id='head_tf' ";
head = head + "onmouseover=\"mcancelclosetime()\" ";
head = head + "onmouseout=\"mclosetime('hs_tf', '" + levelsUp + "')\">";
head = head + "<a href='" + levelsUp + "track/fixtures/index.htm' target='_top' onmouseover=\"giveInfo('track_fixtures')\">Track Fixtures " + CURRENT_YEAR + "</a>";
head = head + "<a href='" + levelsUp + "track/results/index.htm' target='_top' onmouseover=\"giveInfo('track_results')\">Track Results</a>";
head = head + "<a href='" + levelsUp + "track/league_standings/index.htm' target='_top' onmouseover=\"giveInfo('track_standings')\">League Standings " + CURRENT_YEAR + "</a>";
head = head + "<a href='" + levelsUp + "track/rankings/index.htm' target='_top' onmouseover=\"giveInfo('track_rankings')\">Rankings " + CURRENT_YEAR + "</a>";
head = head + "<a href='" + levelsUp + "track/topscorers/index.htm' target='_top' onmouseover=\"giveInfo('track_topscorers')\">Top Scorers " + CURRENT_YEAR + "</a>";
head = head + "<a href='" + levelsUp + "track/openmeetings/index.htm' target='_top' onmouseover=\"giveInfo('track_openmeetings')\">Open Meetings " + CURRENT_YEAR + "</a>";
head = head + "<a href='" + levelsUp + "track/progression/index.htm' target='_top' onmouseover=\"giveInfo('track_progression')\">Member Progression</a>";
head = head + "<a href='" + levelsUp + "track/records/index.htm' target='_top' onmouseover=\"giveInfo('track_records')\">Club Records</a>";
head = head + "<a href='" + levelsUp + "track/alltimelists/index.htm' target='_top' onmouseover=\"giveInfo('track_alltime')\">All Time Lists</a>";
//head = head + "<a href='" + levelsUp + "track/liveresults/index.htm' target='_top' onmouseover=\"giveInfo('track_liveresults')\">Live Results</a>";
head = head + "</div>";
head = head + "</li>";
head = head + "<li><span id='hs_rxc'><a href='#' ";
head = head + "onmouseover=\"mopen('head_rxc', 'hs_rxc', '" + levelsUp + "')\" ";
head = head + "onmouseout=\"mclosetime('hs_rxc', '" + levelsUp + "')\">Road & Cross Country</a></span>";
head = head + "		<P>";
head = head + "<div id='head_rxc' ";
head = head + "onmouseover=\"mcancelclosetime()\" ";
head = head + "onmouseout=\"mclosetime('hs_rxc', '" + levelsUp + "')\">";
head = head + "<a href='http://www.sharkey.f9.co.uk/bac/' target='_top' onmouseover=\"giveInfo('jon_sharkey')\">Jon Sharkey\'s Page</a>";
head = head + "<a href='" + levelsUp + "cross_country/index.htm' target='_top' onmouseover=\"giveInfo('cross_country')\">Cross Country</a>";
head = head + "<a href='" + levelsUp + "road/index.htm' target='_top' onmouseover=\"giveInfo('road')\">Road Running</a>";
head = head + "<a href='" + levelsUp + "road/championships/index.htm' target='_top' onmouseover=\"giveInfo('road-championships')\">Road Running - Club Championships</a>";
head = head + "<a href='" + levelsUp + "road/index.htm#other_results' target='_top' onmouseover=\"giveInfo('road-latestresults')\">Road Running - Latest Results</a>";
head = head + "<a href='" + levelsUp + "road/marathon_bests/index.htm' target='_top' onmouseover=\"giveInfo('marathon_bests')\">Marathon Bests</a>";
head = head + "</div>";
head = head + "</li>";
head = head + "</ul>";
head = head + "</td></tr>";
head = head + "</table>";
head = head + "<P>";
document.getElementById('headerText').innerHTML = head;
}


