// JavaScript Copyright 1999,2000 Mt. Rosalie Enterprises
// email Dave Gibson, scriptit@hotbot.com
// ** The next section of code is for browser detection.

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// Note: Opera and WebTV spoof Navigator.  We do strict client
// detection. If you want to allow spoofing, take out the tests
// for opera and webtv.
var is_nav  = ((agt.indexOf('mozilla')!=-1)
            && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1)
            && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                      (agt.indexOf("; nav") != -1)) );
var is_nav5 = (is_nav && (is_major == 5));
var is_nav5up = (is_nav && (is_major >= 5));

var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) &&
              (agt.indexOf("msie 5.0")==-1) );
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) &&
              (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);

var is_opera = (agt.indexOf("opera") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);

// ** End of browser detection code.

// The next section is for the date display at the top
// of the nav section on each page.

function MakeArray(n) {
 this.length = n
 return this
}

var aMinute = 1000 * 60
var aHour = 60 * aMinute
var aDay = 24 * aHour
var threeDays = 3 * aDay

months = new MakeArray(12)
months[0] = "January"
months[1] = "February"
months[2] = "March"
months[3] = "April"
months[4] = "May"
months[5] = "June"
months[6] = "July"
months[7] = "August"
months[8] = "September"
months[9] = "October"
months[10] = "November"
months[11] = "December"

days = new MakeArray(7)
days[0] = "Sunday"
days[1] = "Monday"
days[2] = "Tuesday"
days[3] = "Wednesday"
days[4] = "Thursday"
days[5] = "Friday"
days[6] = "Saturday"

targetDate = new Date()
nowDay = targetDate.getTime()
targetDate.setTime(nowDay)
var theDay = days[targetDate.getDay()]
var theMonth = months[targetDate.getMonth()]
var theYear = targetDate.getYear()
if (is_major >=4) {
theYear = targetDate.getFullYear()
 } else {
 theYear = targetDate.getYear()
}

var searchHtml = '<form name="searchpage" onSubmit="return searchPage()">'
 +'<b><font color="white" size="-1">SITE SEARCH:</font></b><br><input type="text" size=12 name="keyword"> '
 +'<input type="button" value="Search" onClick="searchPage()"><br>'
 +'<select name="and_or" size=1><option>any word-or<option>all words-and'
 +'<option>exact match</select></form>'

var displayIt = "<table align='left' cellspacing='0' cellpadding='0'><tr align='center'><td align='center' height='18'>"
displayIt += "<font color='white'>" + theDay + "<br>" + theMonth + " " + targetDate.getDate() + ", " + theYear + "</font><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='center'><br><img src='images/logo.gif' border='0'></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='18' width='99'></a><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='art/default.htm' onMouseOver='return lighten(1)' onMouseOut='return darken(1)' onClick='clicked(1)'><img src='images/sh1.jpg' border='0' alt='My Art Work' name='nav1'></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='design/default.htm' onMouseOver='return lighten(3)' onMouseOut='return darken(3)' onClick='clicked(3)'><img src='images/ab1.jpg' border='0' alt='Web Design' name='nav3'></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='football/default.htm' onMouseOver='return lighten(2)' onMouseOut='return darken(2)' onClick='clicked(2)'><img src='images/fb1.jpg' border='0' alt='My Football Site' name='nav2'></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='family/default.htm' onMouseOver='return lighten(4)' onMouseOut='return darken(4)' onClick='clicked(4)'><img src='images/fm1.jpg' border='0' alt='My Family' name='nav4'></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='contact.htm' onMouseOver='return lighten(5)' onMouseOut='return darken(5)' onClick='clicked(5)'><img src='images/con1.jpg' border='0' alt='Contact Me' name='nav5'></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='collect/default.htm' onMouseOver='return lighten(6)' onMouseOut='return darken(6)' onClick='clicked(6)'><img src='images/col1.jpg' border='0' alt='My Collection' name='nav6'></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='music/default.htm' onMouseOver='return lighten(7)' onMouseOut='return darken(7)' onClick='clicked(7)'><img src='images/mus1.jpg' border='0' alt='Music Info' name='nav7'><br><br></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105' name='nav10'></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><a href='default.htm' onMouseOver='return lighten(0)' onMouseOut='return darken(0)' onClick='clicked(0)'><img src='images/hm3.jpg' border='0' alt='roywalton.com Home' name='nav0'><br><br></a></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105' name='nav11'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105' name='nav12'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105' name='nav13'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105' name='nav14'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "<tr><td align='left' height='15' width='105'><img src='images/blank.jpg' border='0' height='15' width='105'><br><br></td><td>&nbsp; &nbsp; &nbsp; &nbsp; </td></tr>"
displayIt += "</table>"

var main_pic = new Array();
var lit_pic = new Array();
var active_pic = new Array();
var stat_display = new Array();

function preloadImages(num,main,lit,active,stat) {
 main_pic[num] = new Image();
 main_pic[num].src = main;
 lit_pic[num] = new Image();
 lit_pic[num].src = lit;
 active_pic[num] = new Image();
 active_pic[num].src = active;
 stat_display[num] = stat
}

// define the image swapping in the following format:
// preloadImages(button_num,main_pic_src,lit_pic_src,active_pic_src,status_bar_text)

preloadImages(0,"images/hm1.jpg","images/hm2.jpg","images/hm3.jpg","Welcome to RoyWalton.com");
preloadImages(1,"images/sh1.jpg","images/sh2.jpg","images/sh3.jpg","Check Out My Art!");
preloadImages(2,"images/fb1.jpg","images/fb2.jpg","images/fb3.jpg","Everything Football!");
preloadImages(3,"images/ab1.jpg","images/ab2.jpg","images/ab3.jpg","My Web Designs");
preloadImages(4,"images/fm1.jpg","images/fm2.jpg","images/fm3.jpg","The Rest of the Walton Family");
preloadImages(5,"images/con1.jpg","images/con2.jpg","images/con3.jpg","Contact Me");
preloadImages(6,"images/col1.jpg","images/col2.jpg","images/col3.jpg","My Collection");
preloadImages(7,"images/mus1.jpg","images/mus2.jpg","images/mus3.jpg","Music Info");

var timer1
var isActive = 0
var isLit = 0

function statusDisplay() {
 window.status = stat_display[isLit]
 timer1 = 0
 timer1 = setTimeout("statusDisplay()", 50)
}

function lighten(num) {
 isLit = num
 if (num != isActive) {
  eval("document.nav"+num+".src = lit_pic["+num+"].src;");
 }
 return false;
}

function darken(num) {
 if (isLit != isActive)
  isLit = isActive;
 if (num != isActive)
  eval("document.nav"+num+".src = main_pic["+num+"].src;");
 return false;
}

function clicked(num) {
 wasActive = isActive
 isActive = num
 isLit = num
 darken(wasActive);
 if (document.images) {
  eval("document.nav"+num+".src = active_pic["+num+"].src;");
 }
 return true;
}

function reLight(num) {
 for (i=0; i<=5; i++) {
  eval("document.nav"+i+".src = main_pic["+i+"].src;");
 }
 isActive = num
 isLit = num
 if (document.images) {
  eval("document.nav"+num+".src = active_pic["+num+"].src;");
 }
}

function reset() {
 clearTimeout(timer1)
}

var extractStr

function searchStr() {
// if (document.location.search) {
//  var sstring = document.location.search
//  var extractStr = sstring.substring(sstring.indexOf("?") + 1, sstring.length)
 y = eval(extractStr)
 reLight(y)
// }
}

function startIt() {
 searchStr();
 statusDisplay();
}

var search_htm_url = "search.html";

function searchPage() {
 if ((document.searchpage.keyword.value.length == 0)
 || (document.searchpage.keyword.value == " ")) {
  alert("First you must enter a keyword to search for.");
 } else {
  sel = document.searchpage.and_or.selectedIndex;
  location.href = search_htm_url + "?"
   + escape(document.searchpage.keyword.value)
   + (sel==0?"&or":(sel==2?"&exact":"&and"));
 }
 return false;
}

function initArray() {
 for (var i = 0; i < initArray.arguments.length; i++)
  this[i] = initArray.arguments[i];
 this.length = initArray.arguments.length;
}

var chrome = new initArray(
 "menubar",
 "menubar,toolbar",
 "menubar,status,resizable,scrollbars",
 "");

var popUpWin = '';
var winFeatures = '';
var track = '';
function makePopUpWin(high,wide,features) {
 winFeatures = features
 if (track == 1 && !popUpWin.closed) {
  popUpWin.close();
  track = 0
 }
   popUpWin = eval("window.open('shareit.html','newWin','"+chrome[winFeatures]+",height="+high+",width="+wide+"')");
   if (!popUpWin.opener) popUpWin.opener = self;
   track=1
}

function closePopUpWin() {
// if (popUpWin && !popUpWin.closed)
  popUpWin.close();
  track = 0
}


