// klarejs11.js    14 jan 08  javascript for buttons, sliding, and scrolling
// klaremain.js    15 jan 08  for main pages (no roundels, no sliding, but keep email funcs (small))
//                 22 jan 08  change reg exp in validEmail, to allow leading and trailing spaces


if (document.images){  

	//precache images
	var offImgArray = new Array();
	offImgArray["button1"] = new Image (46,21);
	offImgArray["button2"] = new Image (138,21);
	offImgArray["button3"] = new Image (182,21);
	offImgArray["button4"] = new Image (109,21);
	offImgArray["button5"] = new Image (76,21);
	offImgArray["button1"].src = "img2/buttons/bhome_up.gif";
	offImgArray["button2"].src = "img2/buttons/bartist_up.gif";
	offImgArray["button3"].src = "img2/buttons/bcommunity_up.gif";
	offImgArray["button4"].src = "img2/buttons/bcommissions_up.gif";
	offImgArray["button5"].src = "img2/buttons/bcontact_up.gif"; 
	offImgArray["email"] = new Image (205,20);
	offImgArray["email"].src = "img2/buttons/email_up.gif";
	offImgArray["sendbutton"] = new Image (54,28);
	offImgArray["sendbutton"].src = "img2/buttons/bsend_up.gif";
	
	
	var overImgArray = new Array();
	overImgArray["button1"] = new Image (46,21);
	overImgArray["button2"] = new Image (138,21);
	overImgArray["button3"] = new Image (182,21);
	overImgArray["button4"] = new Image (109,21);
	overImgArray["button5"] = new Image (76,21);
	overImgArray["button1"].src = "img2/buttons/bhome_over.gif";
	overImgArray["button2"].src = "img2/buttons/bartist_over.gif";
	overImgArray["button3"].src = "img2/buttons/bcommunity_over.gif";
	overImgArray["button4"].src = "img2/buttons/bcommissions_over.gif";
	overImgArray["button5"].src = "img2/buttons/bcontact_over.gif"; 
	overImgArray["email"] = new Image (205,20);
	overImgArray["email"].src = "img2/buttons/email_over.gif";
	overImgArray["sendbutton"] = new Image (54,28);
	overImgArray["sendbutton"].src = "img2/buttons/bsend_over.gif";
		
	var downImgArray = new Array();
	downImgArray["button1"] = new Image (46,21);
	downImgArray["button2"] = new Image (138,21);
	downImgArray["button3"] = new Image (182,21);
	downImgArray["button4"] = new Image (109,21);
	downImgArray["button5"] = new Image (76,21);
	downImgArray["button1"].src = "img2/buttons/bhome_down.gif";
	downImgArray["button2"].src = "img2/buttons/bartist_down.gif";
	downImgArray["button3"].src = "img2/buttons/bcommunity_down.gif";
	downImgArray["button4"].src = "img2/buttons/bcommissions_down.gif";
	downImgArray["button5"].src = "img2/buttons/bcontact_down.gif";  
	downImgArray["email"] = new Image (205,20);
	downImgArray["email"].src = "img2/buttons/email_over.gif";
	downImgArray["sendbutton"] = new Image (54,28);
	downImgArray["sendbutton"].src = "img2/buttons/bsend_down.gif";
		
}

/* functions for Main (top) buttons */
function mOver (imgName) {   // highlight when mouse over (except if current page), and hide Focus
	document.images[imgName].src = overImgArray[imgName].src;
	document.images[imgName].parentNode.hideFocus = true;
	window.status = " ";
	return true;
	
}
	
function mOut (imgName) {    // revert to normal when mouse out 
	document.images[imgName].src = offImgArray[imgName].src;
	document.images[imgName].parentNode.hideFocus = true;
	window.status = "";
	return true;
}

function mDown (imgName) {   // highlight   - then page changes anyway
	document.images[imgName].src = downImgArray[imgName].src;
	document.images[imgName].parentNode.hideFocus = true;
	window.status = " ";
	return true;
}


// email functions, validate, send etc (uses Matt Wright's formmail.pl, cos you have to (?) on 123-reg.co.uk)
// reg exp from Javascript Visual Quickstart manual (plus added leading/trailing spaces allowed)

reg = /^\s*\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+\s*$/

function selectNameField(myForm) {
	myForm.Name.focus()
	myForm.Name.select()
	return false
}

function validEmail(myForm) {
	if (reg.test(myForm.email.value)) {
		return true
	}
	alert("Invalid email address")
	myForm.email.focus()
	myForm.email.select()
	return false
}

function sendEmail (myform) {
	if (validEmail(myform)) {
		myform.action = "formmail/formmail.pl";
		myform.submit();
		//document.getElementById("shorttextdiv").style.visibility = "visible";
		return true;
	}
}


