// ************************************
// menu functions
// ************************************

function initialise() {
//  if (document.all) {					//Internet Explorer
//    thePageHead   = graphhead.style
//    thePlainMenu = menu0.style
//    showit = 'visible'
//    hideit = 'hidden'
//  }

//  if (document.layers) {				// Netscape 4
//    thePageHead  = document.layers['graphhead']
//    thePlainMenu = document.layers['menu0']
//    showit = 'visible'
//    hideit = 'hidden'
//  }

//  if (!document.all && document.getElementById) {	// Netscape 6+
//    thePageHead   = document.getElementById('graphhead').style
 //   thePlainMenu = document.getElementById('menu0').style
//    showit = 'visible'
//    hideit = 'hidden'
//  }
//  hidemenu();

  document.onmousedown=disablerclick
}

function disablerclick() {
  if (event.button==2) {
    alert("This image is copyright - right click is disabled");
    return false;
  }
}

function hidemenu() {
//  theLayer2.visibility = hideit;
}

  function showmenu(submenu) {
    hidemenu();
//    switch(submenu) {
//      case 2:
//          theLayer2.visibility = showit;
//        break;
//      case 3:
//          theLayer3.visibility = showit;
//        break;
//    }
  }

  function showclickable(imglink,imgnam) {
    eval ("document.images["+imglink+"].src = 'buttons/" + imgnam + "_click.gif'");
  }

  function shownormal(imglink,imgnam) {
    eval ("document.images["+imglink+"].src = 'buttons/" + imgnam + ".gif'");
  }

// ******************************
// Registration form verification
// ***********************************************
// Dedicated function rather than generalised as
// there are  only two forms used on the site and
// it makes the page code easier to read this way
// ***********************************************
//
// may not be used as coldfusion client side validation will be tried

function veriReg(fin) {

  var msg;
  var empty_field = "";
//
// the following regular expression (I've used it before) came from www.breakingpar.com/bkp/home.nsf/Doc?OpenNavigator&U=87256B280015193F87256C40004CC8C6
//
  var valid_eml_fmt = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
//
// and these I created 
//
  var valid_name_fmt = /^[a-zA-Z][a-zA-Z]{1,19}$/
  var founderr = false;

  msg = "Your Registration form was not submitted because of the following error(s).\n";
  msg += "Please correct these error(s) and re-submit.\n";

  if (!valid_name_fmt.test(fin.usenam.value)) {
    founderr = true;
    msg += " invalid username " + fin.usenam.value + "\n";
  }

  if (!valid_eml_fmt.test(fin.emladr.value)) {
    founderr = true;
    msg += " invalid email address " + fin.emladr.value + "\n";
  }

  if (founderr) {
    alert(msg);
    return false;
  } else {
    return true;
  }

}

function veriFormThree(fin) {

  var msg;
  var empty_field = "";
  var founderr = false;
//
// the following regular expression (I've used it before) came from www.breakingpar.com/bkp/home.nsf/Doc?OpenNavigator&U=87256B280015193F87256C40004CC8C6
//
  var valid_eml_fmt = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

  msg = "The form could not be processed because of the following.\n";
  msg += "Please correct the entries and re-submit.\n\n";

  if (fin.name.value == "") {
    founderr = true;
    msg += "Please fill in your name.\n";
  }
  if (!valid_eml_fmt.test(fin.email.value)) {
    founderr = true;
    msg += "Invalid email address " + fin.email.value + "\n";
  }

  if (fin.body.value == "") {
    founderr = true;
    msg += "You did not enter a question.\n";
  }

  if (founderr) {
    alert(msg);
    return false;
  } else {
    return true;
  }

}

