function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1

if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
      EmailOk = false
   }
return EmailOk
}

function TrainingEnquiryForm()
{
	var formOK = true;
	var strError = '';
	if ((document.manualEnquiry.strFirstName.value=="") && (document.manualEnquiry.strLastName.value==""))
	{
		formOK = false;
		strError = strError + 'Please enter your name\r';
	}
	
	if (document.manualEnquiry.strTel.value=="")
	{
		formOK = false;
		strError = strError + 'Please enter your telephone number\r';
	}
	
	if (document.manualEnquiry.strEmail.value=="")
	{
		formOK = false;
		strError = strError + 'Please enter your email address\r';
	}
	else
	{
		if (IsEmailValid("manualEnquiry","strEmail")==false)
			{
			formOK = false;
			strError = strError + 'Please enter a valid email address\r';
			}
	}

	if ( (document.manualEnquiry.strAddress1.value=="") && (document.manualEnquiry.strTown.value=="") && (document.manualEnquiry.strPostcode.value=="") )
	{
		formOK = false;
		strError = strError + 'Please enter your full address\r';
	}
	
	if (document.manualEnquiry.strEnquiry.value=="")
	{
		formOK = false;
		strError = strError + 'Please enter your enquiry\r';
	}
	
	if (formOK == false)
	{
		alert('The form is not complete:\r\r' + strError);
		return false;
	}
	
	document.manualEnquiry.submit();
	return true;
}


function TrainingOrderForm() 
{
	var formOK  = true; 
	var strError = '';
	
	if ((document.manualorder.strFirstName.value=="") &&  (document.manualorder.strLastName.value==""))
		{
		formOK = false;
		strError = strError + 'Please enter your name\r';
		}
	if (document.manualorder.strEmailAddress.value=="")
		{
		formOK = false;
		strError = strError + 'Please enter your email address\r';
		}
	else
		{
		if (IsEmailValid("manualorder","strEmailAddress")==false)
			{	
			formOK = false;
			strError = strError + 'Please enter a valid email address\r';
			}
		}
			
	if ((document.manualorder.strAddress1.value=="") || (document.manualorder.strTown.value=="") || (document.manualorder.strPostcode.value==""))
		{
		formOK = false;
		strError = strError + 'Please enter your full address\r';
		}
	
	if (formOK == false)
		{
		alert('The form is not complete:\r\r' + strError);
		return false;
		}
		document.manualorder.submit();
		return true;
}


function DonateNowForm() 
{
	var formOK  = true; 
	var strError = '';
	/*for (counter=0;counter<document.donatenow.OPtAmount.length;counter++) {
	alert(counter + ' ' + document.donatenow.OPtAmount[counter].checked);
	}*/
	if (document.donatenow.OPtAmount[4].checked==true) {
		if (document.donatenow.strDonation.value=="")
			{
			formOK = false;
			strError = strError + 'Please enter the amount you would like to donate\r';
			}
	}
	//N.B. Need to extend this so they can only enter numeric amounts.
	
	if ((document.donatenow.strFirstName.value=="") &&  (document.donatenow.strLastName.value==""))
		{
		formOK = false;
		strError = strError + 'Please enter your name\r';
		}
	if (document.donatenow.strEmailAddress.value=="")
		{
		formOK = false;
		strError = strError + 'Please enter your email address\r';
		}
	else
		{
		if (IsEmailValid("donatenow","strEmailAddress")==false)
			{	
			formOK = false;
			strError = strError + 'Please enter a valid email address\r';
			}
		}
			
	if ((document.donatenow.strAddress1.value=="") || (document.donatenow.strTown.value=="") || (document.donatenow.strPostcode.value==""))
		{
		formOK = false;
		strError = strError + 'Please enter your full address\r';
		}
	
	if (formOK == false)
		{
		alert('The form is not complete:\r\r' + strError);
		return false;
		}
		document.donatenow.submit();
		return true;
}



function VolunteerForm(intFieldCount) 
{
	var formOK  = true; 
	var strError = '';
	
	if ((document.Volunteer.strFirstName.value=="") &&  (document.Volunteer.strLastName.value==""))
		{
		formOK = false;
		strError = strError + 'Please enter your name\n';
		}
	if (document.Volunteer.strEmailAddress.value=="")
		{
		formOK = false;
		strError = strError + 'Please enter your email address\n';
		}
	else
		{
		if (IsEmailValid("Volunteer","strEmailAddress")==false)
			{	
			formOK = false;
			strError = strError + 'Please enter a valid email address\n';
			}
		}
	
	var SelectedType = false;
	if(document.Volunteer.strVT.length) {
		alert('defined');
		for (var i = 0;   i <= document.Volunteer.strVT.length;   i++) {
			if (document.Volunteer.strVT[i]) {
				if (document.Volunteer.strVT[i].checked==true) {
					SelectedType = true;
				}
			}
		}
	} else {
		if (document.Volunteer.strVT.checked==true) {
			SelectedType = true;
		}
	}
	
	if (SelectedType == false)
	{
			formOK = false;
			strError = strError + 'Please indicate which type of volunteering you are interested in\n';
	}
	
	if ((document.Volunteer.strAddress1.value=="") || (document.Volunteer.strTown.value=="") || (document.Volunteer.strPostcode.value==""))
		{
		formOK = false;
		strError = strError + 'Please enter your full address\n';
		}
	
	if (formOK == false)
		{
		alert('The form is not complete:\n\n' + strError);
		return false;
		}
		document.Volunteer.submit();
		return true;
}


function ContactUs() 
{
	var formOK  = true; 
	var strError = '';
	
	if (document.contact.name.value=="")
		{
		formOK = false;
		strError = strError + 'Please enter your name\r';
		}
	if (document.contact.email.value=="")
		{
		formOK = false;
		strError = strError + 'Please enter your email address\r';
		}
	else
		{
		if (IsEmailValid("contact","email")==false)
			{	
			formOK = false;
			strError = strError + 'Please enter a valid email address\r';
			}
		}
	if (document.contact.subject.selectedIndex==0)
		{
		formOK = false;
		strError = strError + 'Please choose a subject for your message\r';
		}
	if (document.contact.comments.value=="")
		{
		formOK = false;
		strError = strError + 'Please enter your message\r';
		}
	
	if (formOK == false)
		{
		alert('The form is not complete:\r\r' + strError);
		return false;
		}
		document.contact.submit();
		return true;
}



function OpenNewWindow(val) {	window.open(val,'Detail','width=550,height=500,top=20,left=20,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes'); }

function OpenNewBrowser(val) {	window.open(val,'NewWin','width=675,height=400,top=20,left=20,toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes'); }// Name: Cookie
// Language: JavaScript
// Author: Travis Beckham | squidfingers.com
// Description: Remove anchor outlines from all links in the document
// --------------------------------------------------

function blurAnchors(){
  if(document.getElementsByTagName){
    var a = document.getElementsByTagName("a");
    for(var i = 0; i < a.length; i++){
      a[i].onfocus = function(){this.blur()};
    }
  }
}
window.onload = blurAnchors;


//backgrounds = new Array();     
//backgrounds[0]="/images/backs/mm-shadow.jpg"     
//backgrounds[1]="/images/images2006/nav/bg.gif"     
//backgrounds[2]="/images/images2006/nav/arrowblue.gif"
//backgrounds[3]="/images/images2006/nav/arrowgrey.gif"

