function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
}

function ValidateEmail(formName){
	var emailID=formName.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	return true
 }


function checkFormValues (formName) {
		
		if (formName.first_name.value == '') {
			alert("Please enter your first name.")
			formName.first_name.focus();
			return false;
			}
		else if (ValidateEmail(formName)==false) {
			alert("Please enter a valid email address.")
			formName.email.focus();
			return false;
			}
		else if (formName.confirm_email.value == '') {
			alert("Please enter your email address again for confirmation.")
			formName.confirm_email.focus();
			return false;
			}
		else if (formName.email.value != formName.confirm_email.value) {
			alert("Please make sure you have entered your confirmation email address correctly.")
			formName.zip_code.focus();
			return false;
			}
		else if (formName.city.value == '') {
			alert("Please enter your city.")
			formName.city.focus();
			return false;
			}	
		else if (formName.state.value == '') {
			alert("Please select your state or province.")
			formName.state.focus();
			return false;
			}
		else if (formName.tbox_comment.value == '') {
			alert("Please describe the reason you chose to celebrate with the NEW Confetti Fudge Ice Cream Cake.")
			formName.tbox_comment.focus();
			return false;
			}
		else
			return true;
	}

/**
* DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
	