function formcheck(formobj) {
	// check title
	if (!(trim(formobj.cust_name.value) > '')) {
		alert('Please enter a Name.');
		formobj.cust_name.focus();
		return false;
	}		
	//check email
	var xx = trim(formobj.cust_email.value);
	if (xx > '') {
		var goodEmail = formobj.cust_email.value.match(/\b(^(\S+@).+(\..{2,3})$)\b/gi);
		if (!goodEmail) {
			alert('Invalid email address syntax');
			formobj.cust_email.select();
			formobj.cust_email.focus();
			return false;
		}
	} else {
		alert('Please enter your email address');
		formobj.cust_email.focus();
		return false;
	}
		
	formobj.submit();
}
function formcompetitioncheck(formobj) {
	// check firstname
	if (!(trim(formobj.firstname.value) > '')) {
		alert('Please enter your First Name.');
		formobj.firstname.focus();
		return false;
	}
	// check lastname
	if (!(trim(formobj.lastname.value) > '')) {
		alert('Please enter your Last Name.');
		formobj.lastname.focus();
		return false;
	}
	
	//check email
	var xx = trim(formobj.email.value);
	if (xx > '') {
		var goodEmail = formobj.email.value.match(/\b(^(\S+@).+(\..{2,3})$)\b/gi);
		if (!goodEmail) {
			alert('Invalid email address syntax');
			formobj.email.select();
			formobj.email.focus();
			return false;
		}
	} else {
		alert('Please enter your email address');
		formobj.email.focus();
		return false;
	}
	// check answer
	if (!(trim(formobj.comments.value) > '')) {
		alert('Please enter your Answer.');
		formobj.comments.focus();
		return false;
	}
	formobj.submit();
}
function checkemailafriend (formobj) {
	// check names
	if (!(trim(formobj.recipientname.value) > '')) {
		alert('Please Enter Recipients Name.');
		formobj.recipientname.focus();
		return false;
	}
	// check recipient's email
	var xx = trim(formobj.recipientemail.value);
	if (xx > '') {
		var goodEmail = formobj.recipientemail.value.match(/\b(^(\S+@).+(\..{2,3})$)\b/gi);
		if (!goodEmail) {
			alert('Invalid Recipient Email Address Syntax');
			formobj.recipientemail.select();
			formobj.recipientemail.focus();
			return false;
		}
	} else {
		alert('Please enter recipient email address');
		formobj.recipientemail.focus();
		return false;
	}
	// check yourname
	if (!(trim(formobj.yourname.value) > '')) {
		alert('Please enter your Name.');
		formobj.yourname.focus();
		return false;
	}
	// check recipient's email
	var xx = trim(formobj.youremail.value);
	if (xx > '') {
		var goodEmail = formobj.youremail.value.match(/\b(^(\S+@).+(\..{2,3})$)\b/gi);
		if (!goodEmail) {
			alert('Invalid Email Address Syntax');
			formobj.youremail.select();
			formobj.youremail.focus();
			return false;
		}
	} else {
		alert('Please enter your email address');
		formobj.youremail.focus();
		return false;
	}
			
	formobj.submit();
}

function formblogcheck (formobj) {
	// check names
	if (!(trim(formobj.name.value) > '')) {
		alert('Please Enter Name.');
		formobj.name.focus();
		return false;
	}
	
	// check yourname
	if (!(trim(formobj.comments.value) > '')) {
		alert('Please enter Comments');
		formobj.comments.focus();
		return false;
	}
	
	// check recipient's email
	var xx = trim(formobj.email.value);
	if (xx > '') {
		var goodEmail = formobj.email.value.match(/\b(^(\S+@).+(\..{2,3})$)\b/gi);
		if (!goodEmail) {
			alert('Invalid Email Address Syntax');
			formobj.email.select();
			formobj.email.focus();
			return false;
		}
	} else {
		alert('Please enter email address');
		formobj.email.focus();
		return false;
	}
		
	formobj.submit();
}
function trim(strText) {
	while (strText.substring(0,1) == ' ')
		strText = strText.substring(1,strText.length);

	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0,strText.length-1);
	
	return strText;
}
function openwindow(gotourl) {
	window.open('' + gotourl + '','EmailaFriend','width=550,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
function clickremove(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}
function clickadd(thisfield, defaulttext) {
	if (thisfield.value == '') {
	thisfield.value = defaulttext;
	}
}
