
var menu_id = 0;
var style = 0;
var level = 0;
var linkprefix = '';

function cOn(tr){
	tr.style.backgroundColor="#cc9933";
}

function cOut(tr){
	tr.style.backgroundColor="#ffffcc";
}

function showIt(id) {
	if (document.layers) document.layers[id].visibility = "show"
	else if (document.getElementById) document.getElementById(id).style.visibility = "visible"
	else if (document.all && !(document.getElementById)) document.all(id).style.visibility = "visible"
}

function hideIt(id) {
	if (document.layers) document.layers[id].visibility = "hide"
	else if (document.getElementById) document.getElementById(id).style.visibility = "hidden"
	else if (document.all && !(document.getElementById)) document.all(id).style.visibility = "hidden"
}

function setLevel(newlevel) {
	level = newlevel;
	for (l = 0; l < newlevel; l++) {
		linkprefix = linkprefix + '../';
	}
}

function writeHeader() {

	document.write('<div class="box">');
	document.write('<table width="779px" cellpadding=10 cellspacing=0 bgcolor=#ffffff align="center" style="border-right:1px solid #cccccc; border-left:1px solid #cccccc; border-bottom:6px solid #cccccc;">');
	document.write('<tr>');
	document.write('<td align="left"><a href="index.html" target="_top"><img src="' + linkprefix + 'images/clublogo.jpg" width="278" height="107" alt="MX5 Owners Club" border="0"></a></td>');
	document.write('<td width="40%" align="right" valign="bottom"><p class="maintitle">Wessex Area</p></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('<table width=779px cellpadding=10 align="center" bgcolor="#ffffff" style="border-right:1px solid #cccccc; border-left:1px solid #cccccc; border-bottom:6px solid #cccccc;"><tr>');
	document.write('<td class="menu" width=145 valign=top>');
}

function writeFooter() {
	document.write('</td>');
	document.write('</tr></table>');
	document.write('<div id=footer>');
	document.write('If you have any comments or questions please e-mail <a href="mailto:allan@legg8.orangehome.co.uk">Allan Legg</a><br>If you have any comments or suggestions for the website please e-mail <a href="mailto:jasonandjulie@bullfinch.freeserve.co.uk">Jason and Julie</a>. Last updated on 08/11/2008');
	document.write('</div>');
	document.write('</div>');
}
	
function writeAllMenus(menu_id) {

	document.write('<br>');

	writeMenu(1, 'Home' , 'index.html');
	writeMenu(2, 'Wessex Area' , 'wessex_info.html');
	writeMenu(3, 'Monthly Newsletter' , 'newsletter.html');
	if ( menu_id == 3 ) {
		writeMenu(3.1,'Recent newsletters' , 'newsletter.html' , 1);
		writeMenu(3.2,'Archived newsletters' , 'newsletter2.html' , 1);		
		}
	writeMenu(4, 'Join the Club' , 'http://www.mx5ocforum.co.uk/documents/mx5oc_membership_form.pdf' , 0, 1);
	writeMenu(10,'Forthcoming Events' , 'events.html');
//	writeMenu(11,'Charity Events','charity.html');
	writeMenu(12,'Previous Events' , 'previous_events.html');
	if ( menu_id == 12 ) {
		writeMenu(12.2004,'Sunday Events' , 'previous_events/sunday2004.html' , 1);
//		writeMenu(12.2003,'Monthly Events' , 'previous_events/monthly.html' , 1);
//		writeMenu(12.2002,'National Events' , 'previous_events/national.html' , 1);
	}	
	writeMenu(20,'Gallery' , 'gallery.html');
	writeMenu(21,'Holiday Snaps' , 'holiday_snaps.html');
//	writeMenu(30,'Lulworth Rally' , 'lulworth.html');
	if ( menu_id == 30 ) {
//		writeMenu(30.2003,'2003' , 'lulworth/lulworth2003.html' , 1);
//		writeMenu(30.2002,'2002' , 'lulworth/lulworth2002.html' , 1);
	}
//  writeMenu(40,'Merchandise' , 'merchandise.html');
	writeMenu(41,'For Sale' , 'forsale.html');
	writeMenu(50,'Links' , 'links.html');

	document.write('</td><td valign=top>');
}

function writeMenu(number, name, pagename, style, noprefix) {
	document.write('<table border="0" width="145" cellpadding="3" cellspacing="0"><tr><td bgcolor="#ffffff" width="100%" align="right"  style="border-bottom: 1px solid #cccccc;"><a ');
	if (style == 1) document.write('class="submenu"');
	if (noprefix == 1) {
	document.write(' href="' + pagename + '" onmouseover="showIt(' + "'dot" + number + "'" + ");window.status='" + name + "'" + ';return true" onmouseout="hideIt(' + "'dot" + number + "'" + ");window.status='';return true" + '"' + '>' + name + '</a></td><td width="15"><span class="arrow" id="dot' + number + '"><img src="' + linkprefix + 'images/menu_arr.gif" width="12" height="12" alt="" border="0"></span></td></tr></table>');
	}
	else {
	document.write(' href="' + linkprefix + pagename + '" onmouseover="showIt(' + "'dot" + number + "'" + ");window.status='" + name + "'" + ';return true" onmouseout="hideIt(' + "'dot" + number + "'" + ");window.status='';return true" + '"' + '>' + name + '</a></td><td width="15"><span class="arrow" id="dot' + number + '"><img src="' + linkprefix + 'images/menu_arr.gif" width="12" height="12" alt="" border="0"></span></td></tr></table>');
	
	}
}

function writeEvent(datestr, textstr, image, day, month, year) {

	
	var currday = new Date();
 	var eventday = new Date(year, month-1, day);
	
    if (eventday > currday) {
	
	document.write('<td width="160px" valign="top"><b>' + datestr + '</b></td>');
	document.write('<td valign="top">' + textstr + '</td>');
	document.write('<td align="center">');
	if (image == '') {
		document.write('</td>');
	}
	else {
		document.write('<img border="0" src="' + image + '" alt=""></td>');
	}
	document.write('</tr>');
	
    }
}

function writePrevEvent(datestr, textstr, textaddr, image) {
	document.write('<td valign="middle"><b>' + datestr + '</b></td>');
	document.write('<td valign="middle"><a href="' + textaddr + '">' + textstr + '</a></td>');
	document.write('<td align="center">');
	if (image == '') {
		document.write('</td>');
	}
	else {
		document.write('<img border="0" src="' + image + '" alt=""></td>');
	}
	document.write('</tr>');
	document.write('<tr>');
	document.write('<td colspan="3">&nbsp;</td>');
	document.write('</tr>');
}
