

// ############## EMAIL VALIDATION FUNCTIONS ############## //
// These functions check the validity of the email sent in the 'contact us' page
function validateEmail(objForm) {
	
	var strEmail = objForm.txtEmailAddress;
	var error=0;
	var set_focus = false;
	var error_details = "\n";

function checkEmail(strEmail) {
	var result = false;
	var strEmailAddress = new String(strEmail);
	var atIndex = strEmailAddress.indexOf("@");
	if (atIndex > 0) {
		var dotIndex = strEmailAddress.indexOf(".",atIndex);
		if ((dotIndex > atIndex + 1) && (strEmailAddress.length > dotIndex + 1)) {
			result = true;
		}
	}
	return result;
}

	if (objForm.selattention.value == "blank") {
		error++;
		error_details = error_details + "Please enter a value for the \"For the attention of\" field.\n";
		//return false;		
	}	
	if (objForm.txtName.value == "") {
		error++;
		set_focus = true
		objForm.txtName.focus();
		error_details = error_details + "Please enter a value for the \"Your name\" field.\n";
		//return false;
	}

	if (strEmail.value == "") {
		error++;
		if (set_focus == false) {
			set_focus = true;
			strEmail.focus();
		}
		error_details = error_details + "Please enter a value for the \"Your email address\" field.\n";
		//return false;
	}
	if (!checkEmail(strEmail.value)) {
		error++;	
		if (set_focus == false) {
			set_focus = true;
			strEmail.focus();
		}
		set_focus == false
		if (!strEmail.value == "") {
			error_details = error_details + "Please enter a complete email address in the form: you@domain.com\n";
		}
		//return false;
	}
	if (strEmail.length < 3) {
		error++;
		if (set_focus == false) {
			set_focus = true;
			strEmail.focus();
		}
		set_focus == false
		error_details = error_details + "Please enter at least 3 characters in the \"Your email address\" field.\n";
		//return (false);
	}

	if (objForm.txtfeedback.value == "") {
		error++;
		if (set_focus == false) {
			set_focus = true;
			objForm.txtfeedback.focus();
		}
		error_details = error_details + "Please enter a value for the \"Your feedback\" field.\n";
		//return false;		
	}
	
	if (error != 0) 
	{
		alert(error_details);
		return false;
	}
	else 
	{
		return true;
	}
}


// ############## POP-UP WINDOW FUNCTION ############## //
function launch(strURL, strName, parentName) {
	var remote = open(strURL, strName, "location=0,status,scrollbars,resizable,width=800");
	if (remote.opener == null)
		remote.opener = window;
	remote.focus();
	remote.opener.name = parentName;
	return remote;
}

function openWindow(strURL) {
	docWindow = launch(strURL, "docWindow","winOpener");
}



