function PageQuery(q) {
  if(q.length > 1) this.q = q.substring(1, q.length);
  else this.q = null;
  this.keyValuePairs = new Array();
  if(q) {
    for(var i=0; i < this.q.split("&").length; i++) {
      this.keyValuePairs[i] = this.q.split("&")[i];
    }
  }
  this.getKeyValuePairs = function() { return
this.keyValuePairs; }
  this.getValue = function(s) {
    for(var j=0; j < this.keyValuePairs.length; j++) {
      if(this.keyValuePairs[j].split("=")[0] == s) {
        if(this.keyValuePairs[j].split("=").length>1)
{
          return this.keyValuePairs[j].split("=")[1];
        }
      }
    }
    return "";
  }
  this.getParameters = function() {
    var a = new Array(this.getLength());
    for(var j=0; j < this.keyValuePairs.length; j++) {
      a[j] = this.keyValuePairs[j].split("=")[0];
    }
    return a;
  }
  this.getLength = function() { return
this.keyValuePairs.length; }
}

function queryString(key){
  var page = new PageQuery(window.location.search);
  return unescape(page.getValue(key));
}

function getLoanTypeHeadline(){
  var prdType = queryString("_4PRD");
  if(prdType == '50fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">50-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '40fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">40-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '30fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">30-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '30fixed_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">30-Year Fixed</span> Loan and Save on Your Mortgage!</span></h1>";
  } else if (prdType == '35fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">35-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '20fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">20-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '15fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">15-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '15fixed_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">15-Year Fixed</span> Loan and Save on Your Mortgage!</h1>";
  } else if (prdType == '10fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">10-Year Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'adjustable') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">Adjustable</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'badCredit') {
    return "<h1>Find New, Low Mortgage Rates for <span class=\"highlighted hilite\">" + DateString() + ". <br />Bad Credit OK!</span></h1>";
  } else if (prdType == 'refinanceCash') {
    return "<h1>Find New, Low Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + "</span>, and get cash for any reason!</span></h1>";
  } else if (prdType == '7arm') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">7-Year ARM</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '7arm_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">7-Year ARM</span> Loan and Save on Your Mortgage!</span></h1>";
  }  else if (prdType == '5arm') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">5-Year ARM</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == '5arm_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">5-Year ARM</span> Loan and Save on Your Mortgage!</span></h1>";
  } else if (prdType == 'debt') {
    return "<h1>Consolidate your debt with the lowest Mortgage Rates for <span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'fixed') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">Fixed</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'goodCredit') {
    return "<h1><span class=\"highlighted\">Get rewarded for your good credit!</span> Find New, Low Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'interest') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">Interest Only</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'interest_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">Interest Only</span> Loan and Save on Your Mortgage!</span></h1>";
  } else if (prdType == 'improvement') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">Home Improvement</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'improvement_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">Home Improvement</span> Loan and Save on Your Mortgage!</span></h1>";
  } else if (prdType == 'equity') {
    return "<h1>Find New, Low <span class=\"highlighted hilite\">Home Equity</span> Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'equity_have') {
    return "<h1>Refinance Your <span class=\"highlighted hilite\">Home Equity</span> Loan and Save on Your Mortgage!</span></h1>";
  } else if (prdType == 'refinanceRates') {
    return "<h1>Find New, Low Mortgage Rates for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
  } else if (prdType == 'fed cut') {
    return "<h1>The Fed Slashed Rate by 75 bps on March 18th! <span class=\"highlighted hilite\">Hurry! Refi Now &amp; Save on your Mortgage.</span></h1>";
  } else if (prdType == 'fedcut') {
    return "<h1>The Fed Slashed Rate by 75 bps on March 18th! <span class=\"highlighted hilite\">Hurry! Refi Now &amp; Save on your Mortgage.</span></h1>";
  } else if (prdType == 'fed_headline') {
    return "<h1>The Fed Slashed Rate by 75 bps on March 18th! <span class=\"highlighted hilite\">Hurry! Refi Now &amp; Save on your Mortgage.</span></h1>";
  } else if (prdType == 'mtg_low') {
    return "<h1>Mortgage Rates hit 2-Year Low! <span class=\"highlighted hilite\">Refinance &amp; Save now</span></h1>";
  }
  var xfyType = queryString("_4XFY");
  if(xfyType == '74') {
    return "Get a $74,569 Loan for $319 a Month!";
              } else if (xfyType == '75') {
                return "<h1>Get a $75,000 Loan for $321 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '85') {
                return "<h1>Get a $85,000 Loan for $289 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '97') {
                return "<h1>Get a $97,500 Loan for $329 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '99') {
                return "<h1>Get a $99,769 Loan for $427 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '100') {
                return "<h1>Get a $100,000 Loan for $429 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '123') {
                return "<h1>Get a $123,995 Loan for $531 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '125') {
                return "<h1>Get a $125,000 Loan for $535 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '145') {
                return "<h1>Get a $145,000 Loan for $479 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '149') {
                return "<h1>Get a $149,799 Loan for $641 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '150') {
                return "<h1>Get a $150,000 Loan for $641 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '157') {
                return "<h1>Get a $157,500 Loan for $521 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '174') {
                return "<h1>Get a $174,675 Loan for $747 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '175') {
                return "<h1>Get a $175,000 Loan for $749 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '180') {
                return "<h1>Get a $180,000 Loan for $599 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '200') {
                return "<h1>Get a $200,000 Loan for $855 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '201') {
                return "<h1>Get a $201,179 Loan for $861 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '205') {
                return "<h1>Get a $205,000 Loan for $679 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '215') {
                return "<h1>Get a $215,000 Loan for $711 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '225') {
                return "<h1>Get a $225,000 Loan for $961 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '249') {
                return "<h1>Get a $249,569 Loan for $1,067 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '250') {
                return "<h1>Get a $250,000 Loan for $1,069 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '255') {
                return "<h1>Get a $255,000 Loan for $841 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '2753') {
                return "<h1>Get a $275,319 Loan for $1,177 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '275') {
                return "<h1>Get a $275,000 Loan for $1,175 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '300') {
                return "<h1>Get a $300,000 Loan for $1,283 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '305') {
                return "<h1>Get a $305,000 Loan for $1,005 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '345') {
                return "<h1>Get a $345,000 Loan for $1,135 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '350') {
                return "<h1>Get a $350,000 Loan for $1,495 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '351') {
                return "<h1>Get a $351,617 Loan for $1,155 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '400') {
                return "<h1>Get a $400,000 Loan for $1,709 a Month!</h1>See below for important rate information.";
              } else if (xfyType == '425') {
    return "<h1>Get a $425,000 Loan for $1,817 a Month!</h1>See below for important rate information.";
  } else {
    return "<h1>Find New, Low <span class=\"highlighted hilite\"> Mortgage Rates</span> for <br /><span class=\"highlighted hilite\">" + DateString() + ".</span></h1>";
 }
   var zipcodeValue = queryString("ZIP4"); {
    return "Find New, Low Mortgage Rates <span class=\"highlighted hilite\">" + zipcodeValue + "</span> for<br /><span class=\"highlighted hilite\">" + DateString() + ".</span>";
  }
}
function divswitcher(target) {
    if (target == 'tab01') {
		document.getElementById('tabcontentNone').style.display = 'none';
	    document.getElementById('side01').style.display = 'block';
		document.getElementById('nav01').className = 'nav01on';
        document.getElementById('side02').style.display = 'none';
		document.getElementById('nav02').className = '';
        document.getElementById('side03').style.display = 'none';
		document.getElementById('nav03').className = '';
        document.getElementById('side04').style.display = 'none';
		document.getElementById('nav04').className = '';
    } else if (target == 'tab02') {
	    document.getElementById('tabcontentNone').style.display = 'none';
        document.getElementById('side01').style.display = 'none';
		document.getElementById('nav01').className = '';
        document.getElementById('side02').style.display = 'block';
		document.getElementById('nav02').className = 'nav02on';
        document.getElementById('side03').style.display = 'none';
		document.getElementById('nav03').className = '';
        document.getElementById('side04').style.display = 'none';
		document.getElementById('nav04').className = '';
    } else if (target == 'tab03') {
	    document.getElementById('tabcontentNone').style.display = 'none';
        document.getElementById('side01').style.display = 'none';
		document.getElementById('nav01').className = '';
        document.getElementById('side02').style.display = 'none';
		document.getElementById('nav02').className = '';
        document.getElementById('side03').style.display = 'block';
		document.getElementById('nav03').className = 'nav03on';
        document.getElementById('side04').style.display = 'none';
		document.getElementById('nav04').className = '';
    } else if (target == 'tab04') {
		document.getElementById('tabcontentNone').style.display = 'none';
        document.getElementById('side01').style.display = 'none';
		document.getElementById('nav01').className = '';
        document.getElementById('side02').style.display = 'none';
		document.getElementById('nav02').className = '';
        document.getElementById('side03').style.display = 'none';
		document.getElementById('nav03').className = '';
        document.getElementById('side04').style.display = 'block';
		document.getElementById('nav04').className = 'nav04on';
    } else if (target == 'tabNone') {
        document.getElementById('tabcontentNone').style.display = 'block';
		document.getElementById('side01').style.display = 'none';
		document.getElementById('nav01').className = '';
        document.getElementById('side02').style.display = 'none';
		document.getElementById('nav02').className = '';
        document.getElementById('side03').style.display = 'none';
		document.getElementById('nav03').className = '';
        document.getElementById('side04').style.display = 'none';
		document.getElementById('nav04').className = '';
    }
}



function GetDay(nDay)
{
	var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
	                     "Thursday","Friday","Saturday");
	return Days[nDay]
}

function GetMonth(nMonth)
{
	var Months = new Array("January","February","March","April","May","June",
	                       "July","August","September","October","November","December");
	return Months[nMonth]
}

function DateString()
{
	var Today = new Date();
	var suffix = "th";
	switch (Today.getDate())
	{
		case 1:
		case 21:
		case 31:
			suffix = "st"; break;
		case 2:
		case 22:
			suffix = "nd"; break;
		case 3:
		case 23:
			suffix = "rd"; break;
	};

	var strDate = GetDay(Today.getDay()) + ", " + GetMonth(Today.getMonth()) + " " + Today.getDate();
	strDate += suffix;
	return strDate
}
