
	function clearText(thefield) {
         
	  if (thefield.defaultValue==trim(thefield.value)) { thefield.value = "" }
	} 
	function replaceText(thefield) {
	  if (trim(thefield.value)=="") { thefield.value = thefield.defaultValue }
	}
	
	
	
	function ValidateEmail(valor) 
    {
	

	    if (/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(valor))
		    return true;
	    else
		    return false;
    }
    
   function trim(myString)
   {
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
   }
        
    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 ValidateDataSmall(Name,Email,Phone,Comment)
	{
	
		Name.value=trim(Name.value);
		Email.value=trim(Email.value);
		Phone.value=trim(Phone.value);
		Comment.value=trim(Comment.value);
		if ((Name.value == "") || (Name.value == 'Name'))
		{
			alert('Please, enter your name.');			
			Name.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 ((Phone.value == "") || (Phone.value == 'Phone'))
		{
			alert('Please, enter your phone.');
			Phone.focus();
			return (false);
		}
		else
		{
			if(!ValidatePhone(Phone.value))
			{
				alert("Please check your phone.");
				Phone.focus();
				return false;
			}
		}
			
		if ((Comment.value == "") || (Comment.value == 'Comments'))
		{
			alert('Please, enter your comments.');
			Comment.focus();
			return (false);
		}
		
		return true;
	}

	function OnSubmit(){
		
		var txtFullName=document.getElementById('txtFullName');
		var txtEmail=document.getElementById('txtEmail');
		var txtPhone=document.getElementById('txtPhone');
		var txtComments=document.getElementById('txtComments');	
		var hdnContactFormID=document.getElementById('hdnContactFormID');
		var hdnContactFormType=document.getElementById('hdnContactFormType');
		
		if (ValidateDataSmall(txtFullName,txtEmail,txtPhone,txtComments)==true)
			window.location.href="savesmallform.aspx?txtFullName="+txtFullName.value+"&txtPhone="+txtPhone.value+"&txtEmail="+txtEmail.value+"&txtComments="+txtComments.value+"&hdnContactFormID="+hdnContactFormID.value+"&hdnContactFormType="+hdnContactFormType.value;
		
	}