

$.extend({
  urlParams: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  urlParam: function(name){
    return $.urlParams()[name];
  }
});

/*
 * Affiliate tracking url params are defined here. You can use any unique
 * param for the affiliate program. Define them in reverse order of precedence.
 * 
 */
function trackAffiliate() {
  var affiliate = $.cookie('softix.affiliate') || "None";
  
  // Add affiliate url params here in reverse order of precedence
  affiliate = $.urlParam('TKTA') || affiliate;
  affiliate = $.urlParam('ref') || affiliate;
  options = { path: '/' }
  
  
  
  $.cookie('softix.affiliate', affiliate, options); 
}
trackAffiliate();
 
