function checkForm(theForm) {
    var why = "";  
    why += checkText(theForm.FirstName.value, "su nombre."); // your first name
    why += checkText(theForm.LastName.value, "su apellido."); // your last name
    why += checkPhone(theForm.WorkPhone.value);
    why += checkEmail(theForm.Email.value);
    
    why += checkDropdown(document.signup_form.Gender.options[document.signup_form.Gender.selectedIndex].value, "Favor introduzca su genero.") // Please tell us your gender
    why += checkDropdown(document.signup_form.OfficeName.options[document.signup_form.OfficeName.selectedIndex].value, "Favor introduzca su ubicacion preferida.") // Please tell us your preferred location
    why += checkDropdown(document.signup_form.Advertisement.options[document.signup_form.Advertisement.selectedIndex].value, "Favor diganos como supo sobre nosotros.") // Please tell us how you heard about us
    
    if (why != "") {
       alert(why);
       return false;
    }
 
return true;
}


function checkEmail (strng) {
var error="";
if (strng == "") {
   // error = "Please enter a valid email address.\n";
   error = "Favor introduzca su direccion de email correcta.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       // error = "Please enter a valid email address.\n";
       error = "Favor introduzca su direccion de email correcta.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
			error = "La direccion de email contiene caracteres ilegales.\n";
          // error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function checkText (strng, formfield) {
 var error = "";
 if (strng == "") {
    // error = "Please enter " + formfield + "\n";
    error = "Favor introduzca " + formfield + "\n";
 }
 return error;
 }

function checkPhone (strng) {
 	
 	var error = "";
 
	if (strng == "") {
		error = "Favor introduzca su telefono preferido.\n";
	   // error = "Please enter a daytime phone number.\n";
	   return error;
	}

 
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	
	if (isNaN(parseInt(stripped))) {
	 	// error = "The phone number contains illegal characters.";
	 	error = "El numero de telefono contiene caracteres ilegales.";
	 
	}
	
	if (!(stripped.length == 10)) {
		// error = "The phone number is not a complete phone number with area code.\n";
		error = "El numero de telefono esta incompleto, favor incluir el codigo de area.\n";
	}
 
 	return error;
 }


function checkDropdown(choice, strng) {
    var error = "";
    if (choice == "") {
       error = strng + "\n";
    }    
return error;
}    


