// Form Functions
function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function checkenquiry(){
	var ftxt = "";
	
	if (document.enquiry.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.enquiry.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.enquiry.email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.enquiry.subject.value==''){
		ftxt += '\n- Please select the Subject of this email.';
	}
	
	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;
	}
}

// Random Images
function showImage(){
	var theImages = new Array() // do not change this

	theImages[0] = 'Images/Header_Photo1.jpg'
	theImages[1] = 'Images/Header_Photo2.jpg'
	theImages[2] = 'Images/Header_Photo3.jpg'

	var j = 0
	var p = theImages.length;
	var preBuffer = new Array()
	
	for (i = 0; i < p; i++){
		preBuffer[i] = new Image()
		preBuffer[i].src = theImages[i]
	}
	var whichImage = Math.round(Math.random()*(p-1));
	
	document.write('<img src="'+theImages[whichImage]+'">');
}