// MISCELLANEOUS FUNCTIONS
// DO NOT NEED database.js

// :: FUNCTIONS
// getObj(name)
// findPosX(obj)
// findPosY(obj)
// moveObj(name)
// getFilename(href) - Returns filename part without domain
// setHTML(ObjID,HTML) - Calls getObj()
// f_rtnDatabaseState()
// f_rtnIfDatabaseError() - Only rtns msg if there is an error with the database (ie. Out of date)
// siteUrl()
// errMsg(Msg)
// f_w3cIcons()
// setCookie(cookieName, cookieValue, expires, path, domain, secure)
// getCookie(cookieName)
// isValidData(Msg) - CHECKS 1st CHAR FOR _NODATA t/f
// validateData(Msg) - REMOVES 1st CHAR IF _NODATA FOUND, RTNS CLEAN STRING
// goUrl(Url) - SET BROWSER TO SPECIFIED URL
// f_textArea(Text)
// f_rtnMonth(No) - PASS MONTH NUMBER 0..11, RETURNS STRING OF MONTH
// f_rtnDay(No) - PASS DAY NUMBER 0..6, RETURNS STRING OF WEEK DAY
// f_rtnDate(No) - PASS DATE (1..31), RETURNS STRING OF THE FORM '17th'
// f_formatDateStr(DateStr,LongVersion,IncDay) - FORMATS DATE STRING
// lastMod()
// takeYear(theDate)
// f_daysAgo(test_date) - RETURNS NUMBER OF DAYS AGO, THE DATE test_date ('d/m/yyyy') OCCURRED
// f_daysAgoStr(daysago) - RETURNS STRING OF THE FORM... "5 days ago", "2 weeks ago" etc.
// strip(filestr)
// f_openWin(file,width,height)
// f_popupWin(file,height) - Calls f_openWin()
// f_formatScore(Num) - WILL RTN STR WITH &frac12; IF NEEDED
// f_fixtureScore(Score) - PASS '3.5-5.5', CALLS f_formatScore(Num)
// writeNew(type,new_date,no_days) - USE rtnNew() INSTEAD!
// rtnNew(type,new_date,no_days,extra_txt)
// f_BNB(Rating)
// grabUrlParam()
// showImg(Image,Title,Desc,W,H)

// :: COMMON DISPLAY FUNCTIONS
// f_header(Title,Desc,Icon,IconW,IconH,Website,LastModDate,Popup)
// f_venueHeader(Title,Address,Website)
// f_infoHeader(Title,Desc,Popup)
// f_backToTop()
// copyR()
// f_webCounter()
// f_footer(TopLink,LastModDate)

// sf_banner(Page,Title,Desc,Icon,W,H)
// selectSeason() - Called from sf_banner()
// changeSeason(NewSeasonID) - Called from onChange on <select>
// f_menuItem(Text,Link,Desc)
// f_menuSubItem(Text,Link,Desc)
// f_menuSpacer(y)
// sf_index(Page)
// f_container(Title,Link,Body,Highlight)


// CONSTANTS
var _NODATA = ':';		// 1st CHAR THAT INDICATES 'NO DATA'
var _TOP = true;			// TO-TOP LINK
var _NOTOP = false;
var _LASTMOD = true;		// INCLUDE DATE LAST MODIFIED
var _NOLASTMOD = false;
var _POPUP = true;		// POPUP WINDOW (SHOW CLOSE/PRINT BTNs IN HEADER)
var _NOPOPUP = false;
var _NEW = 'new';			// writeNew()/rtnNew() functions below
var _UPDATED = 'updated';
var _COMPACT = 'compact';	// Displays compact graphic
var _HOME = 'home';		// HOMEPAGE
var _INDEX_WIDTH = 130;	// WIDTH OF SIDE INDEX PANEL (USABLE SPACE)
var _INDEX_EDGE = 6;		// TOTAL WIDTH (_INDEX_WIDTH + _INDEX_EDGE)
var _GREY = 'abu-abu';	// CONTAINER (f_container())
var _RED = 'red';
var _GREEN = 'green';
var _BLUE = 'blue';
var _LEFT = 'left';		// ALIGN/FLOAT
var _RIGHT = 'right';
var _NONE = 'none';
var _VERBOSE = 'v';		// DETAILED OUTPUT - USED IN news.js, history.js, sp_people.js
var _BRIEF = 'b';
var _COMPLETE = 'c';	// _VERBOSE PLUS (sp_people.js)
var _STATS = 's';			// Returns stats only, ie. Number of records processed 
var _TEXTONLY = true;	// RAW TEXT, NO <IMG> OR FORMATTING (sp_people.js)
var _FORMATTED = false;	// (OPPOSITE OF _TEXTONLY)
var _LINK = true;			// LINK PERSON TO detail.html ?
var _ALPHA = 'Alpha';	// Alphabetical

// GLOBALS...
var SEASON_ID = '';
var SEASON_DESC = '';

// SINCE THIS UNIT IS CONTAINED IN PRETTY MUCH EVERY DOC,
// CHECK THAT WE ARE NOT CONTAINED WITHIN SOMEONE ELSES FRAMESET - WE SHOULD BE TOP!
// NB: NOTICED THAT WE GOT STUCK IN www.bdba.co.uk FRAMESET
if (top != window) {
  top.location.href = window.location.href;
}

// if (!DHTML) return;
//var W3CDOM = (document.getElementsByTagName && document.createElement);
var DHTML = (document.getElementById || document.all || document.layers);

// GET OBJECT - CROSS BROWSER (BUT NOT NESTED LAYERS IN N4)
// CALL: var x = new getObj('myid');
function getObj(name) {
  if (document.getElementById) {
    this.obj = document.getElementById(name);
    if (this.obj != null)
      this.style = document.getElementById(name).style;
  } else if (document.all) {
    this.obj = document.all[name];
    this.style = document.all[name].style;
  } else if (document.layers) {
    this.obj = document.layers[name];
    this.style = document.layers[name];
  }
}

// Rtn x-pos of object (www.quirksmode.org)
// Pass actual Object (not name)
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		// Netscape 4
		curleft += obj.x;
	}
	return curleft;
}

// Rtn y-pos of object (www.quirksmode.org)
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		// Netscape 4
		curtop += obj.y;
	}
	return curtop;
}

// Moves passed object (name) out the way!
// Called from print.js
// NB: In Strict mode, must append 'px'
function moveObj(name) {
	var ok = false;
	if (!DHTML) return ok;

	var y;
	var y1 = 10;
	var y2 = 400;

	var ob = new getObj(name);
	if (ob.obj) {
		ok = true;
		// Read current value...
		y = findPosY(ob.obj);
		//alert('ob.style.top = "' + ob.style.top + '"\n\nob.obj.offsetTop = "' + ob.obj.offsetTop + '"\n\ny = "' + y + '"');		
		if (y != y1) {y = y1;}
		else {y = y2;}
		ob.style.top = y + 'px';	// Append 'px'
	}
	return ok;
}

// Returns (absolute) filename without domain name
// href - (optional) If omitted, returns location.href
function getFilename(href) {
	var fn, slashpos;
	if (typeof(href) == 'undefined') {
		href = location.href;
	}
	slashpos = href.indexOf('/',7);
	if (slashpos > -1) {
		fn = href.substring(slashpos);
	} else {
		fn = '/';
	}
	return fn;
}

// Sets innerHTML property of passed ObjID
// Returns TRUE if successful, false otherwise
function setHTML(ObjID,HTML) {
	var x;
	var ok = false;
	
	if (!DHTML) return ok;
	
	x = new getObj(ObjID);
	if (x.obj) {
		x.obj.innerHTML = HTML;
		ok = true;
	}
	
	return ok;
}


// CORRECT DATABASE VERSION?
function f_rtnDatabaseState() {
  var t;

  // INIT
  t = '<SPAN CLASS="faint"><I>Unknown</I></SPAN>';

  // MAY NOT HAVE LOADED MODULES...
  if (typeof(_DATABASE_UPDATED) == 'undefined') return t;
  if (typeof(_DATABASE_VALIDATION) == 'undefined') return t;

  // SAME?
  if (_DATABASE_UPDATED == _DATABASE_VALIDATION) {
    t = 'Ok';
  } else {
    t = '<SPAN CLASS="alert">Refresh!</SPAN>';
  }

  return t;
}

// CORRECT DATABASE VERSION?
// (Alternatiove form of f_rtnDatabaseState() but only returns text if error)
// Rtns empty string if no error
function f_rtnIfDatabaseError() {
  var t;

  // INIT
  t = '';

  // MAY NOT HAVE LOADED MODULES...
  if (typeof(_DATABASE_UPDATED) == 'undefined') return t;
  if (typeof(_DATABASE_VALIDATION) == 'undefined') return t;

  // SAME?
  if (_DATABASE_UPDATED == _DATABASE_VALIDATION) {
    t = '';
  } else {
    t = '<SPAN CLASS="alert">DATABASE ERROR!<br />&gt;&gt;[&nbsp;<a href="javascript:window.location.reload();">Reload!</a>&nbsp;]&lt;&lt;</SPAN>';
  }

  return t;
}

// SIMPLY RETURNS THE SITE URL
function siteUrl() {
  //return window.location.hostname;
	return 'www.silverfoxbc.co.uk';
}

// RTN ERROR MSG WITHOUT STOPPING SCRIPT
function errMsg(Msg) {
  var t;
  t = '<SPAN CLASS="alert">' + Msg + '</SPAN>';
  return t;
}

// RTNS STANDARD ICONS
function f_w3cIcons() {
  var t;

	// Who needs W3C icons on a non-technical site?!
  t = '<DIV STYLE="margin-top:20px;margin-left:15px;">';
	/*
  t += '<a href="http://validator.w3.org/check?uri=referer">';
  t += '<img border=0 src="/img/valid-html401.png" alt="Valid HTML 4.01!" title="Valid HTML 4.01!" height=31 width=88>';
  t += '</a>';

  t += '<a href="http://jigsaw.w3.org/css-validator/">';
  t += '<img style="border:0;width:88px;height:31px;margin-top:5px;" src="/img/vcss.png" alt="Valid CSS!" title="Valid CSS!">';
  t += '</a>';
	*/
  t += '</DIV>';

  return t;
}

// *** COOKIE FUNCTIONS ***
// The cookieName and cookieValue arguments are mandatory
// but all other arguments are optional.
// The expires argument is a Date object.
// The path defines the part of the document tree on the server
// that the cookie is valid for.
// The domain argument allows multiple server hosts to be used.
// The secure value is boolean and only applicable for use
// with HTTPS: connections.
// eg. SetCookie("foo", "bar", "Mon, 01-Jan-2001 00:00:00 GMT", "/");
// NB: 'expires' is now a Date object
function setCookie(cookieName, cookieValue, expires, path, domain, secure) {
	if (cookieName == '_c') {alert('Setting "_c" Cookie!');}
	document.cookie = escape(cookieName) + "=" + escape(cookieValue)
		+ ((expires) ? "; expires=" + expires.toGMTString() : "")
		+ ((path) ? "; path=" + path : "")
		+ ((domain) ? "; domain=" + domain : "")
		+ ((secure) ? "; secure" : "");
}

// eg. myVar = getCookie("foo");
function getCookie(cookieName) {
	var cookie = " " + document.cookie;
	var search = " " + escape(cookieName) + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}


// CHECKS 1st CHAR, RTNS TRUE IF NOT _NODATA
function isValidData(Msg) {
  return (Msg.charAt(0) != _NODATA);
}

// REMOVES 1st CHAR IF _NODATA AND RTNS STRING
function validateData(Msg) {
  if (Msg.charAt(0) == _NODATA) Msg = Msg.substring(1);
  return Msg;
}

// SET BROWSER TO SPECIFIED URL
function goUrl(Url) {
  window.location.href = Url;
  return false;
}

// RTNS TEXT INSIDE STD <TEXTAREA>..</TEXTAREA>
// id - Optional ID tag
function f_textArea(Text,id) {
  var t = '';
  t += '<form><textarea ';
	if (id > ' ') {
		t += 'id="' + id + '" ';
	}
	t += 'name="txt" style="width:600px;height:380px;">'; // readonly="readonly"
  t += Text + '</textarea><br />';
	t += '<input onclick="javascript:this.form.txt.focus();this.form.txt.select();" type="button" value="Select Text" />';	
	t += '</form>';
  return t;
}

// PASS MONTH NUMBER 0..11, RETURNS STRING OF MONTH
function f_rtnMonth(No) {
  var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
  return months[No];
}

// PASS DAY NUMBER 0..6, RETURNS STRING OF WEEK DAY
function f_rtnDay(No) {
  var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  return days[No];
}

// PASS DATE (1..31), RETURNS STRING OF THE FORM '17th'
function f_rtnDate(No) {
  var str = Number(No);
  //str += '<SUP>';
  if ((No == 1) || (No == 21) || (No == 31)) {
    str += 'st';
  } else if ((No == 2) || (No == 22)) {
    str += 'nd';
  } else if ((No == 3) || (No == 23)) {
    str += 'rd';
  } else {
    str += 'th';
  }
  //str += '</SUP>';
  return str;
}

// PASS DATE IN A STRING OF THE FORM: '10/2/2005'
// RETURNS STRING OF THE FORM: '10th Feb 2005';
// NB: Previously seperated with regular space, now use &nbsp;
// LongVersion - IF true RETURNS LONG VERSION WITH FULL MONTH NAME AND DAY OF WEEK (DEFAULT: false)
// IncDay - IF NOT LongVersion AND IncDay THEN 3 CHAR DAY IS INCLUDED (DEFAULT: false)
// NBSP - Use &nbsp; to separate (DEFAULT: true) otherwise uses normal space
function f_formatDateStr(DateStr,LongVersion,IncDay,NBSP) {
  var d, darr, dstr, month, day, sp;

	// Default
	if (typeof(NBSP) == 'undefined') { NBSP = true; } else { NBSP = false; }
	if (NBSP) { sp = '&nbsp;'; } else { sp = ' '; }
	
  // CONVERTED INTO A DATE TO GET THE DAY OF THE WEEK
  darr = DateStr.split('/');
  darr[1] -= 1;	// MONTHS RANGE 0..11
  d = new Date(darr[2],darr[1],darr[0]);

  // CONSTRUCT STRING
  if (LongVersion) {
    day = f_rtnDay(d.getDay()) + sp;
    month = f_rtnMonth(darr[1]);
  } else {
    if (IncDay) {
      day = f_rtnDay(d.getDay()).substring(0,3) + sp;
    } else {
      day = '';
    }
    month = f_rtnMonth(darr[1]).substring(0,3);
  }
  dstr = day + f_rtnDate(darr[0]) + sp + month + sp + darr[2];

  return dstr;
}

// RETURNS STRING OF THE FORM...
// "Page last changed 5 days ago." etc.
function lastMod() {
  var x = new Date (document.lastModified);
  Modif = new Date(x.toGMTString());
  Year = takeYear(Modif);
  Month = Modif.getMonth();
  Day = Modif.getDate();
  Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
  x = new Date();
  today = new Date(x.toGMTString());
  Year2 = takeYear(today);
  Month2 = today.getMonth();
  Day2 = today.getDate();
  now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
  daysago = now - Mod;
  if (daysago < 0) return '';
  unit = 'days';
  if (daysago > 730) {
    daysago = Math.round(daysago/365);
    unit = 'years';
  }
  else if (daysago > 60) {
    daysago = Math.round(daysago/30);
    unit = 'months';
  }
  else if (daysago > 14) {
    daysago = Math.round(daysago/7);
    unit = 'weeks'
  }
  towrite = 'Page last changed ';
  if (daysago == 0) towrite += 'today';
  else if (daysago == 1) towrite += 'yesterday';
  else towrite += daysago + ' ' + unit + ' ago';
  towrite += '.';
  //towrite += ' (' + Day + '/' + (Month+1) + '/' + Year + ')';

  return towrite;
}

// RETURNS 4 DIGIT YEAR (CROSS PLATFORM)
function takeYear(theDate) {
  x = theDate.getYear();
  var y = x % 100;
  y += (y < 38) ? 2000 : 1900;
  return y;
}

// EXTRACTED FROM lastMod() ABOVE
// RETURNS NUMBER OF DAYS AGO, THE DATE test_date ('d/m/yyyy') OCCURRED, BASED ON CURRENT DATE
function f_daysAgo(test_date) {
  // MAKE DATE UNDERSTANDABLE
  var d = test_date.split('/');
  d[1] -= 1;	// MONTHS RANGE 0..11

  var x = new Date(d[2],d[1],d[0]);
  Modif = new Date(x.toGMTString());
  Year = takeYear(Modif);
  Month = Modif.getMonth();
  Day = Modif.getDate();
  Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
  x = new Date();
  today = new Date(x.toGMTString());
  Year2 = takeYear(today);
  Month2 = today.getMonth();
  Day2 = today.getDate();
  now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
  daysago = now - Mod;

  return daysago;
}

// EXTRACTED FROM lastMod() ABOVE
// PASS daysago (OR DATE), AND RETURNS STRING OF THE FORM...
// "5 days ago", "2 weeks ago" etc.
function f_daysAgoStr(daysago) {
  var towrite = '';
  var unit = 'days';

  // CHECK FOR DATE STR (ie. NaN) AND GET NUMBER OF DAYS
  if (isNaN(daysago)) {
    daysago = f_daysAgo(daysago);
  }

  // CHECK FOR DATE IN FUTURE
  // NB: PREVIOUSLY RETURNED '' (EMPTY STRING)
  if (daysago < 0) return '<I>future</I>';

  // JUST HOW LONG AGO?
  if (daysago > 730) {
    daysago = Math.round(daysago/365);
    unit = 'years';
  }
  else if (daysago > 60) {
    daysago = Math.round(daysago/30);
    unit = 'months';
  }
  else if (daysago > 14) {
    daysago = Math.round(daysago/7);
    unit = 'weeks'
  }
  if (daysago == 0) towrite += 'today';
  else if (daysago == 1) towrite += 'yesterday';
  else towrite += daysago + ' ' + unit + ' ago';
  //towrite += '.';

  return towrite;
}

// STRIPS OUT '/' AND '.' AND RETURNS FLAT STRING
// USED TO GENERATE WINDOW NAME FROM FILENAME
function strip(filestr) {
  var invalid = '/._?&=';
  var flatstr = '';
  var j, qpos;
	
	// Strip everything past '?'
	qpos = filestr.indexOf('?');
	if (qpos > -1) {
		filestr = filestr.substring(0,qpos);
	}

  // COPY VALID CHARS AND IGNORE INVALID ONES
  for (j=0; j<filestr.length; j++) {
    flatstr += (invalid.indexOf(filestr.charAt(j)) > -1) ? '' : filestr.charAt(j);
  }

  return flatstr;
}

// POPS UP A WINDOW WITH THE PASSED HTML FILE - NO TOOLBAR
// width - (Optional) Defaults to 550 - as for f_popupWin()
// height - (OPTIONAL) DEFAULTS TO 280 FOR INFO
// <A HREF="myfile.html" onClick="return f_openWin('myfile.html');">...</A>
function f_openWin(file,width,height) {
	var features;

  // Default window dimensions
  if ((typeof(width) == 'undefined') || (width < 20)) {
    width = 550;
  }	
  if ((typeof(height) == 'undefined') || (height < 100)) {
    height = 280;
  }

  // WINDOW NAME OF file ENSURES THAT EACH FILE HAS THEIR OWN WINDOW
	features = 'resizable=yes,scrollbars=yes,width=' + width.toString() + ',height=' + height.toString();
  popup = window.open(file,strip(file),features);

  popup.focus();

  // ENSURE THAT HREF IS NOT FOLLOWED
  return false;
}

// POPS UP A WINDOW WITH THE PASSED HTML FILE - OK FOR SMALL INFO FILES
// height - (OPTIONAL) DEFAULTS TO 280 FOR INFO
// <A HREF="myfile.html" onClick="return f_popupWin('myfile.html');">...</A>
// CALLS f_openWin() ABOVE
function f_popupWin(file,height) {
  return f_openWin(file,0,height);
}

// PASS SCORE AS NUMBER 3.5 OR 2 - EITHER WHOLE NUMBER OR A HALF
// RETURNS HTML STRING '3&frac12;' OR SIMPLY '2' FOR DISPLAY
function f_formatScore(Num) {
  var strnum;

  // SPECIAL CASE
  // IF NOT A NUMBER THEN RETURN AS IS
  if (isNaN(Number(Num))) return Num;

  if (Math.floor(Num) == Num) {
    strnum = Num;
  } else {
    strnum = (Math.floor(Num) > 0) ? Math.floor(Num) + '&frac12;' : '&frac12;';
  }
  return strnum;
} 

// PASS SCORE FROM FixArr[] ('3.5-5.5') AND RETURNS FORMATED STRING FOR DISPLAY '3&frac12; - 5&frac12;'
// If '-' is not contained in Score, and there is a Score, then returned as is
function f_fixtureScore(Score) {
  var sarr, str;
	
	// Special case
	if ((Score.indexOf('-') == -1) && (Score > ' ')) {
		return Score;
	}
	
  sarr = Score.split('-');
  str = '&nbsp;';
  if ((sarr[0] > ' ') && (sarr[1] > ' ')) {
    str = '<NOBR>' + f_formatScore(sarr[0]) + '-' + f_formatScore(sarr[1]) + '</NOBR>';
  }
  return str;
}

// DISPLAYS 'NEW' OR 'UPDATED' GIF IMAGE IF NOT EXPIRED
// type - EITHER _NEW or _UPDATED AS CONST
// new_date - DATE THING WAS ADDED, OF THE FORM 'd/m/yyyy', FUNCTION LATER SPLITS IT INTO yr,mo,da
// no_days - DAYS BEFORE EXPIRE (new_date + no_days = expiry_date)
// >> NOT SURE THAT THIS IS USED! (see rtnNew)
function writeNew(type,new_date,no_days) {
  var txt = '';
  var anc = '';

  // DATE OCCURRED daysago
  var daysago = f_daysAgo(new_date);
  if ((daysago > no_days) || (daysago < 0))
    return '';

  // VALID
  daysagostr = f_daysAgoStr(daysago);
  if (type == _NEW) {
    txt = 'New ' + daysagostr;
    anc = '<IMG SRC="/img/new_anim.gif" WIDTH=22 HEIGHT=9 ALT="' + txt + '" BORDER=0>';
  } else {
    txt = 'Updated ' + daysagostr;
    anc = '<IMG SRC="/img/updated_anim.gif" WIDTH=46 HEIGHT=9 ALT="' + txt + '" BORDER=0>';
  }

  // DONE
  document.write(anc);
  return txt;
}

// RETURNS 'NEW' OR 'UPDATED' GIF IMAGE IF NOT EXPIRED
// type - EITHER _NEW, _UPDATED or _COMPACT (graphic) as const
// new_date - DATE THING WAS ADDED, OF THE FORM 'd/m/yyyy', FUNCTION LATER SPLITS IT INTO yr,mo,da
// no_days - DAYS BEFORE EXPIRE (new_date + no_days = expiry_date)
// extra_txt - (Optional) Extra text in alt / title
function rtnNew(type,new_date,no_days,extra_txt) {
  var txt = '';
  var anc = '';

  // DATE OCCURRED daysago
  var daysago = f_daysAgo(new_date);
  if ((daysago > no_days) || (daysago < 0))
    return '';
	
	// INIT Extra Text
	if (typeof(extra_txt) == 'undefined') {
		extra_txt = '';
	} else {
		extra_txt += ' ';
	}

  // VALID
  daysagostr = f_daysAgoStr(daysago);
	anc = '<img src="/img/';
  if (type == _NEW) {
    txt = 'New ';
    anc += 'new_anim.gif" width="22" height="9"';
  } else if (type == _UPDATED) {
    txt = 'Updated ';
    anc += 'updated_anim.gif" width="46" height="9"';
  } else {
    txt = 'New/Updated ';
    anc += 'star_anim.gif" width="12" height="11"';
	}
	txt += extra_txt + daysagostr;
	anc += ' alt="' + txt + '" title="' + txt + '" border="0" />';

  return anc;
}

// RETURNS THE NECESSARY FOR A BNB RATING (OUT OF 5)
// IF Rating IS NEG THEN NOTHING IS RETURNED
function f_BNB(Rating) {
  var i;
  var t = '';
  var _MAX = 5;

  if ((Rating >= 0) && (Rating <= _MAX )) {
    t = '<P><B>BNB Rating</B><BR>';
    t += (Rating == 0) ? '&#216;' : '';
    for (i=1; i<=Rating; i++) {
      t += '<IMG HSPACE=2 SRC="/img/thumb_up.gif" WIDTH=17 HEIGHT=15 ALT="' + Rating + ' Thumbs Up!">';
    }
    t += '</P>';
  } else if (Rating > _MAX) {
    alert('BNB Rating: ' + Rating + '\n\nThe maximum BNB Rating is ' + _MAX);
  }

  return t;
}

// RETURNS STRING AFTER '?' IN URL
// REMOVES '#link' IF PRESENT. RTNS EMPTY STRING IF NO '?'
function grabUrlParam() {
  var q, h;
  var param = '';
  
  // FIND '?'
  q = location.href.indexOf('?') + 1;
  if (q > 0) {
    param = location.href.substring(q);
    h = param.indexOf('#');
    if (h > -1) {
      param = param.substring(0,h);
    }
  }

  return param;
}

// OPEN WINDOW WITH IMAGE
// (BASED ON FUNCTION FROM printit.js)
function showImg(Image,Title,Desc,W,H) {
  var t ='';
	var max_height, height_adjust;
	
	// Init
	max_height = screen.height - 50;
	height_adjust = 95;

  t = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n';
  t += '<HTML><HEAD><TITLE>Photo - ' + Title + '</TITLE>';
	t += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
  t += '<LINK REL=STYLESHEET TYPE="text/css" HREF="/style.css" TITLE="Normal" />';
  t += '</HEAD>';

  t += '<BODY CLASS="popup">';
  t += '<DIV><SPAN CLASS="bigfont">' + Title + '</SPAN>';
	if (Desc > ' ') {t += '<BR>' + Desc;}
	t += '</DIV>';

  t += '<IMG style="border:1px solid #999999;margin-top:2px;"';
	t += ' SRC="' + Image + '" WIDTH=' + W + ' HEIGHT=' + H;
	t += ' ALT="' + Title + '" title="' + Title + '">';

	/*
  t += '<DIV STYLE="text-align:right;">';
  t += '[<A HREF="javascript:window.close();">Close Window</A>]';
  t += '</DIV>';
	*/
	
  t += '<div class="noprint" style="float:right;padding:5px;">';
  t += '<INPUT STYLE="width:80px;" TYPE="button" VALUE="Print" onClick="javascript:window.print();"> ';
  t += '<INPUT STYLE="width:80px;" TYPE="button" VALUE="Close" onClick="javascript:window.close();">';
	t += '</div>';

  t += '</BODY></HTML>';

  // ADJUST FOR WINDOW WIDTH/HEIGHT
  if (W < 700) {
    W += 40;
    if (W < 300) {
      W = 300
    }
  } else {
    W = 740;
  }	

	// 5th Nov 2005 - Allows for different screen resolutions
	// Assigned earlier
  if (H < (max_height - height_adjust)) {
    H += height_adjust;
  } else {
    H = max_height;
  }
	
  var imgwin = window.open('about:blank','imgwin','resizable=yes,scrollbars=yes,width=' + W + ',height=' + H);

  imgwin.document.open();
  imgwin.document.write(t);
  imgwin.document.title = Title;
  imgwin.document.close();
}

// GENERAL HEADER
// Icon - FILENAME, ASSUMED TO BE IN /img/ DIRECTORY
// LastModDate - Show last modified date... _LASTMOD / _NOLASTMOD (true/false)
// Popup - Show Close/Print Btns... _POPUP / _NOPOPUP (true/false)
function f_header(Title,Desc,Icon,IconW,IconH,Website,LastModDate,Popup) {
  var t = ''; 

  // ICON
  if (Icon > ' ') {
    t += '<DIV STYLE="float:left;padding:5px;">';
    t += '<IMG SRC="/img/' + Icon +'" WIDTH=' + IconW + ' HEIGHT=' + IconH + '>';
    t += '</DIV>';
  }

  // POPUP - CLOSE / PRINT BTNs
  if (Popup) {
    t += '<DIV ID="noprint" STYLE="float:right;padding:5px;">';
    t += '<INPUT STYLE="width:50px;margin-right:2px;" TYPE="button" VALUE="Print" onClick="javascript:window.print();">';
    t += '<INPUT STYLE="width:50px;" TYPE="button" VALUE="Close" onClick="javascript:window.close();">';
    t += '</DIV>';
  }

  // NAME ANCHOR 'top' (ASSUME AT TOP OF DOCUMENT)
  t += '<A NAME="top">';
  t += '<DIV CLASS="edge"><DIV CLASS="banner">';
  t += '<SPAN CLASS="hugefont">' + Title + '</SPAN><BR>';
  t += Desc;
  if (Website > ' ') {
    t += '<BR><B>W:</B> <A HREF="http://' + Website + '">' + Website + '</A>';
  }
  t += '</DIV></DIV>';
  t += '</A>';

  // Last Modified Date
  if (LastModDate) {
    t += '<DIV CLASS="smallfont faint" STYLE="text-align:right;">' + lastMod() + '</DIV>';
  }

  return t;
}

// VENUE HEADER
function f_venueHeader(Title,Address,Website) {
  return f_header(Title,Address,'venue50x40.gif',50,40,Website,_LASTMOD,_NOPOPUP);
}

// (POPUP) INFO HEADER
function f_infoHeader(Title,Desc,Popup) {
  return f_header(Title,Desc,'info32.gif',32,32,'',_LASTMOD,Popup);
}

// JUST RETURNS 'BACK TO TOP' LINK
function f_backToTop() {
  var t;
  //t = '<DIV STYLE="margin-top:10px;"><A HREF="#top" CLASS="nounderline"><IMG HSPACE=3 SRC="/img/totop.gif" WIDTH=11 HEIGHT=12 ALT="Back to top" BORDER=0><SPAN CLASS="smallfont" STYLE="position:relative;top:-2px;">Back to top</SPAN></A></DIV>';

  //t = '<DIV STYLE="margin-top:10px;"><A HREF="#top" CLASS="nounderline"><IMG SRC="/img/backtotop.gif" WIDTH=85 HEIGHT=15 ALT="Back to top" BORDER=0></A></DIV>';

	t = '<DIV STYLE="margin-top:10px;" class="smallfont"><A HREF="#top" style="color:#CCCC99;">^top</A></DIV>';

  return t;
}

// COPYRIGHT NOTICE
function copyR() {
  return 'Copyright &copy; 2005, 2006 Silver Fox Badminton Club';
}

// 3rd PARTY WEBCOUNTER (IN FOOTER)
function f_webCounter() {
  var t = '';

  // INIT
  _d=document; _n=navigator; _t=new Date();
  _c="0"; _r="0"; _j="U"; _k="U"; _d.cookie="_c=y";
  _d.cookie.length > 0 ? _k="Y" : _k="N";

  // V1.2
  _b=screen; _r=_b.width; _n.appName!="Netscape"?_c=_b.colorDepth : _c=_b.pixelDepth;
  _n.javaEnabled() ? _j="Y" : _j="N";

  t += '<A HREF="http://counter.search.bg/cgi-bin/s?_id=foxhome">';
  if ((typeof(_ONLINE) == 'undefined') || (!_ONLINE)) {
    if (typeof(_ONLINE) == 'undefined') t += errMsg('_ONLINE is undefined.');
    t += '<IMG SRC="/img/blackdot.gif" WIDTH=70 HEIGHT=15 BORDER=0 ALT="WebCounter (Offline)" TITLE="WebCounter (Offline)">';
  } else {
    t += "<img src=\"http://counter.search.bg/cgi-bin/c?_id=foxhome&_z=0&_r="+_r+"&_c="+_c+"&_j="+_j+"&_t="+(_t.getTimezoneOffset())+"&_k="+_k+
"&_l="+escape(_d.referrer)+"\" width=70 height=15 "+
"border=0>";
  }
  t += '</A>';

  return t;
}

// Displays banner with adverts / affiliates
function f_adBanner() {
	var t;
	
	t = '<div style="margin:0 5px 10px 5px;text-align:left;">';
	
	// Text link
	/*
	t += '<script type="text/javascript"><!--';
	t += 'var iDevAffiliate_BoxWidth = "220";';
	t += 'var iDevAffiliate_BoxHeight = "80";';
	t += 'var iDevAffiliate_OutlineColor = "#000099";';
	t += 'var iDevAffiliate_TitleTextColor = "#FFFFFF";';
	t += 'var iDevAffiliate_LinkColor = "#0033CC";';
	t += 'var iDevAffiliate_TextColor = "#000000";';
	t += 'var iDevAffiliate_TextBackgroundColor = "#F3F3F3";';
	t += '//-->';
	t += '</script>';
	t += '<script language="JavaScript" type="text/javascript"';
	t += 'src="https://www.jabwebsolutions.co.uk/affiliate/idevads.php?id=16&ad=2"></script>';
	*/	
	
	// Jab Web Solutions Affiliation - Graphic
	//t += '<a href="https://www.jabwebsolutions.co.uk/affiliate/idevaffiliate.php?id=16_0_1_4"><img src="https://www.jabwebsolutions.co.uk/affiliate/banners/hostedby.gif" border="0" alt="Link to Jab Web Solutions"></a>';	
	
//	t += '';
	t += '</div>';
	
	return t;
}

// GENERAL FOOTER
// LastModDate - true, false
function f_footer(TopLink,LastModDate) {
  var t = ''; 

  t += '<BR CLEAR=ALL>';

  // JUST ABOVE FOOTER...
	// The outer DIV is for older versions of IE that don't correctly center with CSS
	t += '<div style="text-align:center;"><div style="margin:0 auto;width:60%;text-align:center;">' + rtnNew(_COMPACT,'16/5/2006',30) + ' ' + rtnNew(_COMPACT,'16/5/2006',30) + ' ' + rtnNew(_COMPACT,'16/5/2006',30) + '<br><br>Please have a <a href="/guestbook/guestbook.php">browse and sign our Guestbook</a>.  You can write any comments you like and include a link to your website.  Your feedback is appreciated.</div></div>';

  t += '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0"><TR>';
  t += '<TD>&nbsp;';
  if (TopLink) {
    t += '<div class="noprint">' + f_backToTop() + '</div>';
  }
  t += '</TD><TD CLASS="smallfont faint" STYLE="text-align:right;vertical-align:bottom;">';
  if (LastModDate) {
    t += lastMod();
  }
  t += '&nbsp;</TD></TR></TABLE>';

  // START FOOTER
  t += '<DIV CLASS="footer">';

  t += '<div class="noprint">';

  // EDGE
  t += '<DIV STYLE="background-image:url(/img/edge_abovefooter.gif);background-repeat:repeat-x;">';
  t += '<IMG SRC="/img/blankdot.gif" WIDTH=1 HEIGHT=6></DIV>';

  t += '<A HREF="/index.html">Home</A>';
  t += ' | <A HREF="/news/news.html">News</A>';
  t += ' | <A HREF="/news/diary.html">Diary</A>';
  t += ' | <A HREF="/members/members.html">Members</A>';
  t += ' | <A HREF="/matches/fixtures.php">Fixtures</A>';
  t += ' | <A HREF="/matches/results.php">Results</A>';
  t += ' | <A HREF="/matches/tables.php">Tables</A>';
  t += ' | <A HREF="/clubs/clubs.html">Clubs</A>';
  t += ' | <A HREF="/clubs/venues.html">Venues</A>';
  t += ' | <A HREF="/photos/photos.html">Photos</A>';
  t += ' | <A HREF="/other/other.html">Other</A>';
  t += ' | <A HREF="/links/links.html">Links</A>';
  t += ' | <A HREF="/contact.php">Contact Us</A>';
  //t += ' | <A HREF="/history/history.html">History</A>';
  t += ' | <A HREF="/sitemap.html">Site Map</A>';

  // noprint
  t += '</div>';

  // COPYRIGHT NOTICE and WEBCOUNTER
  //t += '<BR>';
  t += '<TABLE STYLE="width:100%;padding:2px;border:0;" CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>';
  t += '<TD CLASS="smallfont faint">&nbsp;' + copyR() + '</TD>';
  t += '<TD STYLE="text-align:right;"><DIV class="noprint">' + f_webCounter(); + '</DIV></TD>';
  t += '</TR></TABLE>';

	t += f_adBanner();	
	
  // END FOOTER
  t += '</DIV>';	

  return t;
}

// Called if season id passed in URL
// Sets season cookie and returns season description
function setSeason(SeasonID) {
	var sdesc, season;
	sdesc = f_getSeason(SeasonID);
	season = SeasonID + ',' + sdesc;
	setCookie('season',season,null,'/');
	
	// Set GLOBALS
	SEASON_ID = SeasonID;
	SEASON_DESC = sdesc;
	return sdesc;
}

// Sets Cookie and Refreshes display
function changeSeason(NewSeasonID) {
	var sdesc = setSeason(NewSeasonID);
	var urlparam = window.location.href.indexOf('?');
	var url;	

	// Need to clear possible url parameters
	if (urlparam > 0) {
		url = window.location.href.substring(0,urlparam);
		window.location.href = url;
	} else {
		window.location.reload();
	}
	return sdesc;
}

// Retrieves season from cookie or current season if not set
// Sets GLOBALS...
function getSeason() {
	var sid = null;
	var sdesc, season, sarr;
	
	// Read Cookie (cookies.js) - is it set?
	season = getCookie('season');
	if (season != null) {
		sarr = season.split(',');
		sid = sarr[0];
		sdesc = sarr[1];
	} else if (typeof(SeasonArr) != 'undefined') {
  	sid = f_getCurrentSeasonID();
  	sdesc = f_getSeason(sid);
  	season = sid + ',' + sdesc;
  	setCookie('season',season,null,'/');
	}
	
	// Set GLOBALS
	if (sid != null) {
		SEASON_ID = sid;
		SEASON_DESC= sdesc;
	}
	return sid;
}

// Returns <select> tag for season, depending on cookie and database.js
function selectSeason() {
	var t, sid, sdesc, season, sarr, i, maxi;
	
	// Read Cookie (cookies.js) - is it set?
	season = getCookie('season');
	if (season != null) {
		sarr = season.split(',');
		sid = sarr[0];
		sdesc = sarr[1];
	}
	
	// If cookie not set and database loaded, get current season and write cookie
 	if (typeof(SeasonArr) != 'undefined') {
		if (season == null) {
			sid = f_getCurrentSeasonID();
			sdesc = f_getSeason(sid);
			season = sid + ',' + sdesc;
			setCookie('season',season,null,'/');
		}
		
		// Build select list
		t = ' | <select name="season" id="season" size="1" onChange="javascript:changeSeason(this.value);">'
		maxi = SeasonArr.length;
		for(i=0; i<maxi; i++) {
			sarr = SeasonArr[i].split(',');
			t += '<option value="' + sarr[0] + '"';
			if (sarr[0] == sid) {
				t += ' selected="selected"';
			}
			t += '>' + sarr[1] + '</option>'; 			
		}
		/*
		t += '<option value="0102">Season 2001/02</option>';
		t += '<option value="0405">Season 2004/05</option>';
		t += '<option value="0506">Season 2005/06</option>';
		t += '<option value="all">All Seasons</option>';
		*/			
		t += '</select>';
	}
	
	// Database not loaded, but cookie may have been set
	else {
		//t = (sdesc > '') ? ' | <span style="color:#000000;">' + sdesc + '</span>' : '';
		t = (sdesc > '') ? ' | ' + sdesc : '';
	}
	
	// SET GLOBALS
	SEASON_ID = sid;
	SEASON_DESC = sdesc;
	
	return t;
}

// DISPLAY MAIN BANNER
// Title, Desc - (OPTIONAL) IF NOT SPECIFIED THEN SHOWS "WHAT'S NEW"
// Icon,W,H - (OPTIONAL) IF Title AND Desc SPECIFIED
function sf_banner(Page,Title,Desc,Icon,W,H) {
  var t = '';
  var w = _INDEX_WIDTH + _INDEX_EDGE;
		
	// Special styles for less than IE6 (override font sizes)
	// IE 5 font-size are just too big! (Same for IE 5.5 ??!)
	// Seem to have to output 'something' for IE5 to take any notice?!
	t = '\n<!--[if lt IE 6]>\n';
	t += '<div style="position:absolute;top:0;left:0;width:24px;height:15px;color:#cccccc;">IE5</div>\n';
	t += '<style type="text/css">\n';
	//t += 'body, th, td, select, .normalfont {font-size:13px}\n';
	t += '.news_msg {font-size:80%;}\n';
	t += '.option0 {font-size:small;}\n';
	t += '.option1 {font-size:x-small;}\n';
	t += 'table.results td {font-size:x-small;}\n';
	t += 'table.results th {font-size:x-small;}\n';
	t += 'table.fixtures td {font-size:80%;}\n';	// Would be good at 90% if resize.js worked for IE5!!
	t += 'table.fixtures th {font-size:80%;}\n';
	t += 'table.scoresheet td {font-size:80%;}\n';
	t += 'table.scoresheet th {font-size:80%;}\n';
	t += '.smallfont {font-size:70%;}\n';
	t += '.bigfont {font-size:120%;}\n';
	t += '.hlinks {font-size:70%;}\n';					
	t += '</style>\n';
	t += '<![endif]-->\n';

	// Start Display...
  t += '<A NAME="top"><DIV ID="sfbanner">'; 

	// BRAVENET GUESTBOOK : http://pub4.bravenet.com/guestbook/show.php?usernum=321188012&cpv=1
  t += '<TABLE STYLE="width:100%;padding:5px;padding-bottom:1px;height:93px;" CELLPADDING=0 CELLSPACING=0 BORDER=0>';
  t += '<TR><TD STYLE="cursor:pointer;width:160px;" ROWSPAN=2 onClick="goUrl(\'/index.php\');"><DIV CLASS="bigfont printonly">Silver Fox<BR>Badminton Club</DIV>&nbsp;</TD>';
  t += '<TD CLASS="hlinks" COLSPAN=2><DIV class="noprint"><A HREF="/index.html" title="Go back to the homepage">Home</A> | <A HREF="/sitemap.html" title="A list of all the pages on this site">Site Map</A> | <A HREF="/contact.php" title="How to contact us">Contact Us</A> | <A HREF="/history/history.html" title="View the history of this website">History</A> | <A HREF="/guestbook/guestbook.php" title="Please sign our Guestbook!">Guestbook</A>' + selectSeason() + '</DIV></TD>';
  t += '<TR>';
  t += '<TD STYLE="padding:0;padding-right:10px;">';
  if (typeof(Title) != 'undefined') {
    if (typeof(Icon) != 'undefined') {
      t += '<DIV class="noprint" STYLE="float:left;margin-right:10px;margin-bottom:5px;">';
      t += '<IMG SRC="' + Icon + '" WIDTH=' + W + ' HEIGHT=' + H + '>';
      t += '</DIV>';
    }
    t += '<DIV CLASS="hugefont">' + Title + '</DIV>';
    t += '<DIV>' + Desc + '</DIV>';
  } else {
    //t += '<DIV CLASS="sfbanner_title" STYLE="float:left;">What\'s New</DIV>';
    //t += '<DIV CLASS="sfbanner_msg">' + f_lastHistory() + '</DIV>';
    t += f_sfbannerText();	// fixtures.js
  }
  t += '</TD>';
  t += '<TD STYLE="text-align:right;vertical-align:bottom;" CLASS="smallfont faint">' + f_rtnIfDatabaseError() + '<BR><BR>Site&nbsp;Last&nbsp;Updated<BR>' + f_lastUpdated() + '</NOBR></TD>';
  t += '</TR></TABLE>';

  t += '<DIV class="noprint">';
  t += '<TABLE STYLE="width:100%;height:6px;" CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>';
  t += '<TD STYLE="width:' + w + 'px;"><IMG SRC="/img/blankdot.gif" WIDTH=' + _INDEX_WIDTH + ' HEIGHT=6>';
  t += '<IMG SRC="/img/edge_topcorner.gif" WIDTH=6 HEIGHT=6></TD>';
  t += '<TD><DIV STYLE="background-image:url(/img/edge_belowbanner.gif);background-repeat:repeat-x;"><IMG SRC="/img/blankdot.gif" WIDTH=1 HEIGHT=6></DIV></TD>';
  t += '</TR></TABLE>';
  t += '</DIV>';

  t += '</DIV></A>';

  // ONLINE?
  if (typeof(_ONLINE) == 'undefined') {
    return t;
  } else if (!_ONLINE) {
    t += '<DIV CLASS="noprint smallfont" STYLE="position:absolute;top:0px;left:0px;">';
    t += '[<A CLASS="nounderline" HREF="http://www.silverfoxbc.co.uk' + getFilename() + '">Go Online!</A>]';
    t += '</DIV>';
  }

  return t;
}

// WRITE MENU ITEM FOR INDEX ON LEFT
// Level - 0,1 (MAIN MENU, SUB MENU)
// Desc - POPUP TEXT
function f_menuItem(Level,Text,Link,Desc) {
  var t;
  
  t = '<DIV CLASS="option_main option' + Level + '">';
	t += '<a';
	// If linking to page we are already on then mark as 'selected'	
	if (location.href.indexOf(Link) != -1) {t += ' class="selected"';}

	t += ' HREF="' + Link + '"';
  if (typeof(Desc) != 'undefined') {
		t += ' TITLE="' + Desc + '"';
	}
	t += '>' + Text + '</a>';
  t += '</DIV>';

  return t;
}

// VERTICAL SPACER IN MENU
// y is multiples of n (5)
// Border - (default false) Draw a border below
function f_menuSpacer(y,Border) {
  var t;
  if (typeof(y) == 'undefined') y = 1;
  if (typeof(Border) == 'undefined') Border = false;	
  y *= 5;
  t = '<DIV STYLE="height:' + y + 'px;';
	if (Border) {
		t += 'border-bottom:1px solid #000000;';
	}
	t += '"><IMG SRC="/img/blankdot.gif" WIDTH=1 HEIGHT=1 alt="Sizer"></DIV>';
  return t;
}

// DISPLAY MAIN INDEX ON THE LEFT
function sf_index(Page) {
  var t = '';
  var w = _INDEX_WIDTH + _INDEX_EDGE;

  t = '<div id="sfindex" class="noprint">';

  t += '<DIV STYLE="width:' + w + 'px;background-image:url(/img/edge_sideindex.gif);background-repeat:repeat-y;background-position:right;">';

  t += f_menuSpacer(6);
  t += f_menuItem(0,'Home','/index.php','The Homepage');
  t += f_menuItem(1,'Committee','/committee.html','Committee Members');
  //t += f_menuItem(1,'Fees','/fees.html','How much does it cost to play?');	
  t += f_menuItem(1,'Contact Us','/contact.php','Contact Us');	
  t += f_menuSpacer(1);

  t += f_menuItem(0,'Club News','/news/news.html','Current News');
  t += f_menuItem(0,'Diary','/news/diary.html','Current Diary');

  t += f_menuItem(0,'Season Info','/matches/season.php','Match Information for the selected Season');
  //t += f_menuItem(1,'Notes','/matches/notes_redirect.html','More Information for the current season');
  t += f_menuItem(1,'Fixtures','/matches/fixtures.php','Unplayed fixtures this season');
  t += f_menuItem(1,'Results','/matches/results.php','Table of Played Fixtures and Results this season');
  t += f_menuItem(1,'Summary','/matches/tables.php','A summary of matches Won, Lost and Drawn this season');	
  t += f_menuItem(1,'Reports','/matches/reports.php','Match reports this season');
  t += f_menuItem(1,'Teams','/matches/teams.php','The teams at the start of the season');
  t += f_menuItem(1,'Scorecards','/matches/scorecards.html','Some blank match scoresheets to print out');
  t += f_menuSpacer(2);

  t += f_menuItem(0,'Members','/members/members.html','A list of current Club Members');
  t += f_menuItem(1,'Player Lookup','/members/lookup.html','Looking for someone?');
  t += f_menuItem(1,'Who\'s Played '+rtnNew(_COMPACT,'29/3/2006',20),'/members/whoplayed.php','Who has played in what matches...');	
  t += f_menuSpacer(2);

  t += f_menuItem(0,'Clubs','/clubs/clubs.html','Other clubs in the Reading and Bracknell Badminton Leagues');
  t += f_menuItem(0,'Venues','/clubs/venues.html','Badminton venues and the clubs who play there');
  t += f_menuItem(0,'Photos','/photos/photos.html','Photos of club activities');
  t += f_menuItem(0,'Other Stuff','/other/other.html','More things badminton and club related');
  t += f_menuItem(0,'Links','/links/links.html','Links to other badminton related sites');
  t += f_menuItem(0,'Site Map','/sitemap.html','Can\'t find what you\'re looking for?');
  t += f_menuItem(0,'Guestbook '+rtnNew(_COMPACT,'16/5/2006',30),'/guestbook/guestbook.php','Browse and sign our Guestbook!');	

  t += f_menuSpacer(3);
  t += '<TABLE STYLE="margin-left:4px;width:120px;" CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>';
  t += '<TD CLASS="compact">Visitors Since<DIV STYLE="position:relative;top:-3px;">6th Dec 2001</DIV></TD>';
  t += '<TD STYLE="vertical-align:middle;">';
  if (_ONLINE) {
    t += '<A HREF="http://counter.digits.com/wc/--info=yes/silverfoxbadminton" TARGET="_digits" TITLE="Unique Visitor Counter">';
    // FONT: -c/<No.>
    t += '<IMG STYLE="border:1px solid silver;" SRC="http://counter.digits.com/wc/-d/4/-r/-z/-c/7/-f/FFFFFF/-b/000000/silverfoxbadminton" WIDTH=45 HEIGHT=15 ALT="Counter">';
    t += '</A>';
  } else {
    t += '<IMG STYLE="border:1px solid silver;" SRC="/img/blackdot.gif" WIDTH=45 HEIGHT=15>';
  }
  t += '</TD></TR></table>';
  t += '<div class="compact" style="margin-left:4px;">Powered by <A HREF="http://www.digits.com/" TARGET="_window">WebCounter</A></div>';

  t += f_menuSpacer(1);

  // BOTTOM EDGE
  t += '<DIV STYLE="background-image:url(/img/edge_belowbanner.gif);background-repeat:repeat-x;">';
  t += '<IMG SRC="/img/blankdot.gif" WIDTH=' + _INDEX_WIDTH + ' HEIGHT=6>';
  t += '<IMG SRC="/img/edge_bottomcorner.gif" WIDTH=6 HEIGHT=6></DIV>';

  // END INDEX - OUTER DIV
  t += '</DIV>';

  // sfindex
  t += '</div>';

  return t;
}

// NEWS CONTAINER (HOMEPAGE)
// Colour - _GREY (NORMAL), _RED, _GREEN
function f_container(Title,Link,Body,Colour) {
  var t;

  // DEFAULT
  if (typeof(Colour) == 'undefined') Colour = _GREY;

  t = '<DIV CLASS="news_title';
  if (Colour != _GREY) {t += ' title_' + Colour;}
  t += '">';

	// OLD STYLE
/*	
  t += '<TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>';
  t += '<TD>&nbsp;&nbsp;&nbsp;<A HREF="' + Link + '"><B>' + Title + '</B></A></TD>';
  t += '<TD CLASS="news_link" STYLE="text-align:right;"><A HREF="' + Link + '">More...</A>&nbsp;</TD>';
  t += '</TR></TABLE>';
*/
	// Works ok with <span> but not <div>!
	t += '<span class="news_link" style="float:right;"><a href="' + Link + '">More &gt;&gt;</a></span>';
	t += '<b>' + Title + '</b>';
  t += '</DIV>';
	
  t += '<DIV CLASS="news_msg"';
  if (Colour == _RED) {
    t += ' STYLE="background-color:#FFDDDD;"';
  } else if (Colour == _GREEN) {
    t += ' STYLE="background-color:#DDFFDD;"';
  } else if (Colour == _BLUE) {
    t += ' STYLE="background-color:#DDDDFF;"';
  }
  t += '>' + Body + '</DIV>';

  return t;
}