// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function checkenquiry(){
	var ftxt = '';

	if (document.ContactUs.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.ContactUs.School.value==''){
		ftxt += '\n- Please enter your School.';
	}
		
	if (document.ContactUs.Message.value==''){
		ftxt += '\n- Please enter your Message.';
	}
	
	if (isValidEmail(document.ContactUs.email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.ContactUs.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (document.ContactUs.subject.value==''){
		ftxt += '\n- Please select an enquiry Subject.';
	}
	
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

$(document).ready(function() {
		  var randomImages = ['shellBackgroundThree.jpg','shellBackgroundTwo.jpg','shellBackgroundOne.jpg'];
		  var rndNum = Math.floor(Math.random() * randomImages.length);
		  $("#home").css({ background: "url(Images/" + randomImages[rndNum] + ") no-repeat top center" });
})


function checknewsletterform(){
	if (isValidEmail(document.newsletterform.email.value)==false){
		alert('Please enter your Email Address.');
		return false;
	}
	else {
		return true;
	}
}

function clearemailfield(fieldVal){
	if (isValidEmail(fieldVal)==false){
		document.newsletterform.email.value='';
	}
}

/* Replacement calls. Please see documentation for more information. */
if(typeof sIFR == "function"){	
	// This is the older, ordered syntax	
	sIFR.replaceElement("h2", named({sFlashSrc: "Scripts/Square721.swf", sColor: "#4D6996"}));	
	sIFR.replaceElement("h3", named({sFlashSrc: "Scripts/Square721.swf", sColor: "#FFFFFF", sWmode: "transparent"}));
};
