function getParams() {
   var params = new Object();
   var query = location.search.substring(1);
   var pairs = query.split("&");
   for (var i = 0; i < pairs.length; i++) {
      var pos = pairs[i].indexOf('=');
      if (pos == -1)
         return true;
      var paramName = pairs[i].substring(0,pos);
      var value = pairs[i].substring(pos+1);
      params[paramName] = value;
   }
   return params;
}
function toTwoDigits(strPass) {
   if (strPass < 10) {
      strPass = strPass.toString();
      strPass = "0" + strPass;
   } else {
      strPass = strPass.toString();
   }
   return strPass;
}

function bookNowSrc(srcPass, targetForm) {
   setReferrer(srcPass);
   targetForm.submit();
   return true;
}

function setReferrer(srcPass) {
   var srcCode = 0;
   var params = getParams();

   if (!params.src && !srcPass) {
      return true;
   }

   if (srcPass) {
      srcCode = srcPass;
   } else {
      srcCode = params.src;
   }

   var monthArray = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
   
   var expireTime = new Date();
   var theTime = new Date();   
   //var timeStamp = theTime.toGMTString();
   
   var theYear = theTime.getUTCFullYear();
   theYear = theYear.toString();   
   theYear = theYear.substring(2,4);
   var theMonth = theTime.getUTCMonth();
   theMonth = monthArray[theMonth];
   var theDay = theTime.getUTCDate();
   theDay = toTwoDigits(theDay);
   var theHours = theTime.getUTCHours();
   theHours = toTwoDigits(theHours);
   var theMinutes = theTime.getUTCMinutes();
   theMinutes = toTwoDigits(theMinutes);
   var theSeconds = theTime.getUTCSeconds();
   theSeconds = toTwoDigits(theSeconds);
   var timeStamp = theDay + "-" + theMonth + "-" + theYear + " " + theHours + ":" + theMinutes + ":" + theSeconds  
  
   //expireTime.setTime(expireTime.getTime() + 604800000);
   expireTime.setTime(expireTime.getTime() + 2419200000);
   
   var tempReferrer = document.referrer.substr(0,4);
   tempReferrer = tempReferrer.toLowerCase();   
   if (tempReferrer == "http") {
      var validReferrer = document.referrer;
   } else {
      var validReferrer = "";
   }
    var cookieDomain;
   
   if (document.domain == "www.southwest.com" || document.domain == "southwest.com")
   {
      cookieDomain = "southwest.com";
   }
   else if (document.domain == "www.swabiz.com" || document.domain == "swabiz.com")
   {
      cookieDomain = "swabiz.com";
   }
   else
   {
      cookieDomain = document.domain;
   }
   
   var cookieName = "referrer"
   var cookieValue = "&src=" + srcCode +
                     "&url=" + validReferrer +
                     "&date=" + timeStamp;
   document.cookie = cookieName + "=" + escape(cookieValue)
                                + ";path=/"
                                + ";domain=" + cookieDomain
                                + ";expires=" + expireTime.toGMTString();
   return true;
}
function redirectURL(url) {
   location.replace(url);
   return true;
}