 function ValidatePhone(source, arguments)
{
		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) {
				 arguments.IsValid= false;
				 return;
			}
		}
		arguments.IsValid= true;
}


function ValidateFirstName(source, arguments)
{

    var FirstName = document.getElementById(source.controltovalidate);
    if (FirstName.value == "")
    {
	    source.errormessage = 'Please, enter your First Name.';
	    arguments.IsValid=false;		
	    return;
    }
	else		
	{
		if (!ValidateName(FirstName.value))
		{
			source.errormessage = 'Please, check your First Name.';    	   
			FirstName.focus();
			arguments.IsValid=false;
			return;
		}
		if(!ValidateConsonants(FirstName.value))
		{
			source.errormessage = 'Please, check your First Name.';
			FirstName.focus();
			arguments.IsValid=false;				
			return;
		}
	}
    arguments.IsValid=true;
}

function ValidateLastName(source, arguments)
{
    var LastName = document.getElementById(source.controltovalidate);    
    if (LastName.value == "")
    {
	    source.errormessage = 'Please, enter your Last Name.';
	    arguments.IsValid=false;		
	    return;
    }
	else		
	{
		if (!ValidateName(LastName.value))
		{
			source.errormessage = 'Please, check your Last Name.';    	   
			LastName.focus();
			arguments.IsValid=false;
			return;
		}
		if(!ValidateConsonants(LastName.value))
		{
			source.errormessage = 'Please, check your Last Name.';
			LastName.focus();
			arguments.IsValid=false;				
			return;
		}
	}
    arguments.IsValid=true;
}

function ValidateCity(source, arguments)
{
    var City = document.getElementById(source.controltovalidate);    
    if (City.value != "")
    {
		if (!ValidateName(City.value))
		{
			source.errormessage = 'Please, check your City.';    	   
			City.focus();
			arguments.IsValid=false;
			return;
		}
		if(!ValidateConsonants(City.value))
		{
			source.errormessage = 'Please, check your City.';
			City.focus();
			arguments.IsValid=false;				
			return;
		}
	}
	
    arguments.IsValid=true;
}

function ValidateState(source, arguments)
{    
    var State = document.getElementById(source.controltovalidate);    
    if (State.value != "")
	{
		if (!ValidateName(State.value))
		{
			source.errormessage = 'Please, check your State.';    	   
			State.focus();
			arguments.IsValid=false;
			return;
		}
		if(!ValidateConsonants(State.value))
		{
			source.errormessage = 'Please, check your State.';
			State.focus();
			arguments.IsValid=false;				
			return;
		}
	}
    arguments.IsValid=true;
}

function ValidateAge(source, arguments)
{    
    var Age = document.getElementById(source.controltovalidate);
    if (Age.value != "")
    {
		if (!ValidateAreaCode(Age.value))
		{
			source.errormessage = 'Please, check your Age.';    	   
			Age.focus();
			arguments.IsValid=false;
			return;
		}
	}	
    arguments.IsValid=true;
}



function ValidateEmail(valor) 
{    
    if (/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.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(!ValidateEmailCharacters(Email.value))
			{
				source.errormessage = "Please check your Email.";
			 	arguments.IsValid=false;
				return;
			}	
			
			if(!ValidateEmail(Email.value))
			{
				source.errormessage = "Please check your Email.";
			 	arguments.IsValid=false;
				return;
			}
			
			if(!ValidateEmailDomain(Email.value))
			{
				source.errormessage = "Please check your Email.";
			 	arguments.IsValid=false;
				return;
			}
			
			if(!ValidateConsonants(Email.value))
			{
				source.errormessage = "Please check your Email Address.";
			 	arguments.IsValid=false;
				return;
			}
        }
        arguments.IsValid=true;
    }    
}




function trim(myString)
{
 return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
 
function ValidateName(valor) 
{
		valor = valor.toLowerCase();
	if (/^[a-z ]+$/i.test(valor))
		return true;
	else
		return false;
}

function ValidateConsonants(valor) 
{
	   valor = valor.toLowerCase();
	if (/[bcdfghjklmnpqrstvwxyz]{7}/.test(valor))
		return false;
	else
		return true;
}

function ValidateEmail(valor) 
{    
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,60}(\.[a-zA-Z]{2,4}){1,2}$/;  
    return emailPattern.test(valor); 
}



function ValidateEmailCharacters(valor)
{
	valor = valor.toLowerCase();
	var ValidChars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";   
	var Char;
	var IsCorrect=true;
	
	for (cont = 0; cont < valor.length && IsCorrect == true; cont++) 
	{ 
		Char = valor.charAt(cont); 
		if (ValidChars.indexOf(Char) == -1) {
			return false;
		}
	}
	return true;
}

function ValidateEmailDomain(valor) 
{
	valor = valor.toLowerCase();
	if (/.ru$|.sk$|.ua$/i.test(valor))
		return false;	
	else
		return true;
} 

function ValidateAreaCode(incoming)
{
    var ValidChars = "0123456789";
    var IsCorrect=true;
    var Char;
    var IsValid=false;
    for (cont = 0; cont < incoming.length && IsCorrect == true; cont++) 
    { 
        Char = incoming.charAt(cont); 
        if (ValidChars.indexOf(Char) == -1) {
             return false;
        }
    }
    return true;
}

















