function menubar_hover(which)
{
  try {
    document.getElementById(which.id).className = "menubar_selectable_hover";
  } catch(e) {
  }
}


function menubar_hover_exit(which)
{
  try {
    document.getElementById(which.id).className = "menubar_selectable";
  } catch(e) {
  }
}

function quickfacts_hover(which)
{
  try {
    which.className = "quickfactstd_hover";
  } catch(e) {
  }
}


function quickfacts_hover_exit(which)
{
  try {
    which.className = "quickfactstd";
  } catch(e) {
  }
}

function goto(where)
{
  window.location.href = where;
}


function menubar_click(which)
{
  if (which.id == "td_home") {
    window.location.href="index.html";
  } else if (which.id == "td_reservations") {
    window.location.href="reservations.html";
  } else if (which.id == "td_roomsandrates") {
    window.location.href="rooms.html";
  } else if (which.id == "td_drivingdirections") {
    window.location.href="directions.html";
  } else if (which.id == "td_amenities") {
    window.location.href="amenities.html";
  } else if (which.id == "td_reunionsandgroupbookings") {
    window.location.href="reunions.html";
  } else if (which.id == "td_areaattractionsandevents") {
    window.location.href="attractions.html";
  } else if (which.id == "td_guestcomments") {
    window.location.href="testimonials.html";
  } else if (which.id == "td_photoalbum") {
    window.location.href="photos.html";
  } else if (which.id == "td_aboutus") {
    window.location.href="aboutus.html";
  } else if (which.id == "td_grillyourownsteakdinner") {
    window.location.href="steakdinner.html";
  }
}

function email_focus(which)
{
  if (which.value == "enter your email") {
    which.value = "";
  } else {
    // email_check(which);
  }
}

function email_blur(which)
{
  if (which.value == "") {
    which.value = "enter your email";
  } else {
    email_check(which);
  }
}

function email_check(which) 
{
  if (confirmEmailAddress(which.value)) {
    document.getElementById("email_submitbutton").disabled = true;
  } else {
    document.getElementById("email_submitbutton").disabled = false;
  }
}


function confirmEmailAddress(emailStr) 
{
  var errorCode = 0;

  var checkTLD=1;
  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
  var emailPat=/^(.+)@(.+)$/;
  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
  var validChars="\[^\\s" + specialChars + "\]";
  var quotedUser="(\"[^\"]*\")";
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
  var atom=validChars + '+';
  var word="(" + atom + "|" + quotedUser + ")";
  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

  /* Finally, let's start trying to figure out if the supplied address is valid. */

  /* Begin with the coarse pattern to simply break up user@domain into
  different pieces that are easy to analyze. */

  var matchArray = emailStr.match(emailPat);

  if (matchArray == null) {
    /* Too many/few @'s or something; basically, this address doesn't 
    even fit the general mould of a valid e-mail address. */
    errorCode += 1; 
    //alert("Email address seems incorrect (check @ and .'s)");
  } else {
    var user = matchArray[1];
    var domain=matchArray[2];

    // Start by checking that only basic ASCII characters are in the strings (0-127).

    for (i=0; i<user.length; i++) {
      if (user.charCodeAt(i)>127) {
        errorCode += 2;
        //alert("Ths username contains invalid characters.");
      }
    }

    for (i=0; i<domain.length; i++) {
      if (domain.charCodeAt(i)>127) {
        errorCode += 4;
        //alert("Ths domain name contains invalid characters.");
      }
    }

    // See if "user" is valid 

    if (user.match(userPat)==null) {
      // user is not valid
      errorCode += 8;
      //alert("The username doesn't seem to be valid.");
    }

    // Check for valid Domain name

    var atomPat=new RegExp("^" + atom + "$");
    var domArr=domain.split(".");
    var len=domArr.length;
    for (i=0;i<len;i++) {
      if (domArr[i].search(atomPat)==-1) {
        errorCode += 16;
        //alert("The domain name does not seem to be valid.");
      }
    }

    /* domain name seems valid, but now make sure that it ends in a
    known top-level domain (like com, edu, gov) or a two-letter word,
    representing country (uk, nl), and that there's a hostname preceding 
    the domain or country. */

    if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
      errorCode += 32;
      //alert("The address must end in a well-known domain or two letter " + "country.");
    }

    // Make sure there's a host name preceding the domain.

    if (len<2) {
      errorCode += 64;
      //alert("This address is missing a hostname!");
    }
  }
  
  return errorCode;
}


function emailsignup()
{
  document.getElementById("emailalertform").submit();
}


function movebackground()
{
  var ScrollTop = document.body.scrollTop;
  if (ScrollTop == 0) {
    if (window.pageYOffset) {
      ScrollTop = window.pageYOffset;
    } else {
      ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
  }

  var backgroundheight = document.getElementById("background").style.height;
  var maxTop = document.body.clientHeight - backgroundheight;
  if (ScrollTop > maxTop) ScrollTop = maxTop;
  //alert(ScrollTop + ":" + maxTop + ":" + backgroundheight );

  document.getElementById("background").style.top = ScrollTop;
}


function getURLParameter(myParameterName) 
{
  try {
    var sURL = window.location.search.substring(1);

    if (sURL != "") {
      var arrURLParams = sURL.split("&");

      var arrParamNames = new Array(arrURLParams.length);
      var arrParamValues = new Array(arrURLParams.length);

      var i = 0;
      for (i=0; i < arrURLParams.length; i++) {
        var sParam =  arrURLParams[i].split("=");
        arrParamNames[i] = sParam[0];
        if (sParam[1] != "")
          arrParamValues[i] = unescape(sParam[1]);
        else
          arrParamValues[i] = "";
      }

      for (i=0; i < arrURLParams.length; i++) {
        if (arrParamNames[i] == myParameterName) {
          var returnvalue = arrParamValues[i];
          if (returnvalue == "true") returnvalue = true;
          if (returnvalue == "false") returnvalue = false;
          if (typeof(returnvalue) == "undefined") returnvalue = "";
          return returnvalue;
        }
      }
      return "";
    } else {
      return "";
    }
  } catch(e) {
  }
}


