var thisForm

function validateForm(frmName) {

	thisForm = frmName;

	var errors = '';
	var errorMsg = '';

	switch(thisForm) {
		case "regfrm":
			if (!isEmpty('regname')) {
				errors += 'Please enter your name.\n';
			}
			if (!checkEmail('regemail')) {
				errors += 'Please enter your email.\n';
			}

			if (errors) {
				alert('There was a problem with your details.\n\n' + errors);
			}
			break;



		default:
			errors += 'error'
			break;
	}

	document.returnValue = (errors == '');

	if (document.returnValue)	{
		eval("document." + frmName + ".submit()")
	}else	{
		return document.returnValue;
	}
}

function unChanged(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	if (strVal == 'name' && elmVal == 'Name') {
		return false;
	} else if (strVal == 'email' && elmVal == 'Email') {
		return false;
	}
	return true;
}

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 isSame(strVal,strVal2){
	if (eval('document.' + thisForm + '.' + strVal +'.value') != eval('document.' + thisForm + '.' + strVal2 +'.value'))	{
		return false;
	}else{
		return true;
	}
}

function isEmpty(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.value');
	elmLen = elmVal.length;
	if (elmLen == null || elmLen == 0) {
		return false;
	}
	return true;
}

function checkTick(strVal) {
	elmVal = eval('document.' + thisForm + '.' + strVal +'.checked');
	if (!elmVal) {
		return false;
	}
	return true;
}


function oneRadioTicked(radioName)	{
	for (i=0 ; i < eval('document.' + thisForm + '.' + radioName +'.length') ; i++)		{	
		if (eval('document.' + thisForm + '.' + radioName +'['+i+'].checked'))	{
			return true;
		}
	}
	return false;
}