function emailWindow(URL,NAME) {
	emailwindow=window.open(URL,NAME,'fullscreen=0,hotkeys=1,location=0,menubar=0,channelmode=0,dependent=1,directories=0,scrollbars=1,status=0,titlebar=1,toolbar=0,resizable=yes,width=512,height=470,screenX=10,screenY=10,top=10,left=10');
	emailwindow.focus();
}

function checkemail(form_name, form_field_name) { 	
	if (form_field_name.value.indexOf("@")==-1) {
		alert("" +form_field_name.name + " field requires a valid email address.");
		form_field_name.focus();	
	}
	else {
		
		return true;
	}
}

function is_field_empty(form_field_name) {
	if (form_field_name.value=='') {
		alert("" +form_field_name.name + " is a required field.")
		form_field_name.focus();
	}
	else
		return (true);
}

function validate_form() {
	var passed1=checkemail(send_email_form, send_email_form.your_email);
	var passed2=checkemail(send_email_form, send_email_form.recipients_email);
	var passed3=is_field_empty(send_email_form.your_name);
	var passed4=is_field_empty(send_email_form.recipients_name);
	var passed5=checkCaptchaImage(send_email_form);

	//Will submit the form only if all values have passed. Meaning that if
	//all returned values are true it will submit.
	//alert("passed1 " + passed1);

	if ((passed1==true) && (passed2==true) && (passed3==true) && (passed4==true) && (passed5==true))
	{
		send_email_form.submit();
	}
}

function checkCaptchaImage(form_name) {
//new form field	
   
   var submit1, submit2;
   
   if (form_name.image_text.value == '') {

    alert('Please enter a value. This is required field.')

   form_name.image_text.focus();

    return false;

  }
  else submit1=true;
  
  //results returned using ajax and then cleaned up
  //removing carriage return, newline, and whitespaces, tabs...
  cleanedUp=document.getElementById("result").value.replace(/(\r\n\s|[\r\n\s])/g, "");
  	
  //print error if no match is found
  if (cleanedUp != "match") {
    alert('The word you entered did not match the picture.\nPlease try again.');

    return false;
  }
  else submit2=true;

  if ((submit1==true) && (submit2==true)) {
	return true;
  }

}