
//This is an image preload script
var pix0 = new Array();
var pix1 = new Array();

for (var i=0; i<=2; i++){
pix0[i]="";
pix1[i]="";
}

function preloadButtonSet(num,dark,light) {
    if(document.images){
        pix0[num] = new Image();
        pix0[num].src = dark;
        pix1[num] = new Image();
        pix1[num].src = light;

    }
}

//Image preload script
var pix0 = new Array();
var pix1 = new Array();

for (var i=0; i<=2; i++){
pix0[i]="";
pix1[i]="";
}

function preloadButtonSet(num,dark,light) {
    if(document.images){
        pix0[num] = new Image();
        pix0[num].src = dark;
        pix1[num] = new Image();
        pix1[num].src = light;

    }
}

//Rollover functions

function over(num) {
 if (document.getElementById){
 	document.getElementById("button"+num).src = pix1[num].src;
  //eval("document.button"+num+".src = pix1["+num+"].src;");
  }
 return false;
}

function out(num) {
 if (document.getElementById){
 	document.getElementById("button"+num).src = pix0[num].src;	
  //eval("document.button"+num+".src = pix0["+num+"].src;");
  }
 return false;
}

//*************************
// Browser-independent method of getting an object
// borrowed from http://www.xs4all.nl/~ppk/js/
function getObj(name){
	if (document.getElementById)
		{
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
		}
		else if (document.all)
		{
			this.obj = document.all[name];
			this.style = document.all[name].style;
		}
		else if (document.layers)
		{
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
}

function AddressWindow(strUrl, obj)
{
	var strParameters = 'scrollbars=yes, ' + 
							'resizable=yes, ' +
							'width=420, ' +
							'height=400';

	doPopup('../addr/' + strUrl, 'contact', strParameters, obj); 
}


// Function to make Interrnet Explorer recognise hover
// on elements other than anchors

function startList(id) {

if (document.all&&document.getElementById) {
  navRoot = document.getElementById(id);
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="LI") {
      node.onmouseover=function() { this.className+=" over";}
      node.onmouseout=function() {this.className=this.className.replace(" over", "");}
   }
  }
 }
}


//Function to colour form input and textarea fields on focus
function FormColour() {
	if (document.getElementsByTagName) {
		navRoot = document.getElementsByTagName("INPUT");
		for (i=0; i<navRoot.length; i++) {
			node=navRoot[i];
			if (node.type =="text"){
				node.onfocus=function() { this.className="foc"; }
				node.onblur=function()  { this.className="blu"; }
			}
		}
		navRoot = document.getElementsByTagName("TEXTAREA");
		for (i=0; i<navRoot.length; i++) {
			node=navRoot[i];
				node.onfocus=function() { this.className="foc"; }
				node.onblur=function()  { this.className="blu"; }
			}
	}
}

//#########################
// Form validation routines
//#########################
//*************************
// Check that an input field is not blank
function FValidateControl(control){
  if ( control.value == " " ) {
    control.value = "";
  }
  if (control.value==""){
    alert(control.id+" must be filled in before your form can be sent.");
    control.focus();
    return false;
  }
  return true;
}
//*************************

//*************************
// Check that the email address is of the right form
// The email field must be called email
	function MailValidate(myForm){
		var re = /^\s?\w+([\.\-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/
		if (re.test(myForm.email.value))
		{
			return true
		}
		alert("Invalid form of email address.\n\nIf it appears correct, check for spaces.");
		myForm.email.focus();
		myForm.email.select();
		return false;
}
//*************************