/*
// January 2005
This script reads the query string containing the referring partners id.
The id is appended to a banner link or link so we can track who referred
to this page.

Example:
http://www.paradata.com/vrccp/index.html?ref=myvacationhomes.com
/*


/* 
   This script reads the query string and stores it in a cookie.
   the id is then appended to all links that point to 
   the long sign up form (Couldn't pass a cookie from
   Paradata to Paygateway, so had to write a query string
   to the url of such links.
   
   These links are generated on 
   every page with document.write. See the code for the 
   apply button, and sign up link (in footer)to see
   how it is done.
   
   ** NOTE: Partner pricing is generated dynamically in pricing.js
*/

function parseQueryString (str) {
  str = str ? str : location.search;
  var query = str.charAt(0) == '?' ? str.substring(1) : str;
  var args = new Object();
  if (query) {
    var fields = query.split('&');
    for (var f = 0; f < fields.length; f++) {
      var field = fields[f].split('=');
      args[unescape(field[0].replace(/\+/g, ' '))] = 
unescape(field[1].replace(/\+/g, ' '));
    }
  }
  return args;
}



  function setCookie(name, value, expires, path, domain, secure)
{
	var expiry = new Date ();
    expiry.setTime (expiry.getTime() + (24 * 60 * 60 * 1000 * expires)); 
	
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expiry.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


var args = parseQueryString ();
for (var arg in args) {
  // alert(arg + ': ' + args[arg] + '\n');
    // cookie expires in 90 days.
	setCookie("referring_partner", args[arg],90);
}


