﻿/*
Returns HTML object
- elemId    - server id of the object (ex. tbFirstName)
- elemType  - HTML object type (ex. INPUT, SELECT, DIV, TR, TD, TABLE .. etc)
*/
function GetServerElement(elemId, elemType)
{
    var allElems = document.getElementsByTagName(elemType);
    
    for(i = 0; i < allElems.length; i++)
    {
        if(allElems[i].id.indexOf(elemId) > -1)
        {
            return allElems[i];
        }
    }
    
    return null;
}







/*
Returns HTML object position and dimensions
- obj.height, obj.width, obj.x, obj.y
*/
function GetPos(theObj)
{
    x = y = 0;
    h = theObj.offsetHeight;
    w = theObj.offsetWidth;
    
    while(theObj)
    {
        x += theObj.offsetLeft;
        y += theObj.offsetTop;
        theObj = theObj.offsetParent;
    }
    
    return {height:h,width:w,x:x,y:y}
}



function isNumeric(value)
{
  //if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/))
  if (!value.toString().match(/^\d*$/))
	return false;
	
	
  return true;
}











function ValidateDebtMiniForm()
{
    
	var ddlCreditCardDebt		= GetServerElement("ddlCreditCardDebt", "SELECT");
	var ddlOtherUnsecuredDebt	= GetServerElement("ddlOtherUnsecuredDebt", "SELECT");
	var ddlNumOfCreditors		= GetServerElement("ddlNumOfCreditors", "SELECT");
	var ddlStatusOfBillPayments	= GetServerElement("ddlStatusOfBillPayments", "SELECT");
	var ddlGoal					= GetServerElement("ddlGoal", "SELECT");
	
	var focusedObj              = null;
	
	
	var retString = "Please select: \r\n";
	var hasError = false;
	
	if(ddlCreditCardDebt.value == "-1")
	{
		retString += "\r\n- Credit Card Debt";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlCreditCardDebt;
	}
	
	if(ddlOtherUnsecuredDebt.value == "-1")
	{
		retString += "\r\n- Other Unsecured Debt";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlOtherUnsecuredDebt;
	}
	
	try
	{
	    if(ddlNumOfCreditors.value == "-1")
	    {
		    retString += "\r\n- Number of Creditors";
		    hasError = true;
    		
		    if (focusedObj == null)
		        focusedObj = ddlNumOfCreditors;
	    }
    }
    catch (exc)
	{ }
	
	try
	{
		if(ddlStatusOfBillPayments.value == "-1")
		{
			retString += "\r\n- Status of Bill Payment";
			hasError = true;
			
			if (focusedObj == null)
		        focusedObj = ddlStatusOfBillPayments;
		}
	}
	catch (exc)
	{}
	
	try
	{
		if(ddlGoal.value == "-1")
		{
			retString += "\r\n- I Want To";
			hasError = true;
			
			if (focusedObj == null)
		        focusedObj = ddlGoal;
		}
	}
	catch (exc)
	{}
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
}


function ValidateDebtPersonalForm() {
    var ddlStatusOfBillPayments = GetServerElement("ddlStatusOfBillPayments", "SELECT");
    var ddlGoal = GetServerElement("ddlGoal", "SELECT");
    var txtFirstName = GetServerElement("txtFirstName", "INPUT");
    var txtLastName = GetServerElement("txtLastName", "INPUT");
    //	var ddlStates				= GetServerElement("ddlStates", "SELECT");
    //	var txtAddress				= GetServerElement("txtAddress", "INPUT");
    var txtEmail = GetServerElement("txtEmail", "INPUT");
    //	var txtCity                 = GetServerElement("txtCity", "INPUT");
    var txtZipCode = GetServerElement("txtZipCode", "INPUT");
    //	var txtHomePhone			= GetServerElement("txtHomePhone", "INPUT");
    var txtPhone1 = GetServerElement("txtPhone1", "INPUT");
    var txtPhone2 = GetServerElement("txtPhone2", "INPUT");
    var txtPhone3 = GetServerElement("txtPhone3", "INPUT");
    var txtHomePhone = txtPhone1.value + txtPhone2.value + txtPhone3.value;
    //	var txtHomePhoneExt			= GetServerElement("txtHomePhoneExt", "INPUT");
    //	var txtWorkPhone			= GetServerElement("txtWorkPhone", "INPUT");
    var txtPhoneAlternate1 = GetServerElement("txtPhoneAlternate1", "INPUT");
    var txtPhoneAlternate2 = GetServerElement("txtPhoneAlternate2", "INPUT");
    var txtPhoneAlternate3 = GetServerElement("txtPhoneAlternate3", "INPUT");
    var txtWorkPhone = txtPhoneAlternate1.value + txtPhoneAlternate2.value + txtPhoneAlternate3.value;
    //	var txtWorkPhoneExt			= GetServerElement("txtWorkPhoneExt", "INPUT");
    //	var txtComments				= GetServerElement("txtComments", "INPUT");


    var retString = "Please insert: \r\n";
    var hasError = false;

    var focusedObj = null


    try {
        if (ddlStatusOfBillPayments.value == "-1") {
            retString += "\r\n- Status of Bill Payment";
            hasError = true;

            if (focusedObj == null)
                focusedObj = ddlStatusOfBillPayments;
        }
    }
    catch (exc) {
        focusedObj = null;
    }

    try {
        if (ddlGoal.value == "-1") {
            retString += "\r\n- I Want To";
            hasError = true;

            if (focusedObj == null)
                focusedObj = ddlGoal;
        }
    }
    catch (exc) {
        focusedObj = null;
    }


    if (txtFirstName.value == "") {
        retString += "\r\n- First Name";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtFirstName;
    }

    if (txtLastName.value == "") {
        retString += "\r\n- Last Name";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtLastName;
    }

    if (txtZipCode.value == "") {
        retString += "\r\n- ZIP";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtZipCode;
    }
    //	try
    //	{
    //		if(ddlStates.value == "-1")
    //		{
    //			retString += "\r\n- State";
    //			hasError = true;
    //			
    //			if (focusedObj == null)
    //		        focusedObj = ddlStates;
    //		}
    //	}
    //	catch (exc)
    //	{}
    //	
    //	if(txtAddress.value == "")
    //	{
    //		retString += "\r\n- Address";
    //		hasError = true;
    //	}

    if (txtEmail.value == "") {
        retString += "\r\n- Email";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtEmail;
    }

    //var txtHomePhoneValue = txtHomePhone.value;
    var txtHomePhoneValue = txtHomePhone;

    txtHomePhoneValue = txtHomePhoneValue.replace("(", "");
    txtHomePhoneValue = txtHomePhoneValue.replace(")", "");
    txtHomePhoneValue = txtHomePhoneValue.replace(/ /g, "");
    txtHomePhoneValue = txtHomePhoneValue.replace(/-/g, "");
    txtHomePhoneValue = txtHomePhoneValue.replace(/_/g, "");

    //var txtWorkPhoneValue = txtWorkPhone.value;
    var txtWorkPhoneValue = txtWorkPhone;

    txtWorkPhoneValue = txtWorkPhoneValue.replace("(", "");
    txtWorkPhoneValue = txtWorkPhoneValue.replace(")", "");
    txtWorkPhoneValue = txtWorkPhoneValue.replace(/ /g, "");
    txtWorkPhoneValue = txtWorkPhoneValue.replace(/-/g, "");
    txtWorkPhoneValue = txtWorkPhoneValue.replace(/_/g, "");


    if (txtHomePhoneValue.length < 10 && txtHomePhoneValue > 0) {
        retString += "\r\n- Invalid Home Phone Number";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtPhone1;
    }


    if (txtWorkPhoneValue.length < 10 && txtWorkPhoneValue > 0) {
        retString += "\r\n- Invalid Cell Phone Number";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtPhoneAlternate1;
    }


    if (txtHomePhoneValue == "" && txtWorkPhoneValue == "") {
        retString += "\r\n- Home Phone Number or Cell Phone Number";
        hasError = true;

        if (focusedObj == null)
            focusedObj = txtPhone1;
    }

    //	if(txtHomePhoneValue == "" && txtHomePhoneExt.value != "")
    //	{
    //		retString += "\r\n- Best Contact Number extension without phone number";
    //		hasError = true;
    //		
    //		if (focusedObj == null)
    //		    focusedObj = txtHomePhone;
    //	}


    //	if(txtWorkPhoneValue == "" && txtWorkPhoneExt.value != "")
    //	{
    //		retString += "\r\n- Cell Phone Number extension without phone number";
    //		hasError = true;
    //	}


    if (hasError) {
        alert(retString);

        if (focusedObj != null)
            focusedObj.focus();

        return false;
    }


    if (!validName(txtFirstName)) {
        alert("Invalid characters in first name field or name is too short");
        txtFirstName.focus();
        return false;
    }

    if (!validName(txtLastName)) {
        alert("Invalid characters in last name field or name is too short");
        txtLastName.focus();
        return false;
    }

    emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!txtEmail.value.match(emailRegex)) {
        alert('Please enter valid email address');
        txtEmail.focus();
        return false;
    }
    if (!isNumeric(txtHomePhoneValue)) {
        alert('Please enter valid Home Phone Number ');
        txtPhone1.focus();
        return false;
    }

    if (!isNumeric(txtWorkPhoneValue)) {
        alert('Please enter valid Cell Phone number ');
        txtPhoneAlternate1.focus();
        return false;
    }
    //	if(!isNumeric(txtHomePhoneExt.value))
    //	{
    //		alert('Please enter valid Best Contact Number extension');
    //		txtHomePhoneExt.focus();
    //		return false;
    //	}

    //	if(!isNumeric(txtWorkPhoneExt.value))
    //	{
    //		alert('Please enter valid Alternate Phone extension');
    //		txtWorkPhoneExt.focus();
    //		return false;
    //	}
}


function ValidateMortgageMiniForm()
{
	var ddlLoanType				= GetServerElement("ddlLoanType", "SELECT");
	var ddlHomeDescription		= GetServerElement("ddlHomeDescription", "SELECT");
	var ddlCreditProfile		= GetServerElement("ddlCreditProfile", "SELECT");
	
	
	var retString = "Please select: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
	if(ddlLoanType.value == "-1")
	{
		retString += "\r\n- Loan Type";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlLoanType;
	}
	
	if(ddlHomeDescription.value == "-1")
	{
		retString += "\r\n- Home Description";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlHomeDescription;
	}
	
	if(ddlCreditProfile.value == "-1")
	{
		retString += "\r\n- Credit Profile";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlCreditProfile;
	}
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
}


function SetHasSecondMortgageVisible(isVisible)
{
	var HasSecondMortgageDiv		= document.getElementById("HasSecondMortgageDiv");
	
	if(isVisible)
	{
		try
		{
			HasSecondMortgageDiv.style.display = "table";
		}
		catch(exc)
		{
			HasSecondMortgageDiv.style.display = "block";
		}
	}
	else
	{
		HasSecondMortgageDiv.style.display = "none";
	}
}



function ValidateMortgageRefinanceForm()
{
    var txtComment                      = GetServerElement("txtComment", "INPUT");

    //var rbLateMortgagePaymentsYes       = GetServerElement("rbLateMortgagePaymentsYes", "INPUT");
    //var rbLateMortgagePaymentsNo        = GetServerElement("rbLateMortgagePaymentsNo", "INPUT");	
	
	var ddlEstimatedHomeValue			= GetServerElement("ddlEstimatedHomeValue", "SELECT");
	var ddlFirstMortgageBalance			= GetServerElement("ddlFirstMortgageBalance", "SELECT");
	var ddlFirstMortgageInterestRate	= GetServerElement("ddlFirstMortgageInterestRate", "SELECT");
	var lbExistingTypeOfRate			= GetServerElement("lbExistingTypeOfRate", "SELECT");
	//var txtAdditionalCash				= GetServerElement("txtAdditionalCash", "INPUT");
	var ddlAdditionalCash				= GetServerElement("ddlAdditionalCash", "SELECT");
	//var txtPropertyAddress				= GetServerElement("txtPropertyAddress", "INPUT");
	//var txtPropertyCity					= GetServerElement("txtPropertyCity", "INPUT");
	var txtPropertyZipCode				= GetServerElement("txtPropertyZipCode", "INPUT");
	var ddlStates           			= GetServerElement("ddlStates", "SELECT");
	
	var rbHasSecondMortgageYes			= GetServerElement("rbHasSecondMortgageYes", "INPUT");
	var rbHasSecondMortgageNo			= GetServerElement("rbHasSecondMortgageNo", "INPUT");	
	var ddlSecondMortgageInterestRate	= GetServerElement("ddlSecondMortgageInterestRate", "SELECT");
	var ddlSecondMortgageBalance		= GetServerElement("ddlSecondMortgageBalance", "SELECT");
	//var lblState						= GetServerElement("lblState", "SPAN");
	var ddlGrossAnnualIncome			= GetServerElement("ddlGrossAnnualIncome", "SELECT");	
	//var txtEmail						= GetServerElement("txtEmail", "INPUT");
	//var chkAccept						= GetServerElement("chkAccept", "INPUT");
	
	
	
	var retString = "Please insert: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
//	
//	if(txtPropertyAddress != null && txtPropertyAddress.value == "")
//	{
//		retString += "\r\n- Property Address";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = txtPropertyAddress;
//	}
	
//	if(txtPropertyCity != null && txtPropertyCity.value == "")
//	{
//		retString += "\r\n- Property City";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = txtPropertyCity;
//	}
	
	if(txtPropertyZipCode.value == "")
	{
		retString += "\r\n- Property ZIP";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPropertyZipCode;
	}
	
//	if(ddlStates.value == "-1")
//	{
//		retString += "\r\n- Property State";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = ddlStates;
//	}
	
	if(ddlEstimatedHomeValue.value == "-1")
	{
		retString += "\r\n- Estimated Home Value";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlEstimatedHomeValue;
	}
	
	if(ddlFirstMortgageBalance.value == "-1")
	{
		retString += "\r\n- First Mortgage Balance";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlFirstMortgageBalance;
	}
	
	if(ddlFirstMortgageInterestRate.value == "-1")
	{
		retString += "\r\n- First Mortgage Interest Rate";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlFirstMortgageInterestRate;
	}
	
	
	if(rbHasSecondMortgageYes.checked)
	{
		if(ddlSecondMortgageInterestRate.value == "-1")
		{
			retString += "\r\n- Second Mortgage Interest Rate";
			hasError = true;
			
			if (focusedObj == null)
		        focusedObj = ddlSecondMortgageInterestRate;
		}
		
		if(ddlSecondMortgageBalance.value == "-1")
		{
			retString += "\r\n- Second Mortgage Balance";
			hasError = true;
			
			if (focusedObj == null)
		        focusedObj = ddlSecondMortgageBalance;
		}
	}
	
	if(lbExistingTypeOfRate.value == "")
	{
		retString += "\r\n- Existing Type of Rate";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = lbExistingTypeOfRate;
	}
	
//	if(txtAdditionalCash != null && txtAdditionalCash.value == "")
//	{
//		retString += "\r\n- Additional Cash";
//		hasError = true;
//	}

	if(ddlAdditionalCash.value == "-1")
	{
		retString += "\r\n- Additional Cash";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlAdditionalCash;
	}
	
	if(ddlGrossAnnualIncome.value == "-1")
	{
		retString += "\r\n- Gross Annual Income";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlGrossAnnualIncome;
	}
	
//	if(txtEmail.value == "")
//	{
//		retString += "\r\n- Email";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = txtEmail;
//	}
	
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
	
	
	if (txtPropertyZipCode.value.length != 5 || !isNumeric(txtPropertyZipCode.value))
	{
		alert('Please enter valid ZIP code (5 numeric characters)');
		txtPropertyZipCode.focus();
		return false;
	}
	
	
//	if (lblState.innerHTML.length < 1)
//	{
//		alert('Please enter valid ZIP code (can not be connected to valid State)');
//		txtPropertyZipCode.focus();
//		return false;
//	}
	
//	emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//	if(!txtEmail.value.match(emailRegex))
//	{
//		alert('Please enter valid email address');
//		txtEmail.focus();
//		return false;
//	}
//	
//	if (!chkAccept.checked)
//	{
//		alert('You must accept Debt Watch Privacy and Security policies to continue');
//		return false;
//	}
	
	/*
	if(txtAdditionalCash != null && !isNumeric(txtAdditionalCash.value))
	{
		alert('Please enter valid (only numbers) Additional Cash');
		txtAdditionalCash.focus();
		return false;
	}
	else
	{
		var estimateHomeValue = parseInt(ddlEstimatedHomeValue.value, 0);
		var firstMortgageBalance = parseInt(ddlFirstMortgageBalance.value, 0);
		
		var secondMortgageBalance = 0;
		
		if(rbHasSecondMortgageYes.checked)
			secondMortgageBalance = parseInt(ddlSecondMortgageBalance.value, 0);
			
		var requestedAdditionalCash = parseInt(txtAdditionalCash.value, 0);
		
		var maxValToAllow = (estimateHomeValue - firstMortgageBalance - secondMortgageBalance) * loanAmountPercentage / 100;
		
		var retVal = (maxValToAllow >= requestedAdditionalCash);
		
		if(!retVal)
		{
			alert('Requested additional cash is too high.\r\n It should not be higher than $'+ maxValToAllow.toString() +' having current settings');
		}
		
		return retVal;
	}
	*/
	
	return true;
}


function SetFirstTimeBuyerVisible (isVisible)
{
	var divFirstTimeBuyer = GetServerElement("divFirstTimeBuyer", "DIV");
	
	if(isVisible)
	{
		try
		{
			divFirstTimeBuyer.style.display = "table";
		}
		catch(exc)
		{
			divFirstTimeBuyer.style.display = "block";
		}
	}
	else
		divFirstTimeBuyer.style.display = "none";
}


function ValidateMortgagePurchaseForm()
{
    var txtPropertyZipCode          = GetServerElement("txtPropertyZipCode", "INPUT");
    var lbHomeEquityType            = GetServerElement("lbHomeEquityType", "SELECT");
	var ddlStates                   = GetServerElement("ddlStates", "SELECT");
	var lbResidence					= GetServerElement("lbResidence", "SELECT");
	var ddlHomeValue				= GetServerElement("ddlHomeValue", "SELECT");
	var ddlEstimatedDownPayment		= GetServerElement("ddlEstimatedDownPayment", "SELECT");
	var lbRateType					= GetServerElement("lbRateType", "SELECT");
	var ddlLikelyToBuyHome			= GetServerElement("ddlLikelyToBuyHome", "SELECT");
	//var lblState					= GetServerElement("lblState", "SPAN");
	var ddlGrossAnnualIncome		= GetServerElement("ddlGrossAnnualIncome", "SELECT");
//	var txtEmail				    = GetServerElement("txtEmail", "INPUT");
//	var chkAccept					= GetServerElement("chkAccept", "INPUT");


	var retString = "Please insert: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
	
	if(txtPropertyZipCode.value == "")
	{
	    retString += "\r\n- ZIP Code";
	    hasError = true;
	    
	    if (focusedObj == null)
		    focusedObj = txtPropertyZipCode;
    }

    if (lbHomeEquityType.value == "")
    {
        retString += "\r\n- Do you prefer a loan or a line of credit?";
        hasError = true;
    }
	
//	
//	if(ddlStates.value == "-1")
//	{
//		retString += "\r\n- States";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = ddlStates;
//	}
	
	
	if(lbResidence.value == "")
	{
		retString += "\r\n- How will be used";
		hasError = true;
	}

	
	if(ddlHomeValue.value == "-1")
	{
		retString += "\r\n- Purchase price of the new home";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlHomeValue;
	}
	
	
	if(ddlEstimatedDownPayment.value == "-1")
	{
		retString += "\r\n- Estimated Down Payment";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlEstimatedDownPayment;
	}
	
	if(lbRateType.value == "")
	{
		retString += "\r\n- Desired Type of Rate";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlEstimatedDownPayment;
	}
	
	if(ddlLikelyToBuyHome.value == "-1")
	{
		retString += "\r\n- When are you likely to buy a home";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlLikelyToBuyHome;
	}
	
	if(ddlGrossAnnualIncome.value == "-1")
	{
		retString += "\r\n- Gross Annual Income";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlGrossAnnualIncome;
	}
	
//	if(txtEmail.value == "")
//	{
//		retString += "\r\n- Email";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = txtEmail;
//	}	

	

	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}




	if (txtPropertyZipCode.value.length != 5 || !isNumeric(txtPropertyZipCode.value))
	{
		alert('Please enter valid ZIP code (5 numeric characters)');
		txtPropertyZipCode.focus();
		return false;
	}
	
//	if (lblState.innerHTML.length < 1)
//	{
//		alert('Please enter valid ZIP code (can not be connected to valid State)');
//		txtPropertyZipCode.focus();
//		return false;
//	}
	
	
//	emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//	if(!txtEmail.value.match(emailRegex))
//	{
//		alert('Please enter valid email address');
//		txtEmail.focus();
//		return false;
//	}
//	
//	if (!chkAccept.checked)
//	{
//		alert('You must accept Debt Watch Privacy and Security policies to continue');
//		return false;
//	}
	
	return true;		
}

function valForm()
{
    return true;
}



function ValidateMortgageLoanModificationForm()
{
    	
	var txtComment						= GetServerElement("txtComment", "INPUT");
	var ddlEstimatedHomeValue			= GetServerElement("ddlEstimatedHomeValue", "SELECT");
	var ddlFirstMortgageLender			= GetServerElement("ddlFirstMortgageLender", "SELECT");
	var ddlFirstMortgageBalance			= GetServerElement("ddlFirstMortgageBalance", "SELECT");
	var ddlFirstMortgageInterestRate	= GetServerElement("ddlFirstMortgageInterestRate", "SELECT");
	var ddlMonthsBehindPayment      	= GetServerElement("ddlMonthsBehindPayment", "SELECT");
	var lbExistingTypeOfRate			= GetServerElement("lbExistingTypeOfRate", "SELECT");
	var txtPropertyAddress				= GetServerElement("txtPropertyAddress", "INPUT");
	//var txtPropertyCity					= GetServerElement("txtPropertyCity", "INPUT");
	var txtPropertyZipCode				= GetServerElement("txtPropertyZipCode", "INPUT");
	var ddlStates           			= GetServerElement("ddlStates", "SELECT");
	
	var rbHasSecondMortgageYes			= GetServerElement("rbHasSecondMortgageYes", "INPUT");
	var rbHasSecondMortgageNo			= GetServerElement("rbHasSecondMortgageNo", "INPUT");	
	var ddlSecondMortgageInterestRate	= GetServerElement("ddlSecondMortgageInterestRate", "SELECT");
	var ddlSecondMortgageBalance		= GetServerElement("ddlSecondMortgageBalance", "SELECT");
	//var lblState						= GetServerElement("lblState", "SPAN");
	var ddlGrossAnnualIncome			= GetServerElement("ddlGrossAnnualIncome", "SELECT");	
//	var txtEmail						= GetServerElement("txtEmail", "INPUT");
//	var chkAccept						= GetServerElement("chkAccept", "INPUT");
	
	
	var retString = "Please insert: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
	
	if(txtPropertyAddress != null && txtPropertyAddress.value == "")
	{
		retString += "\r\n- Property Address";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPropertyAddress;
	}
	
//	if(txtPropertyCity != null && txtPropertyCity.value == "")
//	{
//		retString += "\r\n- Property City";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = txtPropertyCity;
//	}
	
	if(txtPropertyZipCode.value == "")
	{
		retString += "\r\n- Property ZIP";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPropertyZipCode;
	}
	
//	if(ddlStates.value == "-1")
//	{
//		retString += "\r\n- Property State";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = ddlStates;
//	}
	
	if(ddlEstimatedHomeValue.value == "-1")
	{
		retString += "\r\n- Estimated Home Value";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlEstimatedHomeValue;
	}
	
	if(ddlFirstMortgageLender.value == "-1")
	{
		retString += "\r\n- First Mortgage Lender";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlFirstMortgageLender;
	}
	
	if(ddlFirstMortgageBalance.value == "-1")
	{
		retString += "\r\n- First Mortgage Balance";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlFirstMortgageBalance;
	}
	
	if(ddlFirstMortgageInterestRate.value == "-1")
	{
		retString += "\r\n- First Mortgage Interest Rate";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlFirstMortgageInterestRate;
	}
	
	if(ddlMonthsBehindPayment.value == "-1")
	{
		retString += "\r\n- Months Behind Payment";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlMonthsBehindPayment;
	}
	
	if(rbHasSecondMortgageYes.checked)
	{
		if(ddlSecondMortgageInterestRate.value == "-1")
		{
			retString += "\r\n- Second Mortgage Interest Rate";
			hasError = true;
			
			if (focusedObj == null)
		        focusedObj = ddlSecondMortgageInterestRate;
		}
		
		if(ddlSecondMortgageBalance.value == "-1")
		{
			retString += "\r\n- Second Mortgage Balance";
			hasError = true;
			
			if (focusedObj == null)
		        focusedObj = ddlSecondMortgageBalance;
		}
	}
	
	if(lbExistingTypeOfRate.value == "")
	{
		retString += "\r\n- Existing Type of Rate";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = lbExistingTypeOfRate;
	}
	
	if(ddlGrossAnnualIncome.value == "-1")
	{
		retString += "\r\n- Gross Annual Income";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlGrossAnnualIncome;
	}
	
//	if(txtEmail.value == "")
//	{
//		retString += "\r\n- Email";
//		hasError = true;
//		
//		if (focusedObj == null)
//		    focusedObj = txtEmail;
//	}
	
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
	
	
	if (txtPropertyZipCode.value.length != 5 || !isNumeric(txtPropertyZipCode.value))
	{
		alert('Please enter valid ZIP code (5 numeric characters)');
		txtPropertyZipCode.focus();
		return false;
	}
	

//	emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//	if(!txtEmail.value.match(emailRegex))
//	{
//		alert('Please enter valid email address');
//		txtEmail.focus();
//		return false;
//	}
//	
//	if (!chkAccept.checked)
//	{
//		alert('You must accept Debt Watch Privacy and Security policies to continue');
//		return false;
//	}
	
	
	return true;
}





function ValidateMortgagePersonalForm() {
    var ddlMonthlyMortgagePayment = GetServerElement("ddlMonthlyMortgagePayment", "SELECT");
	var txtFirstName			= GetServerElement("txtFirstName", "INPUT");
	var txtLastName				= GetServerElement("txtLastName", "INPUT");
	var txtAddress				= GetServerElement("txtAddress", "INPUT");
	var txtCity					= GetServerElement("txtCity", "INPUT");
	var ddlCity					= GetServerElement("ddlCity", "SELECT");
	var txtZipCode              = GetServerElement("txtZipCode", "INPUT");
	//var txtHomePhone			= GetServerElement("txtHomePhone", "INPUT");
	var txtPhone1               = GetServerElement("txtPhone1", "INPUT");
    var txtPhone2               = GetServerElement("txtPhone2", "INPUT");
    var txtPhone3               = GetServerElement("txtPhone3", "INPUT");
    var txtHomePhone            = txtPhone1.value+txtPhone2.value+txtPhone3.value;
	var txtHomePhoneExt			= GetServerElement("txtPhone4", "INPUT");
	//var txtWorkPhone			= GetServerElement("txtWorkPhone", "INPUT");
	var txtPhoneAlternate1      = GetServerElement("txtPhoneAlternate1", "INPUT");
    var txtPhoneAlternate2      = GetServerElement("txtPhoneAlternate2", "INPUT");
    var txtPhoneAlternate3      = GetServerElement("txtPhoneAlternate3", "INPUT");
    var txtWorkPhone            = txtPhoneAlternate1.value+txtPhoneAlternate2.value+txtPhoneAlternate3.value;
	var txtWorkPhoneExt			= GetServerElement("txtPhoneAlternate4", "INPUT");
	//var txtComments			= GetServerElement("txtComments", "INPUT");
	var txtEmail				= GetServerElement("txtEmail", "INPUT");
	var chkAccept				= GetServerElement("chkAccept", "INPUT");
	
	var retString = "Please insert: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
	
	try
	{
	    if(ddlMonthlyMortgagePayment.value == "-1")
	    {
		    retString += "\r\n- Monthly Mortgage Payment";
		    hasError = true;
    		
		    if (focusedObj == null)
		        focusedObj = ddlMonthlyMortgagePayment;
	    }
	}
	catch (exc)
	{}
	
	
	if(txtFirstName.value == "")
	{
		retString += "\r\n- First Name";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtFirstName;
	}
	
	if(txtLastName.value == "")
	{
		retString += "\r\n- Last Name";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtLastName;
	}
	
	if(txtAddress.value == "")
	{
		retString += "\r\n- Mailing Address";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtAddress;
	}
	
	try
	{
	    if(txtCity.value == "")
	    {
		    retString += "\r\n- City";
		    hasError = true;
		    
		    if (focusedObj == null)
		        focusedObj = txtCity;
	    }
	}
	catch (e){}
	
	if(txtZipCode == "")
	{
	    retString += "\r\n- ZIP";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtZipCode;
	}
	
	
	//var txtHomePhoneValue = txtHomePhone.value;
	var txtHomePhoneValue = txtHomePhone;
	
	txtHomePhoneValue = txtHomePhoneValue.replace("(", "");
	txtHomePhoneValue = txtHomePhoneValue.replace(")", "");
	txtHomePhoneValue = txtHomePhoneValue.replace(/ /g, "");
	txtHomePhoneValue = txtHomePhoneValue.replace(/-/g, "");
	txtHomePhoneValue = txtHomePhoneValue.replace(/_/g, "");

	//var txtWorkPhoneValue = txtWorkPhone.value;
	var txtWorkPhoneValue = txtWorkPhone;
	
	txtWorkPhoneValue = txtWorkPhoneValue.replace("(", "");
	txtWorkPhoneValue = txtWorkPhoneValue.replace(")", "");
	txtWorkPhoneValue = txtWorkPhoneValue.replace(/ /g, "");
	txtWorkPhoneValue = txtWorkPhoneValue.replace(/-/g, "");
	txtWorkPhoneValue = txtWorkPhoneValue.replace(/_/g, "");
	
	if (txtHomePhoneValue.length > 0 && txtHomePhoneValue.length < 10)
	{
	    retString += "\r\n- Invalid Best Contact Number";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPhone1;
	}
	
	if (txtWorkPhoneValue.length > 0 && txtWorkPhoneValue.length < 10)
	{
	    retString += "\r\n- Invalid Alternate Number";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPhoneAlternate1;
	}
	
	if(txtHomePhoneValue == "" && txtWorkPhoneValue == "")
	{
		retString += "\r\n- Best Contact Number or Alternate Number";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPhone1;
	}
	
	if(txtHomePhoneValue == "" && txtHomePhoneExt.value != "")
	{
		retString += "\r\n- Best Contact Number extension without phone number";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPhone1;
	}
	
	
	if(txtWorkPhoneValue == "" && txtWorkPhoneExt.value != "")
	{
		retString += "\r\n- Alternate Number extension without phone number";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtPhoneAlternate1;
	}
	
	if(txtEmail.value == "")
	{
		retString += "\r\n- Email";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtEmail;
	}
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
	
	
	
	
	if (txtZipCode.value.length != 5 || !isNumeric(txtZipCode.value))
	{
		alert('Please enter valid ZIP code (5 numeric characters)');
		txtZipCode.focus();
		return false;
	}
		
	
	if (!validName (txtFirstName))
	{
       alert ("Invalid characters in first name field or name is too short");
       txtFirstName.focus();
       return false;
    }
    
    if (!validName (txtLastName))
    {
       alert ("Invalid characters in last name field or name is too short");
       txtLastName.focus();
       return false;
    }

    if (!validAddr (txtAddress))
    {
        alert ("Invalid characters in address first line or address is too short");
        txtAddress.focus();
        return false;
    }
    
    if (!haveSpace (txtAddress))
    {
       alert ("Address first line must contain at least one space\nPlease separate street number and street name");
       txtAddress.focus();
       return false;
    }
    
    emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!txtEmail.value.match(emailRegex))
	{
		alert('Please enter valid email address');
		txtEmail.focus();
		return false;
	}
	
	if (!chkAccept.checked)
	{
		alert('You must accept Debt Watch Privacy and Security policies to continue');
		return false;
	}
    
    try
    {
        if (!validName (txtCity))
        {
           alert ("Invalid characters in city field or city name is too short");
           txtCity.focus();
           return false;
        }
    }
	catch (e){}
    
    if(!isNumeric(txtHomePhoneExt.value))
	{
		alert('Please enter valid Best Contact Number extension');
		txtHomePhoneExt.focus();
		return false;
	}
	if(!isNumeric(txtHomePhoneValue))
	{
		alert('Please enter valid Best Contact Number ');
		txtPhone1.focus();
		return false;
	}
	
	if(!isNumeric(txtWorkPhoneValue))
	{
		alert('Please enter valid Alternate Phone ');
		txtPhoneAlternate1.focus();
		return false;
	}
	if(!isNumeric(txtWorkPhoneExt.value))
	{
		alert('Please enter valid Alternate Phone extension');
		txtWorkPhoneExt.focus();
		return false;
	}
//	emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//	if(!txtEmail.value.match(emailRegex))
//	{
//		alert('Please enter valid email address');
//		txtEmail.focus();
//		return false;
//	}
//	
//	if (!chkAccept.checked)
//	{
//		alert('You must accept Debt Watch Privacy and Security policies to continue');
//		return false;
//	}
	return true;
}



function ValidateMortgageMoreAboutForm()
{
	var txtCurLivingDuration	= GetServerElement("txtCurLivingDuration", "INPUT");
	var txtCurJobDuration		= GetServerElement("txtCurJobDuration", "INPUT");
	var txtSSN					= GetServerElement("txtSSN", "INPUT");
	var ddlWhenIsLoanNeeded		= GetServerElement("ddlWhenIsLoanNeeded", "SELECT");
	
	
	var retString = "Please insert: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
	
	
	if(txtCurLivingDuration.value == "")
	{
		retString += "\r\n- How long have you lived at your current residence";
		hasError = true;
		
		
		if (focusedObj == null)
		    focusedObj = txtCurLivingDuration;
	}
	
	if(txtCurJobDuration.value == "")
	{
		retString += "\r\n- How long have you worked at your present job";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtCurJobDuration;
	}
	
	if(txtSSN.value == "")
	{
		retString += "\r\n- Social Secutiry Number";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtSSN;
	}
	
	if(ddlWhenIsLoanNeeded.value == "-1")
	{
		retString += "\r\n- When do you need this loan";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = ddlWhenIsLoanNeeded;
	}
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
	
	
	
	
	if(!isNumeric(txtCurLivingDuration.value))
	{
		alert('Current living field must be numeric value');
		txtCurLivingDuration.focus();
		return false;
	}
	
	
	if(!isNumeric(txtCurJobDuration.value))
	{
		alert('Current job field must be numeric value');
		txtCurJobDuration.focus();
		return false;
	}
	
	
	var txtSSNValue = txtSSN.value;
	txtSSNValue = txtSSNValue.replace(/_/g, "");
	
	ssnRegex = /\d{3}-\d{2}-\d{4}/;
	if(txtSSNValue != "" && !txtSSNValue.match(ssnRegex))
	{
		alert('Please enter valid Social Security Number');
		txtSSN.focus();
		return false;
	}
	
	
	return true;
}


function ValidateContactUsForm()
{
	var txtEmail	= GetServerElement("txtEmail", "INPUT");
	//var ddlSubject	= GetServerElement("ddlSubject", "SELECT");
	var txtContent	= GetServerElement("txtContent", "TEXTAREA");
	
	
	var retString = "Please insert: \r\n";
	var hasError = false;
	
	var focusedObj = null;
	
	if(txtEmail.value == "")
	{
		retString += "\r\n- Your email address";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtEmail;
	}
	
//	if(txtSubject.value == "")
//	{
//		retString += "\r\n- Subject of the email";
//		hasError = true;
//	}
	
	if(txtContent.value == "")
	{
		retString += "\r\n- Content of the email";
		hasError = true;
		
		if (focusedObj == null)
		    focusedObj = txtContent;
	}
	
	
	if(hasError)
	{
		alert(retString);
		
		if (focusedObj != null)
		    focusedObj.focus();
		
		return false;
	}
	
	
	
	emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!txtEmail.value.match(emailRegex))
	{
		alert('Please enter valid email address');
		txtEmail.focus();
		return false;
	}
}


function ValidateLatestMortgageLoans()
{
    var txtZipCode				= GetServerElement("txtZipCode", "INPUT");


    if (txtZipCode.value.length != 5)
	{
		alert('Please enter valid ZIP code (5 numeric characters)');
		txtZipCode.focus();
		return false;
	}
}


function ValidateSignInForm()
{
    var txtFirstName			= GetServerElement("txtFirstName", "INPUT");
	var txtLastName				= GetServerElement("txtLastName", "INPUT");
	var txtAddress				= GetServerElement("txtAddress", "INPUT");
    var txtCity 				= GetServerElement("txtCity", "INPUT");
    var ddlStates 				= GetServerElement("ddlStates", "SELECT");
    var txtZipCode				= GetServerElement("txtZipCode", "INPUT");
//    var txtHomePhone    		= GetServerElement("txtHomePhone", "INPUT");
//    var txtHomePhoneExt			= GetServerElement("txtHomePhoneExt", "INPUT");
    var txtPhone1               = GetServerElement("txtPhone1", "INPUT");
    var txtPhone2               = GetServerElement("txtPhone2", "INPUT");
    var txtPhone3               = GetServerElement("txtPhone3", "INPUT");
    var txtHomePhone            = txtPhone1.value+txtPhone2.value+txtPhone3.value;
	var txtHomePhoneExt			= GetServerElement("txtPhone4", "INPUT");
	
//    var txtFaxNumber			= GetServerElement("txtFaxNumber", "INPUT");
    var txtPhoneAlternate1      = GetServerElement("txtPhoneAlternate1", "INPUT");
    var txtPhoneAlternate2      = GetServerElement("txtPhoneAlternate2", "INPUT");
    var txtPhoneAlternate3      = GetServerElement("txtPhoneAlternate3", "INPUT");
    var txtFaxNumber            = txtPhoneAlternate1.value+txtPhoneAlternate2.value+txtPhoneAlternate3.value;
    
    var txtEmail    			= GetServerElement("txtEmail", "INPUT");
    

    var ddlTimeDiff 			= GetServerElement("ddlTimeDiff", "SELECT");
    var ddlBussinessType		= GetServerElement("ddlBussinessType", "SELECT");
    
    var txtLicenseNo            =  GetServerElement("txtLicenseNo", "INPUT");
    
    var txtPassword             =  GetServerElement("txtPassword", "INPUT");
    var txtRepeatPassword       =  GetServerElement("txtRepeatPassword", "INPUT");
    
    var txtCode                 = GetServerElement("txtCode", "INPUT");
    
    var chkAgree                =  GetServerElement("chkAgree", "INPUT");
    
    
    var retString = "Please insert: \r\n";
	var hasError = false;
	
	if(txtFirstName.value == "")
	{
		retString += "\r\n- First Name";
		hasError = true;
	}
	
	if(txtLastName.value == "")
	{
		retString += "\r\n- Last Name";
		hasError = true;
	}
	
	if(txtAddress.value == "")
	{
		retString += "\r\n- Address";
		hasError = true;
	}
	
	
	if(txtCity.value == "")
	{
		retString += "\r\n- City";
		hasError = true;
	}
	
	
	if(ddlStates.value == "-1")
	{
		retString += "\r\n- State";
		hasError = true;
	}
	
	
	if(txtZipCode.value == "")
	{
	    retString += "\r\n- ZIP code";
		hasError = true;
	}
	

    	
	
	
	//var txtHomePhoneValue = txtHomePhone.value;
	var txtHomePhoneValue = txtHomePhone;
	
	txtHomePhoneValue = txtHomePhoneValue.replace("(", "");
	txtHomePhoneValue = txtHomePhoneValue.replace(")", "");
	txtHomePhoneValue = txtHomePhoneValue.replace(/ /g, "");
	txtHomePhoneValue = txtHomePhoneValue.replace(/-/g, "");
	txtHomePhoneValue = txtHomePhoneValue.replace(/_/g, "");

	//var txtFaxNumberValue = txtFaxNumber.value;
	var txtFaxNumberValue = txtFaxNumber;
	
	txtFaxNumberValue = txtFaxNumberValue.replace("(", "");
	txtFaxNumberValue = txtFaxNumberValue.replace(")", "");
	txtFaxNumberValue = txtFaxNumberValue.replace(/ /g, "");
	txtFaxNumberValue = txtFaxNumberValue.replace(/-/g, "");
	txtFaxNumberValue = txtFaxNumberValue.replace(/_/g, "");
	
	if(txtHomePhoneValue == "")
	{
		retString += "\r\n- Home Phone";
		hasError = true;
	}
	
	if(txtHomePhoneValue == "" && txtHomePhoneExt.value != "")
	{
		retString += "\r\n- Home Phone extension without phone number";
		hasError = true;
	}
	if (txtHomePhoneValue.length > 0 && txtHomePhoneValue.length < 10)
	{
	    retString += "\r\n- Invalid Home Phone Number";
		hasError = true;
		txtPhone1.focus();
	}
	
	if (txtFaxNumberValue.length > 0 && txtFaxNumberValue.length < 10)
	{
	    retString += "\r\n- Invalid Fax Number";
		hasError = true;
		txtPhoneAlternate1.focus();
	}
	
	if(txtHomePhoneValue == "" && txtFaxNumberValue == "")
	{
		retString += "\r\n- Home Phone Number or Fax Number";
		hasError = true;
        txtPhone1.focus();
	}
	
	if(txtHomePhoneValue == "" && txtHomePhoneExt.value != "")
	{
		retString += "\r\n- Home Phone Number extension without phone number";
		hasError = true;
        txtPhone1.focus();
	}
		
	if(txtEmail.value == "")
	{
	    retString += "\r\n- Email";
		hasError = true;
	}
	
	
	if(txtPassword.value == "")
	{
	    retString += "\r\n- Password"
	    hasError = true;
	}
	
	if(txtCode.value == "")
	{
	    retString += "\r\n- Confirmation Code";
	    hasError = true;
	}
	
	if(hasError)
	{
		alert(retString);
		return false;
	}



    if (txtZipCode.value.length != 5 || !isNumeric(txtZipCode.value))
	{
		alert('Please enter valid ZIP code (5 numeric characters)');
		txtZipCode.focus();
		return false;
	}
	
	if(!isNumeric(txtHomePhoneExt.value))
	{
		alert('Please enter valid Best Contact Number extension');
		txtHomePhoneExt.focus();
		return false;
	}
	
	
	emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!txtEmail.value.match(emailRegex))
	{
		alert('Please enter valid email address');
		txtEmail.focus();
		return false;
	}
	
	if(txtPassword.value != txtRepeatPassword.value)
	{
	    alert('Confirm password does not match');
	    return false;
	}
	
	
    if(!isNumeric(txtHomePhoneExt.value))
	{
		alert('Please enter valid Home Phone Number extension');
		txtHomePhoneExt.focus();
		return false;
	}
	if(!isNumeric(txtHomePhoneValue))
	{
		alert('Please enter valid Home Phone Number Number ');
		txtPhone1.focus();
		return false;
	}
	
	if(!isNumeric(txtFaxNumberValue))
	{
		alert('Please enter valid Fax Number Phone ');
		txtPhoneAlternate1.focus();
		return false;
	}
	
	if (!validName (txtFirstName))
	{
       alert ("Invalid characters in first name field or name is too short");
       txtFirstName.focus();
       return false;
    }
    
    if (!validName (txtLastName))
    {
       alert ("Invalid characters in last name field or name is too short");
       txtLastName.focus();
       return false;
    }

    if (!validAddr (txtAddress))
    {
        alert ("Invalid characters in address first line or address is too short");
        txtAddress.focus();
        return false;
    }
    
    if (!haveSpace (txtAddress))
    {
       alert ("Address first line must contain at least one space\nPlease separate street number and street name");
       txtAddress.focus();
       return false;
    }
    
    
    if (!validName (txtCity))
    {
       alert ("Invalid characters in city field or city name is too short");
       txtCity.focus();
       return false;
    }
		
	
	
	if (!chkAgree.checked)
	{
		alert('You must accept Debt Watch terms and Services to continue');
		return false;
	}	
	return true;
}