<!--

browserOK = true;
pics = new Array();

var objCount = 0; // number of (changing) images on web-page
var submitCount = 0; // number of times form has been submitted

function preload(name, first, second) {

  // preload images and place them in an array

  if (browserOK) {
    pics[objCount] = new Array(3);
    pics[objCount][0] = new Image();
    pics[objCount][0].src = first;
    pics[objCount][1] = new Image();
    pics[objCount][1].src = second;
    pics[objCount][2] = name;
    objCount++;
  }
}

function on(name){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) {
          // set back all other pictures
          if (pics[i][0].complete)
            document.images[pics[i][2]].src = pics[i][0].src;
        } else {
            // show the second image because cursor moves across this image
            if (pics[i][1].complete)
              document.images[pics[i][2]].src = pics[i][1].src;
        }
    }
  }
}

function off(){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      // set back all pictures
      if (document.images[pics[i][2]] != null)
        if (pics[i][0].complete)
            document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}

preload("nav1", "images/nav1.jpg", "images/nav1_f2.jpg");
preload("nav2", "images/nav2.jpg", "images/nav2_f2.jpg");
preload("nav4", "images/nav4.jpg", "images/nav4_f2.jpg");
preload("nav5", "images/nav5.jpg", "images/nav5_f2.jpg");
preload("nav6", "images/nav6.jpg", "images/nav6_f2.jpg");
preload("nav7", "images/nav7.jpg", "images/nav7_f2.jpg");
preload("nav8", "images/nav8.jpg", "images/nav8_f2.jpg");
preload("nav9", "images/nav9.jpg", "images/nav9_f2.jpg");
preload("nav11", "images/nav11.jpg", "images/nav11_f2.jpg");



//-->


/************* Form Validation ***************/

function validatefield(thisfield,imgname){
  if (thisfield.value == "") {
  imgname.src="images/stop.gif";
  }
  else
  {
  imgname.src="images/blank.gif";
  }
}

function validate_email(theControl)
{

    if ( theControl.value == "" || theControl.value.length <= 0 )
    {

   alert("I'm sorry. This email address must be filled in correct to send the form to our server. Please"
   +" check the prefix and '@' sign.");
   theControl.focus()
        return false;
    }

    var reEmail = /^.+\@.+\..+$/
    var holderValue;
    var thisValue = theControl.value;

    // Check for e-mail addresses from ISPs and other sources that have been consistently
    // entered incorrectly.  If detected, correct the situation.
    if
        (
            (thisValue.substring(thisValue.length - 4, thisValue.length).toLowerCase()) == '@aol' ||
            (thisValue.substring(thisValue.length - 4, thisValue.length).toLowerCase()) == '@msn' ||
            (thisValue.substring(thisValue.length - 6, thisValue.length).toLowerCase()) == '@yahoo' ||
            (thisValue.substring(thisValue.length - 6, thisValue.length).toLowerCase()) == '@lycos' ||
            (thisValue.substring(thisValue.length - 7, thisValue.length).toLowerCase()) == '@excite' ||
            (thisValue.substring(thisValue.length - 10, thisValue.length).toLowerCase()) == '@altavista' ||
            (thisValue.substring(thisValue.length - 11, thisValue.length).toLowerCase()) == '@compuserve' ||
            (thisValue.substring(thisValue.length - 8, thisValue.length).toLowerCase()) == '@prodigy' ||
            (thisValue.substring(thisValue.length - 8, thisValue.length).toLowerCase()) == '@hotmail' ||
            (thisValue.substring(thisValue.length - 9, thisValue.length).toLowerCase()) == '@netscape'
        )
        {
            holderValue = thisValue.concat('.com');
            thisValue = holderValue;
            theControl.value = thisValue;
        }
    if
        (
            (thisValue.substring(thisValue.length - 5, thisValue.length).toLowerCase()) == '@home'
        )
        {
            holderValue = thisValue.concat('.net');
            thisValue = holderValue;
            theControl.value = thisValue;
        }

    // Now check the actual value of the e-mail address for validity.
    var flagFirstCheck = (theControl.value.length < 6) ||
        (thisValue.indexOf('@') == -1) ||
        (thisValue.indexOf('.') == -1) ||
        (thisValue.indexOf('@',(thisValue.indexOf('@')+1)) != -1) ||
        ((thisValue.indexOf('.')+1) == thisValue.length) ||
        ((thisValue.indexOf('@')+1) == thisValue.length)
    var flagSecondCheck = reEmail.test(thisValue)
    if ( flagFirstCheck || !flagSecondCheck)
    {

   alert("I'm sorry. This email address seems to be incorrect. Please"
   +" check the prefix and '@' sign.");
   theControl.focus()

        return false;
    }
    else {

        return true;
    }
}

function FEmptyControl(control, prompt) {
  if (control.value=="") {
    alert("The " + prompt +" field is a required field, and it must be filled in before your form can be sent to our server.")
    control.focus()
    return false }
  return true }

function check_search_form(form) {
if (!FEmptyControl(form.keywords,'Enter some keywords for search please??')) return false
   return true }

function check_contact_form(form) {
if (!validate_email(form.email)) return false
if (!FEmptyControl(form.recipient,'Email Recipient')) return false
if (!FEmptyControl(form.name,'Name')) return false
if (!FEmptyControl(form.address,'Address')) return false
if (!FEmptyControl(form.city,'City')) return false
if (!FEmptyControl(form.state,'State')) return false
if (!FEmptyControl(form.zip,'Zip')) return false

   if (submitCount == 0)
      {
      submitCount++;
      return true;
      }
   else
      {
      alert("This form has already been submitted.");
      return false;
      }

   }

/************* End Form Validation ***************/

/*
  Expandable Listmenu Script
  Author : Thomas Bakketun
  http://www.bakketun.net/listmenu/

  Based on script by:
  Author : Daniel Nolan
  http://www.bleedingego.co.uk/webdev.php

  $Id: listmenu.js,v 1.3 2004/11/12 02:58:23 thomasb Exp $
*/


function elementHasClass( element, className ) {
  if ( ! element.className ) {
    return false;
  }
  var re = new RegExp( "(^|\\s+)" + className + "($|\\s+)" );
  return re.exec( element.className );
}

function initMenus() {
  if ( ! document.getElementsByTagName ) {
    return;
  }
  var singleopen, keepopen
  var menus = document.getElementsByTagName( "ul" );
  for ( var i = 0; i < menus.length; i++ ) {
    if ( elementHasClass( menus[ i ], "treemenu" ) ) {
      initMenu( menus[ i ],
        elementHasClass( menus[ i ], "singleopen" ),
        elementHasClass( menus[ i ], "keepopen" )
      );
    }
  }
}

function getChildNodes( element, tag ) {
  var foundNodes = new Array();
  var childNodes = element.childNodes;
  for (var i = 0; i < childNodes.length; i++ ) {
    var node = childNodes[ i ];
    //FIXME: should only do convert to lowercase when i HTML-mode
    if ( node.tagName && ( node.tagName.toLowerCase() == tag ) ) {
      foundNodes.push( node );
    }
  }
  return foundNodes;
}

function createA(menu) {
  var a, text;
  text = menu.firstChild;
  a = document.createElement("a");
  a.href = "#";
  menu.replaceChild(a, text);
  a.appendChild(text);
  return a;
}

function initMenu(menu, singleopen, keepopen) {
  var item, a, open;
  var items = getChildNodes(menu, "li");
  open = false;
  for (var i = 0; i<items.length; i++) {
    item = items[i];
    a = getChildNodes(item, "a")[0];
    var submenu = getChildNodes(item, "ol")[0];
    if (submenu) {
      if (!a) {
        a = createA(item);
      }
      open = initMenu(submenu, singleopen, keepopen) || open;
      a.onclick = function() { return menuonclick(this, singleopen); }
    } else {
      if (a) open = open || (keepopen && a.href == window.location);
    }
    if (item.className == "treenodeopen") setMenu(item, true);
    open = open || item.className == "treenodeshow";
  }
  setMenu(menu.parentNode, open);
  return open;
}

function menuonclick(a, singleopen) {
  setMenu(a.parentNode, a.className == "treeclosed");
  var menus = getChildNodes(a.parentNode.parentNode, "li");
  if (singleopen) {
    for (var i = 0; i<menus.length; i++) {
      if (menus[i] != a.parentNode) {
        setMenu(menus[i], false);
      }
    }
  }
  return false;
}

function setMenu(menu, open) {
  var a = getChildNodes(menu, "a")[0];
  var ul = getChildNodes(menu, "ol")[0];
  if (a && ul) {
    if (open) {
      a.className = "treeopen";
      ul.style.display = "block";
    } else {
      a.className = "treeclosed";
      ul.style.display = "none";
    }
  }
}

function changemenu(id, newClass) {
identity=document.getElementById(id);
identity.className=newClass;
}

// if(document.createElement) window.onload = initMenus();
// initMenus();