// May 10 2005

var totalGraphics=0;
var graphic = new Array();
var selected=0;
var lastnum=0;
var imageSubdirectory = "images/";
var imagePrefix       = "SWP_";
var onSuffix          = "_ON.gif";
var offSuffix         = "_OFF.gif";
var overSuffix        = "_SEL.gif";
var frameTarget       = "_top";
var num;
var Ltop = 0;
var currtop = Ltop;
var today = new Date();
var electionDay = new Date();
var secval = 1;

// --------------------- MAKE CHANGES ---------------------------------------

createMenu(30, 150, "home", "Sonora Waterpolo Home Page", "index.html");
createMenu(30, 150, "schedules", "Practice & Game Schedules", "schedules.html");
//createMenu(30, 150, "fund", "Sonora Waterpolo Fundraisers", "funds.html");
//createMenu(30, 150, "sponsors", "Sonora Waterpolo Sponsors", "sponsors.html");
createMenu(30, 150, "about", "About Sonora Waterpolo", "about.html");
createMenu(30, 150, "join", "Join the Sonora Waterpolo Team", "join.html");
createMenu(30, 150, "boys", "The Boys' Waterpolo Team", "boys.html");
createMenu(30, 150, "girls", "The Girls' Waterpolo Team", "girls.html");
//createMenu(30, 150, "highlights", "game highlights", "highlights.html");
//createMenu(30, 150, "gallery", "photo gallery", "gallery.html");
//createMenu(30, 150, "links", "Water Polo Links", "links.html");
// --------------------- END CHANGES -----------------------------------------

function initpage()
{
  with(this.document)
  {
    write('</head><body bgcolor="#0000ff" '); 
    write('text="#000000" link="#000000" vlink="#000000" ');
    write('alink="#000000" topmargin="0" leftmargin="0">');
    header();
    write('<table bgcolor="#0fffff" border="0" bordercolor="green" cellpadding="0" cellspacing="0" width="800"><tr>');
    write('<td width="170" valign="top" bgcolor="#0fffFF">');
  }
}

function header()
{
  with(this.document)
  {
    write('<table border="0" bordercolor="red" cellpadding="0" cellspacing="0" width="800"><tr>');
    write('<td width="250" height="202"><center><img src="images/logo_final_250.jpg" alt="Sonora Waterpolo logo" height="252" width="250"></center></td>');
    write('<td width="550" bgcolor="#000000" align="center">');
//    doDate();
    write('<img src="images/pool_banner.jpg" width="550" height="176" alt="waterpolo game" border="0" vspace="15">');
    doDate();
    write('</td>');
    write('</tr></table>');

    write('<table width="800" border="0" bordercolor="yellow" cellpadding="0" cellspacing="0" height="15">');
    write('<tr><td width="800" height="15" bgcolor="#0fffff">');
    write('</td>');
    write('</tr></table>');

  }
}
function MenuItem (height, width, name, infoText, link)
{
  this.height   = height;
  this.width    = width;
  this.name     = name;
  this.info     = infoText;
  this.link     = link;
  this.on       = new Image (width, height);
  this.on.src   = imageSubdirectory + imagePrefix + name + onSuffix;
  this.off      = new Image (width, height);
  this.off.src  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.offname  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.over     = new Image (width, height);
  this.over.src = imageSubdirectory + imagePrefix + name + overSuffix;
  this.info     = infoText;
  this.selected   = 0;
//51
  this.pos      = currtop;
  currtop += height;
}
function createMenu (height, width, name, infoText, link)
{
  graphic[totalGraphics] = new MenuItem(height, width, name, infoText, link);
  totalGraphics++;
}
function doClick (num)
{
  document.images[graphic[num].name].src = graphic[num].on.src;
  if(lastnum != num){document.images[graphic[lastnum].name].src = graphic[lastnum].off.src;}
  this.lastnum = num;
  selected = num;
}
function doMouseOver(num)
{
  if (num != selected)
  {
    document.images[graphic[num].name].src = graphic[num].over.src;
  }
  self.status = graphic[num].info;
}
function doMouseOut(num)
{
  if (num != selected)
  {
    document.images[graphic[num].name].src = graphic[num].off.src;
  }
}
function doOnLoad(page)
{
  var page;
  doClick(page);
}

function writemenu()
{
	with(this.document)
	{
		write('<table border="0" width="170" bordercolor="pink" cellpadding="0" cellspacing="0" valign="top"><tr>');
		write('<td valign="top"><div style="margin-left:5px;margin-top:5px">');
		for(i = 0; i < totalGraphics; i++)
		{
			write ('<a target="' + frameTarget + '" href="' + graphic[i].link + '" onMouseOver="doMouseOver(' + i + '); return true" onMouseOut="doMouseOut(' + i + ')" onClick="doClick(' + i + ')">');
			write ('<img name="' + graphic[i].name + '" src="' + graphic[i].offname + '" alt="' + graphic[i].name + '" width="' + graphic[i].width + '" height="' + graphic[i].height + '" border="0" vspace="3">');
			write ('</a><br>');
		}
		write('</div><br/>');
		write('</td></tr><tr><td><!-- image src="images/KNXU_menu_btm.gif" width="150" height="32" --></td></tr></table>');
	}
}

function left_setup()
{
    this.document.write('<br/><div style="margin-left:0px">');
}

function main_setup()
{
    with(this.document)
    {
	write('</div></td>');  //end of left menu button cell//
        write('<td valign="top" bgcolor="#0fffff" width="615">');
        write('<div style="color:black;margin-top:10px;margin-left:20px;margin-right:20px;font-family:arial;font-size:10pt">');
    }
}

function right_setup()
{
    with(this.document)
    {
	write('</div></td>');
	write('<td width="15" valign="top" bgcolor="#0fffff">'); //FAR RIGHT BORDER SKINNY//
	write('<div style="margin-left:0px">');
    }
}

function endpage()
{
  with(this.document)
  {
    write('</div></td></tr><tr><td><!-- background="images/KNXU_bottom.gif" --></td>');
    write('<td><!-- background="images/KNXU_bottom.gif" -->');
    write('<span style="color:#ffffff;font-family:arial;font-size:7pt">');
    write('<center>Copyright 2005 - KNXU Communications</center></span></td>');
    write('<td></td></tr></table>');
  }
}


function Dcountdown()
{
//	electionDay.setFullYear(2004);
//	electionDay.setMonth(10);
//	electionDay.setDate(2);
//	electionDay.setHours(7,0,0,0);
	electionDay.setFullYear(2004);
	electionDay.setMonth(2);
	electionDay.setDate(2);
	electionDay.setHours(7,0,0,0);
	var timeleft = electionDay.getTime() - today.getTime();
	var days = timeleft/(24*3600000);
	days = parseInt(days.toString());
	var hoursleft = timeleft-days*24*3600000;
	var hours = hoursleft/3600000;
	hours = parseInt(hours.toString());
	var minsleft = hoursleft-hours*3600000;
	var mins = Math.floor(minsleft/60000);
	var secsleft = minsleft-mins*60000;
	var secs = Math.floor(secsleft/1000);
	var ticks = hours;
	if(mins < 10){
		ticks += ":0" + mins;
	}else{
		ticks += ":" + mins;
	}
	if(secs < 10){
		ticks += ":0" + secs;
	}else{
		ticks += ":" + secs;
	}
	secval = secs;
	
//	return(days + " days " + hours + "h " + mins + "m " + secs + "s left until polls open 2 Mar 2004");
	with(this.document)
	{
	  write('<table border="1" width="200"><tr><td valign="top"><div style="color:#ffff00;font-family:arial;font-size:12pt">');
	  write("<b>The&nbsp;March&nbsp;2,&nbsp;2004 California&nbsp;Primary&nbsp;Election</b>");
	  write('</div></td></tr>');
	  write('<tr><td><div style="color:white;font-family:arial;font-size:12pt;font-weight:bold">Polls open in</div></td></tr>');
	  write('<tr><td align="center">');
	    write('<table border="1">');
	    write('<tr>');
	    write('<td align="center" width="50" rowspan="3">');
	    write('<img src="images/GOPeleph_shiny.gif" height="32" width="34" alt="GOP pin"></td>');
	    write('<td width="20" align="right" bgcolor="#000078"><div style="color:#fff800;font-family:arial;font-size:12pt"><b>' + days + '</b></div></td>');
	    write('<td><div style="color:white;font-family:arial;font-size:12pt">&nbsp;&nbsp;days</div></td></tr>');
	    write('<tr><td width="20" align="right" bgcolor="#000078"><div style="color:#fff800;font-family:arial;font-size:12pt"><b>' + hours + '</b></div></td>');
	    write('<td><div style="color:white;font-family:arial;font-size:12pt">&nbsp;&nbsp;hours</div></td></tr>');
	    write('<tr><td width="20" align="right" bgcolor="#000044"><div style="color:#fff800;font-family:arial;font-size:12pt"><b>' + mins + '</b></div></td>');
	    write('<td><div style="color:white;font-family:arial;font-size:12pt">&nbsp;&nbsp;minutes</div></td>');
	    write('</tr>');
	    write('</table>');
	  write('</td></tr></table>');
	}
    setTimeout("location.reload()",60000);
}

function doDate()
{
//	this.document.write('<div style="color:#ffff00;margin-left:10px;margin-top:5px;font-family:arial;font-size:14"><center><b>' + getDayStr(today.getDay()).toString() + ', ');
	this.document.write('<div style="color:#ffff00;margin-right:0px;margin-bottom:0px;font-family:arial;font-size:14"><center><b>' + getDayStr(today.getDay()).toString() + ' ');
	this.document.write(getLongMonth(today.getMonth()) + " " + today.getDate().toString() + ", ");
	this.document.write(today.getFullYear().toString() + "</b></center></div>");
}
function getMon(mon)
{
	var month = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	return month[mon];
}
function getLongMonth(mon)
{
	var month = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	return month[mon];
}
function getDayStr(day)
{
	var week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	return week[day];
}


