// ******************************
// *   www.robotron-2084.co.uk  *
// ******************************
// *   v3.1 25th January 2006   *
// *     ©2006 Dave Langley     *
// ******************************  

// Script to display header logo and graphics at the top of the screen (using absolute placement) //

// Don't do anything in older browsers that definitely do not work! //
if (!badBrowser){

// Initialise variables //
var dateObj = 0; 
var todayObj = 0;
dateObj = new Date(document.lastModified);
todayObj = new Date();
var year = dateObj.getYear();
var month = dateObj.getMonth();
var date = dateObj.getDate();
var day = dateObj.getDay() - 1;
var thisyear = todayObj.getYear();
var thismonth = todayObj.getMonth();
var thisdate = todayObj.getDate();
var thisday = todayObj.getDay() - 1;

// Correct variable where required //
if (day<0) { day = 6; }
if (thisday<0) { thisday = 6; }
if (year <= 2000) { if (year <= 100) {year+=2000;} else {year+=1900;};}
if (thisyear <= 2000) { if (thisyear <= 100) {thisyear+=2000;} else {thisyear+=1900;};}

// Define text strings required for long date format //
var endSUF = 'th';
if (date == 1 || date == 21 || date == 31) { endSUF = 'st'; }
if (date == 2 || date == 22) { endSUF = 'nd'; }
if (date == 3 || date == 23) { endSUF = 'rd'; }

// Define text strings required for long date format //
var thisSUF = 'th';
if (thisdate == 1 || thisdate == 21 || thisdate == 31) { thisSUF = 'st'; }
if (thisdate == 2 || thisdate == 22) { thisSUF = 'nd'; }
if (thisdate == 3 || thisdate == 23) { thisSUF = 'rd'; }

var mNAMES = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var dNAMES = new Array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');



// Build long date format for today //
var DATEstr = dNAMES[thisday] + ", " + thisdate + thisSUF + " " + mNAMES[thismonth] + " " + thisyear;

// Build long date format for last time file was updated //
var LUstr = "This page was last updated on " + dNAMES[day] + ", " + date + endSUF + " " + mNAMES[month] + " " + year;

// Build copyright string setting end year to current year //
var COPYstr = "©2000-" + thisyear + " Dave Langley - All Rights Reserved";



// Fix website logo for certain special occasions otherwise use a random logo from selection //
var LOGOname ="";
var numberOfLogos = 10; 
var logoNumber = Math.ceil((Math.random()) * numberOfLogos - 0.01);

if (thismonth+1 == 12) {LOGOname = "gifs/logo_christmas.gif";}                      // December - it's christmas! //
// else 
// if (thisdate == 3 && thismonth+1 == 5) {LOGOname = "gifs/logo_special.gif";};    // 3rd May! //
else 
   {LOGOname = "gifs/logo_" + logoNumber + ".gif";};                                // random choice //



// Calculate the inner width of the client browser window //
var browserWidth = 0; 
if (self.innerHeight) // All except Internet Explorer //
   {browserWidth = window.innerWidth; browserHeight = window.innerHeight;}
else if (document.documentElement && document.documentElement.clientHeight) // Internet Explorer 6 in Strict Mode //
   {browserWidth = document.documentElement.clientWidth; browserHeight = document.documentElement.clientHeight;}
else if (document.body) // Internet Explorer //
   {browserWidth = document.body.clientWidth; browserHeight = document.body.clientHeight;}

// Calculate total width and height of HTML page (including areas out of sight) //
var pageWidth = 0; var pageHeight = 0;
if ((document.body.scrollHeight) > (document.body.offsetHeight)) 
   {pageWidth = document.body.scrollWidth; pageHeight = document.body.scrollHeight;}
else 
   {pageWidth = document.body.offsetWidth; pageHeight = document.body.offsetHeight;}



// Set minimum width to ensure pages and menus appear correctly //
var displayWidth; 
if (browserWidth < 900){displayWidth=900;}else{if(ie){displayWidth=browserWidth;}else{displayWidth=pageWidth;};}

// When page has built set main display width to be correct as it cannot be calculated before building //
if ((!(ns4|ns6|ns7))||mz7)
   {document.all["mainDisplay"].style.width = displayWidth;}
else {if (ns4) // Netscape 4 //
   {document.layers["mainDisplay"].width= displayWidth;}
else           // Netscape 6 and 7  //
   {document.getElementById("mainDisplay").style.width = displayWidth;};};
   
// Place footer at bottom of screen for small pages //
var displayHeight;
if (pageHeight > browserHeight-57) {displayHeight=pageHeight-57;} else {displayHeight=browserHeight;}
if (ie) {displayHeight-=4;} // Internet Explorer tweak - why does it need this? //



// Build header and Logo HTML and display using absolute placement at top of screen //
HTMLstr  = "<div style=\"z-index: 2; width: " + displayWidth + "px; height: 122px; top: 0px; left: 0px; overflow: hidden; position: absolute\"><table width=" + displayWidth + "px border=0px cellspacing=0px cellpadding=0px align=center><tr><td style=\"background-image: url(gifs/logo_underlay.gif)\"><img src=\"" + LOGOname + "\" width=" + displayWidth + "px height=75px border=0px alt=\"\"></td></tr></table><table width=" + displayWidth + "px height=47px border=0px cellspacing=0px cellpadding=0px align=left><tr valign=middle><td width=225px height=47px style=\"background-image: url(gifs/top_l1.gif); width: 225px; height: 47px\"><p style=\"left: 10px; top: -2px; position: relative; font-weight: bold\">" + DATEstr + "</p></td><td width=55px height=47px style=\"background-image: url(gifs/top_l2.gif); width: 55px; height: 47px\"></td><td width=28px height=47px style=\"background-image: url(gifs/top_l3.gif); width: 28px; height: 47px\"></td><td width=" + (displayWidth-283) + "px height=47px style=\"background-image: url(gifs/top_r.gif); width: " + (displayWidth-283) + "px; height: 47px\"></td></tr></table></div>\n";



// Build footer HTML and display //
HTMLstr += "<div style=\"z-index: 3; width: " + displayWidth + "px; height: 47px; top: " + displayHeight + "px; left: 0px; overflow: hidden; position: absolute\"><table width=" + displayWidth + "px border=0px cellspacing=0px cellpadding=0px align=left><tr valign=middle><td width=225px height=47px style=\"background-image: url(gifs/bottom_l1.gif); width: 225px; height: 47px\"></td><td width=55px height=47px style=\"background-image: url(gifs/bottom_l2.gif); width: 55px; height: 47px\"></td><td width=28px height=47px style=\"background-image: url(gifs/bottom_l3.gif); width: 28px; height: 47px\"></td><td width=" + (displayWidth-283) + "px height=47px style=\"background-image: url(gifs/bottom_r.gif); width: " + (displayWidth-283) + "px; height: 47px\"><table width=\"100%\" border=0px cellspacing=0px cellpadding=0px align=center><tr valign=middle><td width=88px style=\"width: 88px; text-align: left\"><a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"gifs/valid_html_v4.01.gif\" border=0px width=88px height=31px alt=\"This website is fully HTML v4.01 compliant!\"></a></td><td style=\"text-align: center\">" + COPYstr + "<br>" + LUstr + "</td><td width=88px style=\"width: 88px; text-align: right\"><a href=\"http://jigsaw.w3.org/css-validator/\"><img src=\"gifs/valid_css.gif\" border=0px width=88px height=31px alt=\"This website is fully CSS compliant!\"></a></td></tr></table></td></tr></table></div>\n";



// Display a warning message for debugging only //
//HTMLstr += "<div style=\"z-index: 99; width: 251px; top: 166px; left: 19px; overflow: hidden; position: absolute\"><table width=251px border=2px cellspacing=3px cellpadding=4px align=left bgcolor=purple><tr><td style=\"height: 280px\"><h4><u><b>Debugging Information</b></u></h4><h6><b>Window Properties</b><br>Browser Width=" + browserWidth + " | Browser Height=" + browserHeight + "<br>HTML Width=" + pageWidth + " | HTML Height=" + pageHeight + "<br><br><br><b>Browser Identification</b><br>" + agt + "<br><br>IE: All=" + ie + " | v4=" + ie4 + " | v5+6=" + ie5 + " | v6=" + ie6 + "<br>Netscape: v4=" + ns4 + " | v6-8=" + ns6 + " | v7=" + ns7 + " | v8=" + ns8 + "<br>Opera: v5=" + op5 + " | v6=" + op6 + " | v7-9=" + op7 + " | v8=" + op8 + " | v9=" + op9 + "<br>Firefox: v0 =" + ff0vX + " | v1=" + ff1 + " | v1.5 =" + ff1v5 + "<br>Mozilla =" + mz7 + " | KDE=" + kde + " | Safari=" + saf + "<br>Legacy Browser=" + exclude + "<br><br><br><b>Operating System</b><br>Windows=" + win + " | Macintosh=" + mac + " | Linux/other=" + lin + "</h6></td></tr></table></div>\n"; 



// Output HTML code //
document.writeln(HTMLstr);



// *********************
}//* DO NOT EDIT THIS *
// *********************
// End of badBrowser exclude //