function ValidateData()
{
	var contactDate = document.getElementById('contactDate');	
	var txtFirstName = document.getElementById('txtFirstName');
	var txtLastName = document.getElementById('txtLastName');
	var txtPhone = document.getElementById('txtPhone');
	var txtEmail = document.getElementById('txtEmail');	
	var txtComments = document.getElementById('txtComments');
		
	if (contactDate.value != "")
	{
		return false;
	}
	
	if (txtFirstName.value == "")
	{
		alert('Please, enter your first name.');
		txtFirstName.focus();
		return false;
	}
	else
	{	
		if (!ValidateName(txtFirstName.value))
		{
			alert('Please, check your first name.');
			txtFirstName.focus();			
			return (false);
		}
		if (!ValidateConsonants(txtFirstName.value))
		{
			alert('Please, check your first name.');
			txtFirstName.focus();			
			return (false);
		}
	}
		
	if (txtLastName.value == "")
	{
		alert('Please, enter your last name.');
		txtLastName.focus();
		return false;
	}
	else
	{
		if (!ValidateName(txtLastName.value))
		{
			alert('Please, check your last name.');
			txtLastName.focus();			
			return (false);
		}
		if (!ValidateConsonants(txtLastName.value))
		{
			alert('Please, check your last name.');
			txtLastName.focus();			
			return (false);
		}
	}
	
	if (txtPhone.value == "")
	{
		alert('Please, enter your phone number.');
		txtPhone.focus();
		return false;
	}
	else
	{
		if(!ValidatePhone(txtPhone.value))
		{
			alert("Please, enter a valid phone number.");
			txtPhone.focus();
			return false;
		}
	}
	
	if (txtEmail.value == "")
	{
		alert('Please, enter your email.');
		txtEmail.focus();
		return false;
	}
	else
	{
		if(!ValidateEmailCharacters(txtEmail.value))
		{
		   	alert("Please check your email.");
		  	txtEmail.focus();			
		   	return false;
		}
		if(!ValidateEmail(txtEmail.value))
		{
			alert("Please check your email.");
			txtEmail.focus();			
			return false;
		}
		if(!ValidateEmailDomain(txtEmail.value))
		{
			alert("Please check your email, domain (.ru, .sk, .ua) isn't valid.");
			txtEmail.focus();			
			return false;
		}

		if(!ValidateConsonants(txtEmail.value))
		{
			alert("Please check your email.");
			txtEmail.focus();			
			return false;
		}			
	}
	
	if (txtComments.value == "")
	{
		alert('Please, enter your comments.');
		txtComments.focus();
		return false;
	}	
	return true;
}

function ValidatePhone(incoming)
{
	var ValidChars = "0123456789.()- ";
	var IsCorrect=true;
	var Char;
	
	for (cont = 0; cont < incoming.length && IsCorrect == true; cont++) 
	{
		Char = incoming.charAt(cont); 
		if (ValidChars.indexOf(Char) == -1) 
			return false;
	}
	return 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;
} 

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 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 ValidateEmailDomain(valor) 
{
	valor = valor.toLowerCase();
	if (/.ru$|.sk$|.ua$/i.test(valor))
		return false;	
	else
		return true;
}  
