// JavaScript Document
//*************************************************************************************************************************************	
function trimAll(sString) 
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function verif_email(email) {
var arobase = email.indexOf("@");
var point = email.lastIndexOf(".");
if((arobase < 3)||(point + 2 > email.lengtd)||(point < arobase+3)) return false;
return true;
}

//*****************************************************************************************************************************************
function validate_debt_Test_Form()
{
	//var type = type

	var debt_Test_Form = document.forms['debt_Test_Form'];
	var Total = trimAll(debt_Test_Form.Total.value);
	var Creditors = trimAll(debt_Test_Form.Creditors.value);
	var Income = trimAll(debt_Test_Form.Income.value);
	var Status = trimAll(debt_Test_Form.Status.value);
	var Firstname = trimAll(debt_Test_Form.Firstname.value);
	var Surname = trimAll(debt_Test_Form.Surname.value);
	var Email = trimAll(debt_Test_Form.Email.value);
	var Telephone = trimAll(debt_Test_Form.Telephone.value);
	var Mobile = trimAll(debt_Test_Form.Mobile.value);
	var Privacy = debt_Test_Form.Privacy;
	
	//if (type == 2)
	//{
	//var QuickQuoteMortAmount = trimAll(QuickQuoteForm.QuickQuoteMortAmount.value);
	//var QuickQuoteMortTerm = trimAll(QuickQuoteForm.QuickQuoteMortTerm.value);
	//var QuickQuoteMortType = trimAll(QuickQuoteForm.QuickQuoteMortType.value);
	//}
	
	if (Total == '')
	{
		alert("You must enter an amount")	
		return false;
	}
	
	if (Creditors == '')
	{
		alert("You must enter number of Creditors")	
		return false;
	}
	
	if (Income == '')
	{
		alert("You must enter an income amount")	
		return false;
	}
	
	if (Status == '')
	{
		alert("You must enter you resedential status")
		return false;
	}
	
	if (Firstname == '')
	{
		alert("You must enter your first name")
		return false;
	}
	
	
	if (Surname == '')
	{
		alert("You must enter your sur name")
		return false;
	}
	
	if (Telephone == '')
	{
		alert("You must enter a phone number")
		return false;
	}
	
	if (!verif_email(Email))
			{
		alert("You must enter a valid email address")	
		return false;
			}

	
	//if (QuickQuoteEmail == '')
	//{
	//	alert("You must enter a valid email address")	
	//	return false;
	//}
	
	
	if (Privacy.checked == false)
	{
		alert("You must agree to the terms of use and privacy policy")
		return false;
	}

		return true;
}