String.prototype.trim = function(){
return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))
}

String.prototype.startsWith = function(str){
return (this.match("^"+str)==str)
}

String.prototype.endsWith = function(str){
return (this.match(str+"$")==str)
}

function STMRCWindow(page, sHeight, swidth) {
	if (swidth && sHeight) {
		window.open(page, "CtrlWindow", ",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,dependent=no,directories=no,width="+swidth+",height="+sHeight+",x=50,y=50");
	}
	else { 
		window.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,dependent=no,directories=no,width=455,height=540,x=50,y=50");
	}
}	
function getObject(id) {
	var object = null;
	if( document.getElementById ) {
		object = document.getElementById(id);
	}		
	else if( document.layers ) {   
		object = document.layers[id];
	}
	else if( document.all ) {
		object = document.all[id];
	}
	return object;
}	

function getValue(id){
	var obj = getObject(id);
	if(obj){
		return obj.value;
	}	
	return "";
}

function validForm(form){
	var loan  = getValue("q1");
	var state = getValue("q2");
	var statecheck = false;
	
	
	if(state == "il" || state == "la" || state == "ky" ||
		state == "nc" || state == "ut"){
		statecheck = true;
	}	
	
	if(statecheck){
		var arg1 = "2";			  
		if(loan=="Signed purchase agreement"){
			arg1 = "1";
		}
		form.action = "http://www.tkqlhce.com/interactive?AID=10432840&PID=1801669&url=http://www.lendingtree.com/alliance/from.asp&SID=MO&"
+"TYPE_CONST="+arg1+"&V2PROP_CONST=30&CREDIT_HISTORY_DESCRIPTION_BO_CONST=2";	
	}
	else{	
		if(loan == "refinance2"){
			loan = "refinance";
		}
		form.action = "http://affiliates.quickenloans.com/z/8/CD6/&referral_api"+"&state="+state+"&purpose="+loan;		
	}
	
	return true;
}

function validForm2(){
	var form = document.lpForm;

	var loan  = getValue("q1");
	var state = getValue("q2");
	var statecheck = false;
	
	
	if(state == "il" || state == "la" || state == "ky" ||
		state == "nc" || state == "ut"){
		statecheck = true;
	}	
	
	if(statecheck){
		var arg1 = "2";			  
		if(loan=="Signed purchase agreement"){
			arg1 = "1";
		}
		document.lpForm2.TYPE_CONST.value=arg1;		
		document.lpForm2.submit();
		return false;
	}
	else{	
		if(loan == "refinance2"){
			loan = "refinance";
		}
		form.arg1.value = loan;
		form.arg2.value = state;
		form.submit();
	}	
	
	return true;
}