function isBlank(s)
{
	for(var i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if((c != ' ') && (c != '\n') && (c != '\t'))
		{
			return false;
		}
	}
	return true;
}

var myemail = "";
var myconfirm = "";

function verify(f)
{
	var msg;
	var empty_fields = "";
	var errors = "";
	
	for(var i = 0; i < f.length; i++)
	{
		var e = f.elements[i];
		var myValue = e.value;
		if(((e.type == "text") || (e.type == "textarea")) && !e.optional)
		{
			if((myValue == null) || (myValue == "") || isBlank(myValue))
			{
				empty_fields += "\n     " + e.name;
			}
		}	
		
		//Get email values for later checks
		if(e.name == "email")
		{
			myemail = e.value;
		}	
		
		if(e.name == "email_confirm")
		{
			myconfirm = e.value;
		}	
			
		//form specific validation
		if(e.name != "url")
		{
			if (myValue.match(/<a href=/)) 
			{
				errors += "\n     " + e.name + " cannot contain links.";
			}
		}
	}
	
	if(myemail != myconfirm)
	{
		errors += "\n    The email addresses entered do not match.";
	}
	
	if(!empty_fields && !errors)
	{
		return true;
	}
	
	msg = "The form was not submitted because of the following error(s).\n";
	msg += "Please correct and resubmit.\n\n";
	
	if(empty_fields)
	{
		msg += "- The following required fields are empty:" + empty_fields + "\n";
		if(errors)
		{
			msg += "\n";
			msg += errors;
		}
	}
	alert(msg);
	return false;
}

function confirmEmail()
{
	var email = document.form1.email.value;
	var confirmemail = document.form1.confirmemail.value;
	 
	alert(email);
	alert(confirmemail);
	
	if(confirmemail == email)
	{
		document.form1.submit.enable;
	}else
	{
		alert("Both email fields must contain the same value. Please correct before proceeding.");
		document.form1.email.focus();
	}
	
	return true;
}