// JavaScript Document

function submitForm()
{

var theForm = document.forms['form_1'];

	iVal = theForm.f_name.value;

	if (iVal == "Your first name")
	{
		alert("Please enter your first name");
		theForm.f_name.focus();
		return false;
	}

	if (iVal.indexOf("<") >= 0 || iVal.indexOf(">") >= 0)
	{
		alert("Please do not contain signs < or >");
		theForm.f_name.focus();
		return false;
	}
	
	iVal = theForm.s_name.value;

	if (iVal == "Your surname")
	{
		alert("Please enter your surname");
		theForm.s_name.focus();
		return false;
	}

	if (iVal.indexOf("<") >= 0 || iVal.indexOf(">") >= 0)
	{
		alert("Please do not contain signs < or >");
		theForm.s_name.focus();
		return false;
	}

	iVal = theForm.phone.value;
	
	if 
	(
	 Number(iVal) < 0 || 
	 iVal == "" || 
	 isNaN(iVal) == true
	)
	{
		alert("Please enter phone number with area code like 0299001100. Do not contain spaces.");
		theForm.phone.focus();
		return false;
	}

	if 	( iVal.indexOf("0") != 0) 
	{
		alert("Please provide area code");
		theForm.phone.focus();
		return false;
	}

	iVal = theForm.email.value;
		
	if (iVal == "" || iVal.indexOf("@") <= 0)
	{
		alert("Please enter a valid email address");
		theForm.email.focus();
		return false;
	}

	if (iVal.indexOf("<") >= 0 || iVal.indexOf(">") >= 0)
	{
		alert("Please do not contain signs < or >");
		theForm.email.focus();
		return false;
	}

	iVal = theForm.comment.value;
		
	if (iVal.indexOf("<") >= 0 || iVal.indexOf(">") >= 0)
	{
		alert("Please do not contain signs < or >");
		theForm.comment.focus();
		return false;
	}

	return true;
}

function clearFName()
{

	var theForm = document.forms['form_1'];

	if (theForm.f_name.value == "Your first name")
		theForm.f_name.value = "";
	
	return true;
}

function clearSName()
{

	var theForm = document.forms['form_1'];

	if (theForm.s_name.value == "Your surname")
		theForm.s_name.value = "";
	
	return true;
}

function clearPhone()
{

	var theForm = document.forms['form_1'];

	if (theForm.phone.value == "Your phone number")
		theForm.phone.value = "";

	return true;
}

function clearEmail()
{

	var theForm = document.forms['form_1'];

	if (theForm.email.value == "Your email address")
		theForm.email.value = "";

	return true;
}

function resetForm()
{

	var theForm = document.forms['form_1'];

	theForm.f_name.value = "Your first name";
	theForm.s_name.value = "Your surname";
	theForm.phone.value = "Your phone number";
	theForm.email.value = "Your email address";

	return true;
}

function checkFName()
{

	var theForm = document.forms['form_1'];
	
	if (theForm.f_name.value == "")
		theForm.f_name.value = "Your first name";

	return true;
}

function checkSName()
{

	var theForm = document.forms['form_1'];
	
	if (theForm.s_name.value == "")
		theForm.s_name.value = "Your surname";

	return true;
}


function checkPhone()
{

	var theForm = document.forms['form_1'];
		
	iVal = theForm.phone.value;
	
	if (iVal == "")
		theForm.phone.value = "Your phone number";

	return true;
}

function checkEmail()
{

	var theForm = document.forms['form_1'];
		
	iVal = theForm.email.value;
	
	if (iVal == "")
		theForm.email.value = "Your email Aadress";

	return true;
}
