function ValidateDetails(theForm){
	
	//check for HTML code
	for(i=0; i<theForm.length; i++) {
		if(theForm[i].value.match("<[^<>]*>")) {
			alert('You cannot type any HTML code. Please ammend.');
			theForm[i].focus();
			return false;
		}
	}
	
	//check empty fields
	if (theForm.FirstName.value=="") {
		alert('Please fill in your First Name.');
		theForm.FirstName.focus();
		return false;
    }
	if (theForm.LastName.value=="") {
		alert('Please fill in your Last Name.');
		theForm.LastName.focus();
		return false;
    }
	if (theForm.HomePhone.value=="") {
		alert('Please fill in your Home Phone.');
		theForm.HomePhone.focus();
		return false;
    }
	//check email
	if (!checkMail(theForm.email.value)) {
		theForm.email.focus();
		return false;
    }
	//check ZIP
	if (theForm.Zip.value.length!=5 || isNaN(theForm.Zip.value)) {
		alert('Zip Code must be a 5 digit number.');
		theForm.Zip.focus();
		return false;
    }

	//check creditors
	balance_sum = 0;

	for(i=1; i<=10; i++) {
		obj = document.getElementById('CurrentBalance'+i);
		
		if(isNaN(obj.value)) {
			alert('Balance must be a number!');
			obj.focus();
			return false;
		}
		else
			balance_sum = balance_sum + (obj.value*1);
	}
	
	if(balance_sum<=0) {
		alert('You must enter at least one Creditor and have its Balance Due.');
		return false;
	}
	
	// SUBMIT FORM //
	return true;
	
}

function checkMail(email)
{
	var x = email;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else {
		alert('Please enter a valid email address');
		return false;
	}
}

cc = 6;
function addCred(){
	obj = document.getElementById("ctr"+cc);

	obj.style.display = '';

	if(cc==10)
		document.getElementById("adcredb").style.display = 'none';

	cc++;
}
