
	function clearText(thefield) {
	  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
	} 
	function replaceText(thefield) {
	  if (thefield.value=="") { thefield.value = thefield.defaultValue }
	}
	
	function ValidateConsonantsSmall(valor) 
	{
		   valor = valor.toLowerCase();
		if (/[bcdfghjklmnpqrstvwxyz]{7}/.test(valor))
			return false;
		else
			return true;
	}
	
	

	function ValidateEmailSmall(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 ValidateEmailCharactersSmall(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 ValidateEmailDomainSmall(valor) 
	{
		valor = valor.toLowerCase();
		if (/.ru$|.sk$|.ua$/i.test(valor))
			return false;	
		else
			return true;
	}
   
	function trim(myString)
	{
		return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
	}
	
	function ValidateNameSmall(valor) 
	{
			valor = valor.toLowerCase();
		if (/^[a-z ]+$/i.test(valor))
			return true;
		else
			return false;
	} 




    
	function ValidateDataSmall(FirstName,LastName,Email,Comment,contactDate)
	{
		_gaq.push(['_trackEvent', 'Webform', 'Start Submit', 'Small Contact']);
		FirstName.value=trim(FirstName.value);
		LastName.value=trim(LastName.value);
		Email.value=trim(Email.value);   
		Comment.value=trim(Comment.value); 
		if (contactDate.value != "")
		{						
			return (false);
		}
		
		if (FirstName.value == "")
		{
			alert('Please, enter your first name.');
			FirstName.focus();
			_gaq.push(['_trackEvent', 'Webform', 'Validation Error - FirstName', 'Small Contact']);
			return (false);
		}
		else		
		{
			if (!ValidateNameSmall(FirstName.value))
			{
				alert('Please, check your first name.');
				FirstName.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - FirstName', 'Small Contact']);
				return false;
			}
			if(!ValidateConsonantsSmall(FirstName.value))
			{
				alert("Please check your first name.");
				FirstName.focus();		
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - FirstName', 'Small Contact']);
				return false;
			}	
			
		}
		
		if (LastName.value == "")
		{
			alert('Please, enter your last name.');
			LastName.focus();
			_gaq.push(['_trackEvent', 'Webform', 'Validation Error - LastName', 'Small Contact']);
			return (false);
		}
		else		
		{
			if (!ValidateNameSmall(LastName.value))
			{
				alert('Please, check your last name.');
				LastName.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - LastName', 'Small Contact']);
				return false;
			}
			if(!ValidateConsonantsSmall(LastName.value))
			{
				alert("Please check your last name.");
				LastName.focus();			
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - LastName', '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(!ValidateEmailCharactersSmall(Email.value))
			{
				alert("Please check your email.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}	
			
			if(!ValidateEmailSmall(Email.value))
			{
				alert("Please check the emails address.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}
			
			if(!ValidateEmailDomainSmall(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(!ValidateConsonantsSmall(Email.value))
			{
				alert("Please check your email.");
				Email.focus();
				_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Email', 'Small Contact']);
				return false;
			}					
		}
			
		if (Comment.value == "")
		{
			alert('Please, enter your comments.');
			Comment.focus();
			_gaq.push(['_trackEvent', 'Webform', 'Validation Error - Comment', 'Small Contact']);
			return (false);
		}
		_gaq.push(['_trackEvent', 'Webform', 'Submit Ok', 'Small Contact']);
		return true;
	}

	

    function getElement(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 txtFirstName=document.getElementById('txtFirstName');	
		var txtLastName=document.getElementById('txtLastName');		
		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(txtFirstName,txtLastName,txtEmail,txtComments,contactDate)==true)
			window.location.href="savesmallform.aspx?txtFirstName="+txtFirstName.value+"&txtLastName="+txtLastName.value+"&txtEmail="+txtEmail.value+"&txtComments="+txtComments.value+"&hdnContactFormID="+hdnContactFormID.value+"&hdnContactFormType="+hdnContactFormType.value;
		
	}
	
