var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

var navoptions = [
'<select name ="Destination2" onChange="goTo(this)">',
  '<option value="NoValue" SELECTED>--- KeeneFest WebSite Index ---</option>',
  '<option value="index.html">2002 Home Page</option>',
  '<option value="../arch2003/index.html">2003 Home Page</option>',
  '<option value="../kfest2001.pdf">2001 Flyer (pdf)</option>',
  '<option value="KF5.pdf">2002 Flyer (pdf)</option>',
  '<option value="concerts.html">Concert Information</option>',
  '<option value="http://wellhost.com/keenefest/mailist.html">Join our Mailing List</option>',
  '<option value="progsing.html">Singers Program</option>',
  '<option value="progconduct.html">Conductors Program</option>',
  '<option value="application2002.html">Application Form</option>',
  '<option value="kent.html">About Kent School</option>',
  '<option value="caramoor.html">About Caramoor Festival</option>',
  '<option value="faculty.html">Keenefest Faculty</option>',
  '<option value="sched.html">Festival Schedule</option>',
  '<option value="board.html">Keenefest Board of Directors</option>',
  '<option value="musicstores.html">List of Music Sources</option>',
  '<option value="amazon.html">KeeneFest/Amazon.com BOOKSTORE</option>',
  '<option value="checklist.html">Participant Checklist</option>',
  '<option value="drivect.html">Driving to Kent, CT</option>',
  '<option value="pastconcerts.html">Past Performances</option>',
  '<option value="ourlogo.html">Embroidery Logo</option>',
  '<option value="2002pix.html">Archive: 2002 Pictures</option>',
  '<option value="reviewgluck.html">Review of Bach Mass in B minor</option>',
  '<option value="howtovideo.html">Notes: Video checklist</option>',
'</select>'
]

function getRef(id) {
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
 }
function getSty(id) {
 return (isNS4 ? getRef(id) : getRef(id).style);
 }

function init () {
//  alert("DOM="+isDOM+" / IE4="+isIE4+" / NS4="+isNS4+" / "+getRef('navpulldown'))

  }

function buildHeader(bodyclass,dobook) {
  if (!bodyclass) bodyclass='combody';
  document.write('<table width="100%" border=0 cellpadding=10 cellspacing=0>');
  document.write(' <tr>');
  document.write('  <td align=center style="background-color:#FFBB00; color:#000000; border-color:#FFBB00">');
  document.write('   <span style="padding-top: 5; padding-bottom: 5">');
  document.write('    <a href="index.html"><img border=0 src="banner.jpg" align=middle alt="Click here to return to the KeeneFest Home Page"></a>');
  document.write('    </span>');
  document.write('   </td>');
  document.write('  <td style="background-color:#FFBB00; color:#000000; border-color:#FFBB00">');
  document.write('   <TABLE WIDTH="100%">');
  document.write('    <tr>');
  document.write('     <td align="center" style="background-color:#FFBB00; color:#000000; border-color:#FFBB00">');
  document.write('      <form name="none" action="">');
  document.write('       <table border=0 cellspacing=0 cellpadding=0>');
  document.write('        <tr>');
  document.write('         <td valign="middle" align="right" style="background-color:#FFBB00; color:#000000; border-color:#FFBB00">');
  document.write('          <center>');
  for (var i=0;i<navoptions.length;i++) {
    document.write(navoptions[i])
    }
//document.write('          <a href="concerts.html"><font size="+2">Concert Information</font></a>');
  document.write('          <br><a href="http://wellhost.com/keenefest/mailist.html">Join our mailing list</a></center><br>');
  document.write('          </center>');
  document.write('          </td>');
  document.write('         </tr>');
  document.write('        </table>');
  document.write('       </form>');
  if (dobook) {
    document.write('      <font size="-1">');
    document.write('      (Bookmark this page and check for updates!)');
    document.write('      <br />');
    document.write('       Last <a href="changes.html">updated</a>');



    document.write('       2003 Jul 16  ');



    document.write('       </font>');
    }
  document.write('      </TD>');
  document.write('     </TR>');
  document.write('    </table>');
  document.write('   </td>');
  document.write('  </tr>');
  document.write(' <tr><td colspan=2 class='+bodyclass+'><span class='+bodyclass+'>');
  }

function buildFooter() {
  document.write('<CENTER>');
  document.write('<P>');
  document.write('<HR ALIGN=CENTER>');
  document.write('[');
  document.write('<a href="http://wellhost.com/contact.html?to=webmaster&force=1&subject=KeeneFestWeb:+Contact">Contact Us</a>');
  document.write(']');
  document.write('<p>Other pages on this site:');
  document.write('<form name="none" action="">');
  document.write('<table border=0 cellspacing=0 cellpadding=0>');
  document.write('<tr><td valign="middle" align="right" style="background-color:#FFFFFF; color:#000000; border-color:#FFFFFF">');
  for (var i=0;i<navoptions.length;i++) {
    document.write(navoptions[i])
    }
  document.write('</td></tr></table>');
  document.write('</form>');
  document.write('&copy; 2003 The Dennis Keene Choral Festival, Inc.');
  document.write('<br><font size="-1">');
  show_visits();
  document.write('</font></center>');
  document.write('</span></td></tr></table>');
  }

function goTo(pagename) {
  if ((-1 < pagename.selectedIndex) && (pagename.options[pagename.selectedIndex].value != 'nil')) {
    val = pagename.options[pagename.selectedIndex].value;
    if (val!="NoValue") {
      pagename.selectedIndex=0;
      location.href=val;
      return true;
      }
    }
  }


function validForm(inform) {
  if (document.all || document.getElementById) {  // IE or NS6+ only
    for (i = 0; i < inform.length; i++) {
      var tempobj = inform.elements[i];
      if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset") tempobj.disabled = true;
      }
    }

  var tryemail = inform.email.value;
  var errSt="";
  var toploc = ""
  var switchto = "";

  if (tryemail == "") {
    errSt="* You didn't enter your email address."
    switchto = inform.email;
    }
  else if (tryemail.indexOf("@")<3){
    errSt="* The email address ("+tryemail+") doesn't look right.\n  There's no '@' sign; Please use the external e-mail address form as in the example."
    switchto = inform.email;
    }

  if (inform.required.value != "") {
    var required = inform.required.value.split(",")
    for (var i=0;i<required.length;i++) {
      if (inform[required[i]].value == "") {
        errSt += '\nYou didn\'t supply a value for '+required[i]
        if (switchto == "") switchto=inform[required[i]]
        }
      }
    }

  if ( ((inform.apply_as.value == 'Conductor') || (inform.apply_as.value == 'Fellow')) && (inform.is_singer.value == "")) {
       errSt += '\nYou didn\'t indicate whether you are a singing conductor'
       if (switchto == "") switchto=inform.apply_as;
       }


  if (errSt != "") {
    alert("FORM INCOMPLETE:\n"+errSt)
    if (toploc != "") location.href=toploc
    else if (switchto != "") switchto.focus()
    for (i = 0; i < inform.length; i++) {
      var tempobj = inform.elements[i];
      if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset") tempobj.disabled = false;
      }
    return false;
    }
  else return true;
  }


function show_visits(page_cookie) {
  if (!page_cookie) {
    var page_cookie=location.href
    var i=page_cookie.indexOf("?",0)
    if (-1 < i) {
      page_cookie=page_cookie.substring(0,-1+i)
      }
    var i=page_cookie.indexOf("/",0)
    while (i > -1) {
      page_cookie=page_cookie.substring(1+i,page_cookie.length)
      i=page_cookie.indexOf("/",0)
      }
    }
  var cookie_date=new Date(document.lastModified);
  var expdate = new Date();
  expdate.setTime(expdate.getTime()+(5*24*60*60*1000));
  document.write("<Font color=0000FF>" + "Page "+page_cookie+" last updated: "+ document.lastModified);
  if (!(cookie_date == GetCookie(page_cookie))){
    SetCookie(page_cookie,cookie_date,expdate);
    document.write(" (<font color='red'>Changed</font> since your last visit)");
    }
  else {
    document.write(" (Unchanged since your last visit)");
    }
  document.write("</font>");
  }

function SetCookie (name, value) {
  var args = SetCookie.arguments;
  var len = SetCookie.arguments.length;
  var expires = (len > 2) ? args[2] : null;
  var path = (len > 3) ? args[3] : null;
  var domain = (len > 4) ? args[4] : null;
  var secure = (len > 5) ? args[5] : false;
  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) +
  ((domain == null) ? "" : ("; domain=" + domain)) +
  ((secure == true) ? "; secure" : "");
  }

function getParseVal (xstr,startpoint) {
  var endindex = xstr.indexOf ("&", startpoint);
  if (endindex == -1) endindex = xstr.length;
  var regexp = /%/g;
  return unescape(xstr.substring(startpoint, endindex)).replace(regexp, " ");
  }

function getParse (xstr,name) {
  var prefix = name + "=";
  var prefixlen = prefix.length;
  var strlen = xstr.length;
  var i = 0;
  while (i < strlen) {
    var j = i + prefixlen;
    if (xstr.substring(i, j) == prefix) return getParseVal(xstr,j);
    i = xstr.indexOf("&", i) + 1;
    if (i == 0) break;
    }
  return "??";
  }

function getCookieVal (startpoint) {
  var endindex = document.cookie.indexOf (";", startpoint);
  if (endindex == -1) endindex = document.cookie.length;
  return unescape(document.cookie.substring(startpoint, endindex));
  }

function GetCookie (name) {
  var prefix = name + "=";
  var prefixlen = prefix.length;
  var strlen = document.cookie.length;
  var i = 0;
  while (i < strlen) {
    var j = i + prefixlen;
    if (document.cookie.substring(i, j) == prefix) return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
  return null;
  }

function showHTML () {
  var stx = document.getElementById("mainBody")
  document.write("<HTML><xmp>"+stx.innerHTML+"</xmp></HTML>")
  }

