function ExitRate(){}
ExitRate.prototype.loantype='';ExitRate.prototype.loanamount='';ExitRate.prototype.zipcode='';ExitRate.prototype.state='';ExitRate.prototype.ltv='';ExitRate.prototype.credit='';ExitRate.prototype.newwindowmessage='No time to fill out a form? Just click OK to see rates from top lenders.';ExitRate.prototype.samewindowmessage='No time to fill out a form? Just click OK to see rates from top lenders.';ExitRate.prototype.status='qsExitRate';ExitRate.prototype.idletimelimit=60000;ExitRate.prototype.toggle=1;ExitRate.prototype.pageoverride=[];ExitRate.prototype.newwindow=false;ExitRate.prototype.userstayed=false;ExitRate.prototype.locationchanged=false;ExitRate.prototype.newwindowproperties='width=800,height=600,top=10,left=10,screenX=0,screenY=10';ExitRate.prototype.targetpage={'mortgagerates':{'url':'/'},'homefinance':{'url':'/'}};ExitRate.prototype.valuemap={};ExitRate.prototype.loadinterval=null;ExitRate.prototype.idletimer=null;ExitRate.prototype.resetTimer=function(){};ExitRate.prototype.setCookie=function(name,value,days){if(name==null){name=this.status;}
if(value==null){value=0;}
if(days==null){days=1;}
var expiry=new Date();expiry.setTime(expiry.getTime()+(days*24*60*60*1000));document.cookie=name+'='+value+';expires='+expiry.toGMTString()+';path=/';};ExitRate.prototype.getCookie=function(name){if(!(typeof name=='string')){return null;}
var allcookies=document.cookie.split(';');var cookiename=name+'=';for(var i=0;i<allcookies.length;i++){var c=allcookies[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(cookiename)==0){return c.substring(cookiename.length,c.length);}}
return null;};ExitRate.prototype.delCookie=function(name){this.setCookie(name,null,-1);};ExitRate.prototype.enableRate=function(){this.toggle=1;};ExitRate.prototype.disableRate=function(){this.toggle=0;};ExitRate.prototype.showNewWindow=function(){if(this.newwindow){window.clearTimeout(this.idletimer);var status=this.getCookie(this.status);if(status!='0'){this.setCookie(this.status,1,1);if(confirm(this.newwindowmessage)){var pageurl=this.targetUrl();var xratewin=window.open(pageurl,'xRatePage',this.newwindowproperties);xratewin.focus();}}}
else{if(confirm(this.samewindowmessage)){this.showSameWindow();}}};ExitRate.prototype.showSameWindow=function(){window.clearTimeout(this.idletimer);var status=this.getCookie(this.status);var toggle=this.toggle;var n=this.pageoverride.length;for(var i=0;i<n;i++){$(this.pageoverride[i]).mousedown(function(){toggle=0;});$(this.pageoverride[i]).keydown(function(){toggle=0;});}
if(status!='0'){if(this.locationchanged==false){this.loadinterval=window.setInterval('xrate.changeLocation()',500);this.userstayed=true;return this.samewindowmessage;}}};ExitRate.prototype.changeLocation=function(){if(this.userstayed==true){this.locationchanged=true;if(this.loadinterval!=null){window.clearInterval(this.loadinterval);}
var pageurl=this.targetUrl();window.top.location=pageurl;}};ExitRate.prototype.targetUrl=function(){var vloan=this.loantype;var vcredit=this.credit;var vstate=this.state;var vamount=parseInt(this.loanamount);var vltv=parseFloat(this.ltv);var vzipcode=this.zipcode;var page=this.targetpage.mortgagerates.url;var isNotRateTable=false;var params='?';if(vloan){if(this.valuemap.loantype){vloan=this.valuemap.loantype[vloan];if(typeof vloan=='undefined'){vloan='2';}}else{vloan='2';}}else{vloan='2';}
if(this.valuemap.credit){if(vcredit){vcredit=this.valuemap.credit[vcredit];if(typeof vcredit=='undefined'){vcredit='';}}else{vcredit='';}}
if(isNaN(vamount)){vamount=200000;}
if(vamount<100000){isNotRateTable=true;}
if(isNaN(vltv)){vltv='';}else{if((vltv>80)&&(vloan=='2')){isNotRateTable=true;}
if((vltv>95)&&(vloan=='1')){isNotRateTable=true;}}
if((vcredit!='')&&(vcredit!='Excellent')&&(vcredit!='Good')){isNotRateTable=true;}
if(isNotRateTable){page=this.targetpage.homefinance.url;}
params+='loantype='+vloan+'&';params+='zipcode='+vzipcode+'&';params+='statecode='+vstate+'&';params+="loanamount="+vamount;return page+params;};
