/*
date :   28.11.01 
author:  danny.callaghan@freeserve.com
file:    create.js
owner:   trev@nufc-london.com

This script writes out the header (the London Mags banner, contact email address, and today's date),
and the footer (last updated and the copyright info), and the nav bar on the left hand side.
Shouldn't need to edit anything below here
*/

function writeHeaderandNav(){
  writeBannerMap();
  writeBanner();
  openContents();
  writeHeader();
  writeNavigation();
}

function writeHeader(){
  /* Header line */
  writeSpacer();
  document.write('<tr style="background-color:'+navBgColour+'; height:20px">');
    document.write('<td style="border-top: 1px solid #333333; border-bottom: 1px solid #333333; border-left: 1px solid #333333"><span class="headertext">Contact: <a href="mailto:'+emailAddress+'" class="contact">'+emailName+'</a></span></td>');
    document.write('<td style="border-top: 1px solid #333333; border-bottom: 1px solid #333333">&nbsp;</td><td style="border-top: 1px solid #333333; border-bottom: 1px solid #333333; border-right: 1px solid #333333; text-align: right"><span class="headertext">'+TodayIs+'</span></td>');
  document.write('</tr>');
  writeSpacer();
}

function writeFooter(){

  /* Close main content cell and content row */
  document.write('<br></td>');
     document.write('</tr>');
    
    /* Footer line */
    writeSpacer();
    document.write('<tr style="background-color:'+navBgColour+'; border: 1px solid #333333; height:20px">');
      document.write('<td style="border-top: 1px solid #333333; border-bottom: 1px solid #333333; border-left: 1px solid #333333"><span class="headertext">Last updated: '+DocDate()+'</span></td>');
			document.write('<td style="border-top: 1px solid #333333; border-bottom: 1px solid #333333">&nbsp;</td><td  style="border-top: 1px solid #333333; border-bottom: 1px solid #333333; border-right: 1px solid #333333; text-align: right"><span class="copyRight">&copy; '+copyRight+' All rights reserved.</span></td>');
    document.write('</tr>');
    writeSpacer();

  /* Close content table and other divisions */
  document.write('</table>');
  document.write('</div>');
  document.write('</div>');
  document.write('</center>');
}

function writeBanner(){
  /* Initial stuff */
	document.write('<center>');
  document.write('<div align="center" style="position: relative; top: 0px; left: 0px; width:'+screenWidth+'">');
	
  /* Banner */
  document.write('<div id="banner" style="position: absolute; top: 0px; left: 0px; width:'+screenWidth+'; border: 1px solid #333333; background-color: #ffffff">');
    document.write('<img src="'+rootDir+'images/'+bannerImage+'" width="640" height="110" border="0" usemap="#' + bannerMap.name + '" alt="banner">');
  document.write('</div>');
}

function writeBannerMap(){
  // banner heading links map
	
	if (bannerMap != null) {
    document.write('<map name="'+bannerMap.name+'">');
		for (i=0; i<bannerMap.regions.length; i++) {
    document.write('<area shape="rect" coords="' + bannerMap.regions[i].x1 + ', ' + bannerMap.regions[i].y1 + ', ' + bannerMap.regions[i].x2 + ', ' + bannerMap.regions[i].y2 + ', ' + '" ' + bannerMap.regions[i].attr + ' />');
		}
    document.write('</map>');
	}
}

function openContents(){
  /* Open content table and write header */
  document.write('<div id="table" style="position: absolute; top: 112px; left: 0px;">');
  document.write('<table style="border="0" cellpadding="0" cellspacing="0" width="' + screenWidth + '" summary="navigation, spacer and main content columns">');
}

function writeNavigation(){
  /* Navigation panel: spacer, three vertical sections */
  document.write('<tr>');
    document.write('<td style="background-color:#999999; border: 1px solid #333333; width:160px; height:'+minHeight+'px; text-align: center; vertical-align: top">');
		
		document.write('<img src="'+rootDir+'images/t.gif" width="150" height="7" border="0" alt="">');

    for (m = 0; m < menuSections.items.length; m ++){
    
      if (menuSections.items[m].items.length > 0) {
        writeNavLabel(menuSections.items[m].heading, menuSections.items[m].url);
    	}
    	
    	for (i = 0; i < menuSections.items[m].items.length; i ++){
        writeNavItem(menuSections.items[m].items[i].title, menuSections.items[m].items[i].url, menuSections.items[m].target)
      }
    }
		
		document.write('<img src="'+rootDir+'images/t.gif" width="150" height="7" border="0" alt="">');
    document.write('</td>');
  
    /* Spacer column */
    document.write('<td>');
    		document.write('<img src="'+rootDir+'images/t.gif" width="5" height="1" border="0" alt="spacer">');
    document.write('</td>');
  
  	/* Open main content cell */
  	document.write('<td class="text" style="background-color:'+mainBgColour+'; border: 1px solid #333333; height:'+minHeight+'px; vertical-align: top">');
		document.write('<img src="'+rootDir+'images/t.gif" width="150" height="7" border="0" alt=""><br>');
}

function writeNavLabel(label, url){
    if (url == null) {
		document.write('<br><div class="navtext" style="margin: auto; background-color: '+navLabelBgColour+'; color: '+navLabelTextColour+'; width:140px; border: 1px solid #333333;">'+label+'</div>');
		}
		else {
    document.write('<br><div class="navtext" style="margin: auto; background-color: '+navLabelBgColour+'; color: '+navLabelTextColour+'; width:140px; border: 1px solid #333333;">'+'<a href="'+url+'">'+label+'</a></div>');
		}
}

function writeNavItem(title, url, target){
    if (target == null) {
				document.write('<a href="'+url+'" class="nav">'+title+'</a><br>');
		}
		else {
				document.write('<a href="'+url+'" class="nav" target="'+target+'">'+title+'</a><br>');
		}
}

function writeSpacer(){
  document.write('<tr>');
  	document.write('<td style="vertical-align: top" colspan="3">');
  			document.write('<img src="'+rootDir+'images/t.gif" width="1" height="5" border="0" alt="spacer">');
  	document.write('</td>');
  document.write('</tr>');
}

function getLongDateString(){
	monthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	dayOfMonth = (this.getDate() < 10)?"0"+this.getDate().toString():this.getDate();
  dateStr = dayOfMonth+" "+monthNames[this.getMonth()]+" "+this.getFullYear();
	return dateStr;
}

function DocDate(){
	DateTimeStr = document.lastModified;
	secOffset = Date.parse(DateTimeStr);
	if (secOffset == 0 || secOffset == null)
			 dateStr = "Unknown";
	else{
		aDate = new Date();
		aDate.setTime(secOffset);
		datestr = aDate.getLongDateString();
	}
	return dateStr;
}

Date.prototype.getLongDateString=getLongDateString;

var now = new Date();
var TodayIs = now.getLongDateString()

defaultStatus = 'Newcastle United Supporters Club - London'