/////////////////////////////////////////////////////////////////

// New Function for redirecting applicant to a particular page //

/////////////////////////////////////////////////////////////////


// This function controls the onUnload function and redirect
var RateVar = 0;
 
function Rates() {
 
if (RateVar == 0) {
 question = confirm("Before you leave, would you like to see today’s best rates without having to fill out our form?");
 if (question != 0) {
  window.location="http://www.lenderquotes.net/rate_results.php?loanPurpose=REFI&la=200000&rp=2";
 }
}
}
// End of onUnload function and redirect

function sendApp(ob) {



	var ob;

	var PortalServiceCode = "";

	var PropertyType = "";

	var CreditRating = "";

	var PropertyState = "";

	var ObjectType = "";

	

	document.AppForm.action = "";

	RateVar=1;

	if (document.getElementById("PortalServiceCode") != null) {

		

		//alert("It's a Radio Button!");

		ObjectType = "R";

		//The following code determines which service was selected - REFI, DEBTCON, HOMEEQ, NEWHOME, REVERSE

		//if the object is a radio button

		ob = document.AppForm.PortalServiceCode;

		for (var i=0;i<ob.length;i++) {

			if (ob[i].checked == true) {

				PortalServiceCode = ob[i].value;

			}

		}

	}

	else {

		

		//alert("It's a DropDown Box!");

		ObjectType = "D";

		//The following code determines which service was selected - REFI, DEBTCON, HOMEEQ, NEWHOME, REVERSE

		//if a drop down box

		ob = document.AppForm.TYPE_CONST;

		for (var i=0;i<ob.options.length;i++) {

			if (ob.options[i].selected == true) {

				PortalServiceCode = ob.options[i].value;

			}

		}

	}



	//The following 1 digit code determines which residence was selected - SFR-0, MFR-1

	ob = document.AppForm.PropertyType;

	for (var i=0;i<ob.options.length;i++) {

		if (ob.options[i].selected == true) {

			PropertyType = ob.options[i].value;

			//switch(PropertyType)  {	//Converts verbage to numeric equivalent

			//	case "SFR":

			//		PropertyType = "0";

			//		break;

			//	case "MFR":

			//		PropertyType = "1";

			//		break;

			//}

		}

	}

		

	

	//The following 1 digit code determines which credit rating was selected - Excellent-0, Good-1, Fair-2, Poor-3

	ob = document.AppForm.CreditRating;

	for (var i=0;i<ob.options.length;i++) {

		if (ob.options[i].selected == true) {

			CreditRating = ob.options[i].value;

			//switch(CreditRating)  {	//Converts verbage to numeric equivalent

			//	case "Excellent":

			//		CreditRating = "0";

			//		break;

			//	case "Good":

			//		CreditRating = "1";

			//		break;

			//	case "Fair":

			//		CreditRating = "2";

			//		break;

			//	case "Poor":

			//		CreditRating = "3";

			//		break;

			//}

		}

	}

	

	

	//In the future you would want all service types to go to your URL for the following states.

	//Comment out the following lines by prefacing them with a double forward slash.  

	//	if (PortalServiceCode == "REFI") {

	//		document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

	//	}

	//	else {

	//  DO NOT COMMENT THIS LINE - document.AppForm.action = "http://www.lenderquotes.net/myapply.php";

	//	}

	

	//The following code determines which state was selected - AL, NJ, etc.

	// QuinStreet requires 2 digit state codes - Select tags must have 2 digit values

	ob = document.AppForm.PropertyState;

	for (var i=0;i<ob.options.length;i++) {

		if (ob.options[i].selected == true) {

			PropertyState = ob.options[i].value;

			PropertyState = PropertyState.substring(2) //Converts 4 digit state code to 2

			switch(PropertyState)  {

				case "DE":

					if (PortalServiceCode == "REVERSE") {

						document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

					}

					else {
						// commented out myapply.php due to probs w/leadpoint website... place "//" on QL and remove from myapply to switch back.
						//document.AppForm.action = "http://www.lenderquotes.net/myapply.php";
						document.AppForm.action = "http://www.lenderquotes.net/bcsp_11.php";

					}

					break;

				case "MD":

					if (PortalServiceCode == "REVERSE") {

						document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

					}

					else {

						//document.AppForm.action = "http://www.lenderquotes.net/myapply.php";
						document.AppForm.action = "http://www.lenderquotes.net/bcsp_11.php";

					}

					break;

				case "NJ":

					if (PortalServiceCode == "REVERSE") {

						document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

					}

					else {

						//document.AppForm.action = "http://www.lenderquotes.net/myapply.php";
						document.AppForm.action = "http://www.lenderquotes.net/bcsp_11.php";

					}

					break;

				case "NY":

					if (PortalServiceCode == "REVERSE") {

						document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

					}

					else {

						//document.AppForm.action = "http://www.lenderquotes.net/myapply.php";
						document.AppForm.action = "http://www.lenderquotes.net/bcsp_11.php";

					}

					break;

				case "PA":

					if (PortalServiceCode == "REVERSE") {

						document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

					}

					else {

						//document.AppForm.action = "http://www.lenderquotes.net/myapply.php";
						document.AppForm.action = "http://www.lenderquotes.net/bcsp_11.php";

					}

					break;

				default:

					if (PortalServiceCode == "REVERSE") {

						document.AppForm.action = "http://www.lenderquotes.net/rmapply.php";

					}

					else {

						//document.AppForm.action = "http://p.puokie.com/cgi/r?;n=203;c=365784;s=4295;x=7936;f=200802131119040;u=j;z=TIMESTAMP;";

						document.AppForm.action = "http://www.lenderquotes.net/bcsp_11.php";

					}

			}

		}

	}

	//The following code redirects all Credit Ratings of "Poor & Fair"
	//who are NOT applying for a Reverse Mortgage to the following URL

	if (PortalServiceCode != "REVERSE") {

		//if (CreditRating == "3" || CreditRating == "4") {
		if (CreditRating == "4") {
			document.AppForm.action = "http://www.lenderquotes.net/bcsp_12.php";
			//http://www.jdoqocy.com/click-2934668-8761298?sid=LQ (quicken loans - FHA Link w/LQ sid)
			//http://affiliates.quickenloans.com/z/3/CD12/&subid1=LQ (quicken loans DT program - FHA Link w/LQ sid)
		}

	}

	

	

	

	

	if (PortalServiceCode == "") {

		if (ObjectType == "D") {

			document.AppForm.TYPE_CONST.focus();

		}

		else {

			document.AppForm.PortalServiceCode.focus();

		}

		alert("Please select a Loan Type");

		return false;

	}

	

	if (PropertyState == "" || PropertyState == "-- Select One --") {

		document.AppForm.PropertyState.focus();

		alert("Please select a Property State");

		return false;

	}

	

	if (PropertyType == "") {

		document.AppForm.PropertyType.focus();

		alert("Please select a Property Type");

		return false;

	}

	

	if (CreditRating == "") {

		document.AppForm.CreditRating.focus();

		alert("Please select a Credit Rating");

		return false;

	}

	

	

	URLaction = document.AppForm.action;

	if (URLaction == "http://www.lenderquotes.net/apply.php") {

		URLaction = URLaction + "?service=" + PortalServiceCode + "&propertyStateCode=" + PropertyState + "&propertyDesc=" + PropertyType + "&credit_rating=" + CreditRating

		document.AppForm.action = URLaction

	}



	//alert(document.AppForm.action);

	

	//alert(PortalServiceCode);

	//alert(PropertyState);

	//alert(PropertyType);

	//alert(CreditRating);

	

	document.AppForm.submit();

}



function ImageSwap(ob,imgsrc) {

	ob.src = imgsrc;

}

/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////