function ValidateFullName(source, arguments)
{

    var Name = document.getElementById(source.controltovalidate);
    if ((Name.value == "") || (Name.value == Name.defaultValue))
    {
	    source.errormessage = 'Please, enter your Name.';	   
	    arguments.IsValid=false;		
	    return;
    }		
	else
	{
        if(!ValidateName(Name.value))
		{
			source.errormessage = 'Please check your Name.';	   
			arguments.IsValid=false;		
			return;
		}

		if(!ValidateConsonants(Name.value))
		{
			source.errormessage = 'Please check your Name.';	   
			arguments.IsValid=false;
			return;
		}
	}	
    arguments.IsValid=true;
}

function ValidatePhone(source, arguments)
{
    var Phone = document.getElementById(source.controltovalidate);
    if ((Phone.value == "") || (Phone.value == Phone.defaultValue))
    {
	    source.errormessage = 'Please, enter your Phone.';
	   
	    arguments.IsValid=false;		
	    return;
    }
    else
    {
	    var ValidChars = "0123456789.()- ";
	    var IsCorrect=true;
	    var Char;
        var IsValid=false;
        incoming= document.getElementById(source.controltovalidate).value;
	    for (cont = 0; cont < incoming.length && IsCorrect == true; cont++) 
	    { 
	        Char = incoming.charAt(cont); 
	        if (ValidChars.indexOf(Char) == -1) {
				 source.errormessage = 'Please, check the Phone.';
	             arguments.IsValid= false;
	             return;
	        }
	    }
	 }
	 arguments.IsValid= true;
}

function ValidateEmail(valor) 
    {
	    if (/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,60}\.[a-zA-Z]{2,4}$/.test(valor))
		    return true;
	    else
		    return false;
    }  

function CustomValidateEmail(source, arguments)
{
    if(arguments)
    {
        var Email = document.getElementById(source.controltovalidate);
        if (Email.value == "")
        {
	        source.errormessage = 'Please, enter your Email.';
    	   
	        arguments.IsValid=false;			
	        return;
        }
        else
        {
        if(!ValidateEmail(Email.value))
	        {
		        source.errormessage = "Please check the emails address.";
    		 
		        arguments.IsValid=false;				
		        return;
	        }
        }
        arguments.IsValid=true;
    }    
}

function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 

function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

function trim(myString)
{
 return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}

function ValidateConsonants(valor) 
{
       valor = valor.toLowerCase();
	if (/[bcdfghjklmnpqrstvwxyz]{7}/.test(valor))
		return false;
	else
		return true;
}  


function ValidateName(valor) 
{
      	valor = valor.toLowerCase();
	if (/^[a-z ]+$/i.test(valor))
		return true;
	else
		return false;
} 
