var thisForm

function chkForm(frmName) {
	thisForm = frmName;
	validateForm(frmName);
	if (document.returnValue) {
		eval('document.' + thisForm + '.submit()');
	}
}

function chkSearch(frmName) {
	thisForm = frmName;
	validateSearch(frmName);
	if (document.returnValue) {
		eval('document.' + thisForm + '.submit()');
	}
}

function checkEmail(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	testRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(elmVal);
	if (!testRe) {
		return false;
	}
	return true;
}

function isSelStill(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	testStr = "not_selected"
	if (elmVal == testStr) {
		return false;
	}
	return true;
}

function isEmpty(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	elmLen = elmVal.length;
	if (elmLen == null || elmLen == 0) {
		return false;
	}
	return true;
}

function checkAlpha(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	testRe = /^[a-z ]+$/.test(elmVal);
	if (!testRe) {
		return false;
	}
	return true;
}

function checkNum(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	testRe = /^\d+$/.test(elmVal);
	if (!testRe) {
		return false;
	}
	return true;
}

function checkDate(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	testRe = /^([0-9]{2})(\/[0-9]{2})(\/[0-9]{2})$/.test(elmVal); //Date fomat dd/mm/yy
	if (elmVal != "DD/MM/YY") {
		if (!testRe) {
			return false;
		}
	}
	return true;
}

function notChanged(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	if (elmVal == 'Enter your keyword/s here') {
		return false;
	}
	return true;
}

function validateSearch(frmName) {
	thisForm = frmName;
	var errors = '';
	var errorMsg = '';
	if (!notChanged('keywords') || !isEmpty('keywords')) {
		errors += 'Please enter your keyword/s.\n';
	}
	if (errors) {
		alert('The Site Search Form has not been completed properly.\n\n' + errors);
	}
	document.returnValue = (errors == '');
	return document.returnValue;
}
