
//------------------- for clearing and replacing text in form input fields and textareas -------------------//
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 trim(myString)
{
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
function ValidateDataSmall(Name,Email,Comment)
{

	Name.value=trim(Name.value);
    	Email.value=trim(Email.value); 
    	Comment.value=trim(Comment.value);

	
	if ((Name.value == "") || (Name.value == Name.defaultValue))
	{
		alert('Please, enter your name.');
		Name.focus();
		return (false);
	}
	
	
	if ((Email.value == "") || (Email.value == Email.defaultValue))
	{
		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 == Comment.defaultValue))
	{
		alert('Please, enter your comments.');
		Comment.focus();
		return (false);
	}
	
	return true;
}

function OnSubmit(){
	
	var txtFullName=document.getElementById('txtFullName');
	var txtEmail=document.getElementById('txtEmail');
	var txtComments=document.getElementById('txtComments');	
	var hdnContactFormID=document.getElementById('hdnContactFormID');
	var hdnContactFormType=document.getElementById('hdnContactFormType');
	
	if (ValidateDataSmall(txtFullName,txtEmail,txtComments)==true)
		window.location.href="savesmallform.aspx?txtFullName="+txtFullName.value+"&txtEmail="+txtEmail.value+"&txtComments="+txtComments.value+"&hdnContactFormID="+hdnContactFormID.value+"&hdnContactFormType="+hdnContactFormType.value;
	
}
