<!--

function ValidateSubscribeNews(frm) {
	if (Trim(frm.txtEmail.value)=="") {alert("Please enter your email address.");frm.txtEmail.focus();return false;}
	else if (!ValidateEmail(Trim(frm.txtEmail.value))) {alert("Please enter a valid email address.");frm.txtEmail.focus();return false;}
	else return true;
}

function ValidateLoginMember(frm){
	if (Trim(frm.txtUser.value)=="") {alert("Please enter your Member Username.");frm.txtUser.focus();return false;}
	else if (Trim(frm.txtPass.value)=="") {alert("Please enter your Member Password.");frm.txtPass.focus();return false;}
	else return true;
}

function ValidateSubmitEvent(frm){
	if (Trim(frm.txtTitle.value)=="") {alert("Title is required.");frm.txtTitle.focus();return false}
	else if (Trim(frm.txtDescr.value)=="") {alert("Description is required.");frm.txtDescr.focus();return false}
	
	else if (Trim(frm.txtSDate.value)=="") {alert("Start Date is required.");frm.txtSDate.focus();return false}
	else if (!ValidateDateDMY(Trim(frm.txtSDate.value))) {alert("Start Date must be in dd/mm/yyyy format.");frm.txtSDate.focus();return false}
	else if (Trim(frm.txtSTime.value)=="") {alert("Start Time is required.");frm.txtSTime.focus();return false}
	else if (!ValidateTimeHM(Trim(frm.txtSTime.value))) {alert("Start Time must be in hh:mm format.");frm.txtSTime.focus();return false}
	
	else if (Trim(frm.txtEDate.value)=="") {alert("End Date is required.");frm.txtEDate.focus();return false}
	else if (!ValidateDateDMY(Trim(frm.txtEDate.value))) {alert("End Date must be in dd/mm/yyyy format.");frm.txtEDate.focus();return false}
	else if (Trim(frm.txtETime.value)=="") {alert("End Time is required.");frm.txtETime.focus();return false}
	else if (!ValidateTimeHM(Trim(frm.txtETime.value))) {alert("End Time must be in hh:mm format.");frm.txtETime.focus();return false}
	
	else if (Trim(frm.txtConName.value)=="") {alert("Contact Name is required.");frm.txtConName.focus();return false}
	else if (Trim(frm.txtConEmail.value)=="") {alert("Contact Email Address is required.");frm.txtConEmail.focus();return false}
	else if (!ValidateEmail(Trim(frm.txtConEmail.value))) {alert("Please enter a valid email address.");frm.txtConEmail.focus();return false}
	
	else return true;
}

// Trims the leading and trailing blanks from a given string:
function Trim(strToTrim) {
	while(strToTrim.charAt(0)==' '){strToTrim = strToTrim.substring(1,strToTrim.length);}
	while(strToTrim.charAt(strToTrim.length-1)==' '){strToTrim = strToTrim.substring(0,strToTrim.length-1);}
	return strToTrim;
}

// Validate an e-mail address:
function ValidateEmail(str){
	if (str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
	else return false; 
}

// Validate date in "mm/dd/yyyy", "m/d/yyyy" format:
function ValidateDateMDY(str){
	if (str.search(/((^(10|12|0?[13578])([/])(3[01]|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(11|0?[469])([/])(30|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(2[0-8]|1[0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(29)([/])([2468][048]00)$)|(^(0?2)([/])(29)([/])([3579][26]00)$)|(^(0?2)([/])(29)([/])([1][89][0][48])$)|(^(0?2)([/])(29)([/])([2-9][0-9][0][48])$)|(^(0?2)([/])(29)([/])([1][89][2468][048])$)|(^(0?2)([/])(29)([/])([2-9][0-9][2468][048])$)|(^(0?2)([/])(29)([/])([1][89][13579][26])$)|(^(0?2)([/])(29)([/])([2-9][0-9][13579][26])$))/) != -1) return true;
	else return false; 
}

// Validate date in "dd/mm/yyyy", "d/m/yyyy" format:
function ValidateDateDMY(str){
	if (str.search(/^(?:(?:(?:0?[1-9]|1\d|2[0-8])\/(?:0?[1-9]|1[0-2]))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:(?:(?:31\/0?[13578]|1[02])|(?:(?:29|30)\/(?:0?[1,3-9]|1[0-2])))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:29\/0?2\/(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26]))))$/) != -1) return true;
	else return false; 
}

// Validate time in "hh:mm:ss" format:
function ValidateTimeHMS(str){
	if (str.search(/^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$|^([01]\d|2[0-3])/) != -1) return true;
	else return false; 
}

// Validate time in "hh:mm" format:
function ValidateTimeHM(str){
	if (str.search(/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/) != -1) return true;
	else return false; 
}

// Allows only letters, numbers and underscore:
function ChkIllegalChars(str){
	var illegalChars = /\W/;
	if (illegalChars.test(str)) return false;
	else return true;
}

function ValidateEnquiryForm(frm) {
	if (Trim(frm.txtName.value)=="") {alert("Name is required.");frm.txtName.focus();return false}
	else if (Trim(frm.txtEmail.value)=="") {alert("Email is required.");frm.txtEmail.focus();return false}
	else if (!ValidateEmail(Trim(frm.txtEmail.value))) {alert("Please enter a valid email address.");frm.txtEmail.focus();return false}
	else if (Trim(frm.txtEnq.value)=="") {alert("Enquiry text is required.");frm.txtEnq.focus();return false}
	else return true;
}

function ValidateSubmitStory(frm){
	var fname=Trim(frm.txtImage.value)
	var ext=Trim(fname.substr(fname.lastIndexOf(".")+1))
	ext=ext.toLowerCase();
	
	if (Trim(frm.txtName.value)=="") {alert("Name is required.");frm.txtName.focus();return false}
	else if (Trim(frm.txtEmail.value)=="") {alert("Email is required.");frm.txtEmail.focus();return false}
	else if (!ValidateEmail(Trim(frm.txtEmail.value))) {alert("Please enter a valid email address.");frm.txtEmail.focus();return false}
	else if (Trim(frm.txtTitle.value)=="") {alert("News title is required.");frm.txtTitle.focus();return false}
	else if (Trim(frm.txtCont.value)=="") {alert("News story is required.");frm.txtCont.focus();return false}
	else if (fname!="" && ext!="jpg" && ext!="jpeg" && ext!="jpe" && ext!="gif" && ext!="bmp" && ext!="png" ) {
		alert("This type of file is not allowed to upload.");
		frm.txtImage.focus();
		return false;
	}
	else return true;
}

function ValidateSubmitDoc(frm){
	var fname=Trim(frm.txtFile.value)
	var ext=Trim(fname.substr(fname.lastIndexOf(".")+1))
	ext=ext.toLowerCase();
	
	if (Trim(frm.txtName.value)=="") {alert("Name is required.");frm.txtName.focus();return false}
	else if (Trim(frm.txtEmail.value)=="") {alert("Email is required.");frm.txtEmail.focus();return false}
	else if (!ValidateEmail(Trim(frm.txtEmail.value))) {alert("Please enter a valid email address.");frm.txtEmail.focus();return false}
	else if (Trim(frm.txtTitle.value)=="") {alert("Document title is required.");frm.txtTitle.focus();return false}
	else if (Trim(frm.txtFile.value)=="") {alert("Choose a document to upload.");frm.txtFile.focus();return false}
	else if (ext!="doc" && ext!="pdf" && ext!="txt") {
		alert("This type of file is not allowed to upload.");
		frm.txtFile.focus();
		return false;
	}
	else return true;
}
//-->