    //Form Validation//

// check if there are only letters
function checkName( fieldValue, divID){
    var checkLetters = /^[a-zA-Z]+$/;//values allowed in the input field
    //displays the message 'Correct' if there are only letters
    if(checkLetters.test(fieldValue)) {
            document.getElementById(divID+'_msg').innerHTML="Correct";
    }
    //displays the message 'Correct' if there are only letters
    else{
	    document.getElementById(divID+'_msg').innerHTML="<span style=\"color:#CC1100;\">Please only enter letters into this field</span>";
    }         
}

//displays the message 'Correct' Username is only letters and numbers and between 5-15 characters
function checkUserName( fieldValue, divID){
    var regex = /^[a-zA-Z0-9]+$/;//values allowed in the input field
    if(fieldValue.length < 5 || fieldValue.length > 15){
        document.getElementById(divID+'_msg').innerHTML="* Username must be between 5-15 characters";
	areYouEmpty(fieldValue, divID);
    }  
    else if(regex.test(fieldValue)) {
        document.getElementById(divID+'_msg').innerHTML="Correct";
    }
    else{
	document.getElementById(divID+'_msg').innerHTML="<span style=\"color:#CC1100;\">Only numbers and letters allowed.</span>";
	areYouEmpty(fieldValue, divID);
    }         
}

//displays the message 'Correct' Phone is only numbers and bigger than 5 characters
function checkPhone( fieldValue, divID){
    var regex = /^[0-9]/;//values allowed in the input field
    if(regex.test(fieldValue)) {
        document.getElementById(divID+'_msg').innerHTML="Correct";
    }
    else{
	document.getElementById(divID+'_msg').innerHTML="<span style=\"color:#CC1100;\">Only numbers allowed.</span>";
	areYouEmpty(fieldValue, divID);
    }         
}

function checkText( fieldValue, divID){
    var regex = /[<>]/;//values not allowed in the input field
    //displays the message 'Correct' if there are only letters
    if(regex.test(fieldValue)) {
        document.getElementById(divID+'_msg').innerHTML="<span style=\"color:#CC1100;\">Invalid character used.</span>";
    }
    //displays the message 'Correct' if there are only letters
    else{
	document.getElementById(divID+'_msg').innerHTML="Correct";
        areYouEmpty(fieldValue, divID);
    }         
}

//displays the message 'Correct' password is only letters and numbers and between 5-15 characters
function checkPassword( fieldValue, divID){
    var regex = /^[a-zA-Z0-9]+$/;//values allowed in the input field
    if(fieldValue.length < 5 || fieldValue.length > 15){
        document.getElementById(divID+'_msg').innerHTML="* Password must be between 5-15 characters";
	areYouEmpty(fieldValue, divID);
    }  
    else if(regex.test(fieldValue)) {
            document.getElementById(divID+'_msg').innerHTML="Correct";
    }
    else{
	    document.getElementById(divID+'_msg').innerHTML="<span style=\"color:#CC1100;\">Only numbers and letters allowed.</span>";
	    areYouEmpty(fieldValue, divID);
    }         
}

//checks that the email is entered correctly
function checkEmail(value,fieldname){
    regexy = /^[\w\.]+@[a-zA-Z0-9_]+?\.[a-zA-Z\.]{2,6}$/;//values and format allowed in the input field
    //if email is entered correctly display message 'Correct"
    if (regexy.test(value)) {
	document.getElementById(fieldname+'_msg').innerHTML='Correct';
	return true;
    }
    //if email is not entered correctly display message 'valid address required
    else{	
	document.getElementById(fieldname+'_msg').innerHTML='<span style=\"color:#CC1100;\">Valid address required</span>';
	areYouEmpty(value, fieldname);
	return false;
    }
    
}

//checks to see if a input box is empty
  function areYouEmpty(fieldValue, divID){
    //if the input box is empty displays messege '* Required field'
    if(fieldValue.length == 0){
        document.getElementById(divID+'_msg').innerHTML="* This field cannot be empty";
    }  
}
	
