	function clearText(thefield) {
	  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
	} 
	
	function replaceText(thefield) {
	  if (thefield.value=="") { thefield.value = thefield.defaultValue }
	}
		
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 trim(myString)
    {
     return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
    }
    
	function ValidateDataSmall(FullName,Email,AboutUs,Comment,ContactDate)
	{
		_gaq.push(['_trackEvent', 'Webform', 'Start Submit', 'Small Contact']);
        FullName.value=trim(FullName.value);
        Email.value=trim(Email.value);   
        AboutUs.Value = trim(AboutUs.value);   
        Comment.value=trim(Comment.value);   
        
		if (ContactDate.value != "")
		{						
			return (false);
		}
		
		if (FullName.value == "")
		{
			alert('Please, enter your full name.');
			FullName.focus();
			_gaq.push(['_trackEvent', 'Webform', 'Validation Error - FullName', 'Small Contact']);
			return (false);
		}
		else
		{
			if (!ValidateName(FullName.value))
			{
				alert('Please, check your full name.');
				FullName.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - FullName', 'Small Contact']);
				return (false);
			}
			if (!ValidateConsonants(FullName.value))
			{
				alert('Please, check your full name.');
				FullName.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - FullName', 'Small Contact']);
				return (false);
			}		
		}		

		if (Email.value == "")
		{
			alert('Please, enter your email.');
			Email.focus();
			_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
			return (false);
		}
		else
		{
			if(!ValidateEmailCharacters(Email.value))
			{
				alert("Please check your email.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}
			if(!ValidateEmail(Email.value))
			{
				alert("Please check your email.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}
			if(!ValidateEmailDomain(Email.value))
			{
				alert("Please check your email, domain (.ru, .sk, .ua) isn't valid.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}

			if(!ValidateConsonants(Email.value))
			{
				alert("Please check your email.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}
		}
		
		if (AboutUs.value == "")
		{
			alert('Please, select any option.');
			AboutUs.focus();
			_gaq.push(['_trackEvent', 'Webform', 'Validation Error - AboutUs', 'Small Contact']);
			return (false);
		}
			
	_gaq.push(['_trackEvent', 'Webform', 'Submit Ok', 'Small Contact']);
	return true;
	}

	function getSmallContactElement(name)
	{
	    var object = null;
	    var tbSmallContact=document.getElementById('tbSmallContact'); 
	    for (var i=0; i<tbSmallContact.rows.length; i++)
        {
            for (var j=0; j<tbSmallContact.rows[i].cells.length; j++)
            {
                for (var k=0; k<tbSmallContact.rows[i].cells[j].childNodes.length; k++)
                {                
                    if(tbSmallContact.rows[i].cells[j].childNodes[k].id == name)
                    {
                       object = tbSmallContact.rows[i].cells[j].childNodes[k];
                       return object;
                    }
                }
            }
           
        }    
	}
	
	function OnSubmit(){
		var txtFullName=getSmallContactElement('txtFullName');			
		var txtEmail=getSmallContactElement('txtEmail');
		var ddlHearAboutUs=getSmallContactElement('ddlHearAboutUs');
		var txtComments=getSmallContactElement('txtComments');	
		var chkSingUp=getSmallContactElement('chkSingUp');
		var contactDate=getSmallContactElement('contactDate');
		var hdnContactFormID=getSmallContactElement('hdnContactFormID');
		var hdnContactFormType=getSmallContactElement('hdnContactFormType');
		
		if (ValidateDataSmall(txtFullName,txtEmail,ddlHearAboutUs, txtComments,contactDate)==true)
		{
			if(chkSingUp.checked)
				chkSingUp.value = "Yes";
			else
				chkSingUp.value = "No";
			
		    window.location.href="/savesmallform.aspx?"+
			                "txtFullName="+txtFullName.value+
			                "&ddlHearAboutUs="+ddlHearAboutUs.value+
			                "&txtEmail="+txtEmail.value+
			                "&txtComments="+txtComments.value+
							"&chkSingUp="+chkSingUp.value+
			                "&hdnContactFormID="+hdnContactFormID.value+
			                "&hdnContactFormType="+hdnContactFormType.value;	
		}
	}
	
	
	
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;
}  
