	function clearText(thefield) {
	  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
	} 
	
	function replaceText(thefield) {
	  if (thefield.value=="") { thefield.value = thefield.defaultValue }
	}	
	
	function ValidateEmail(valor) 
    {
	    if (/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(valor))
		    return true;
	    else
		    return false;
    }
    
    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 trim(myString)
   {
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
   }

	function ValidateDataSmall(FirstName,LastName,Email,Comment)
	{	    
		FirstName.value=trim(FirstName.value);
		LastName.value=trim(LastName.value);
		Email.value=trim(Email.value);		
		Comment.value=trim(Comment.value);
		
		if ((FirstName.value == "") || (FirstName.value == 'FirstName'))
		{
			alert('Please, enter your first name.');
			FirstName.focus();
			return (false);
		}
		
		if ((LastName.value == "") || (LastName.value == 'FirstName'))
		{
			alert('Please, enter your last name.');
			LastName.focus();
			return (false);
		}
		
		if ((Email.value == "") || (Email.value == 'Email'))
		{
			alert('Please, enter your email.');
			Email.focus();
			return (false);
		}
		else
		{
			if(!ValidateEmail(Email.value))
			{
				alert("Please check the emails address.");
				Email.focus();
				return false;
			}
		}
		
		if ((Comment.value == "") || (Comment.value == 'Comments'))
		{
			alert('Please, enter your comments.');
			Comment.focus();
			return (false);
		}
		
		return true;
	}

	function OnSubmit()
	{
	
		var txtFirstName=getElement('txtFirstName');
		var txtLastName=getElement('txtLastName');
		var txtEmail=getElement('txtEmail');
		var txtComments=getElement('txtComments');			
		var hdnContactFormID=getElement('hdnContactFormID');
		var hdnContactFormType=getElement('hdnContactFormType');
		var chkSingUp=getElement('chkSingUp');
		
		if (ValidateDataSmall(txtFirstName,txtLastName,txtEmail,txtComments)==true)
			window.location.href="/savesmallform.aspx?txtFirstName="+txtFirstName.value +
			"&txtLastName=" + txtLastName.value +
			"&txtEmail=" + txtEmail.value +			
			"&txtComments=" + txtComments.value +
			"&chkSingUp=" + chkSingUp.checked +
			"&hdnContactFormID=" + hdnContactFormID.value +
			"&hdnContactFormType=" + hdnContactFormType.value;		
	}
	
	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;
                    }
                }
            }
        }    
    }