function OnSubmit()
{
	var txtFullName = document.getElementById('txtFullName');
	var txtEmail = document.getElementById('txtEmail');
	var txtComments = document.getElementById('txtComments');
	var contactDate = document.getElementById('contactDate');
	var hdnContactFormID = document.getElementById('hdnContactFormID');
	var hdnContactFormType = document.getElementById('hdnContactFormType');

	if (ValidateDataSmall(txtFullName, txtEmail, txtComments, contactDate)==true)
	window.location.href="/savesmallform.aspx?txtFullName="+txtFullName.value+"&txtEmail="+txtEmail.value+"&txtComments="+txtComments.value+"&hdnContactFormID="+hdnContactFormID.value+"&hdnContactFormType="+hdnContactFormType.value;
}

function ValidateDataSmall(FullName, Email, Comment,contactDate)
{	
	if (contactDate.value != "")
	{
		return false;
	}
	
	FullName.value=trim(FullName.value);
  	Email.value=trim(Email.value);
  	Comment.value=trim(Comment.value);
	
	if ((FullName.value == "") || (FullName.value == 'Name'))
	{
		alert('Please, enter your full name.');
		FullName.focus();
		return false;
	}
	else
	{	
		if (!ValidateName(FullName.value))
		{
			alert('Please, check your full name.');
			FullName.focus();			
			return (false);
		}
		if (!ValidateConsonants(FullName.value))
		{
			alert('Please, check your full name.');
			FullName.focus();			
			return (false);
		}
	}
	
	if ((Email.value == "") || (Email.value == 'Email'))
	{
		alert('Please, enter your email.');
		Email.focus();
		return false;
	}
	else
	{
		if(!ValidateEmailCharacters(Email.value))
		{
		   	alert("Please check your email.");
		  	Email.focus();			
		   	return false;
		}
		if(!ValidateEmail(Email.value))
		{
			alert("Please check your email.");
			Email.focus();			
			return false;
		}
		if(!ValidateEmailDomain(Email.value))
		{
			alert("Please check your email, domain (.ru, .sk, .ua) isn't valid.");
			Email.focus();			
			return false;
		}

		if(!ValidateConsonants(Email.value))
		{
			alert("Please check your email.");
			Email.focus();			
			return false;
		}
	}
		
	if ((Comment.value == "") || (Comment.value == 'Comments'))
	{
		alert('Please, enter your comments.');
		Comment.focus();
		return false;
	}
	return true;
}

function trim(myString)
{
 return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}


function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 

function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

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;
}  


