// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

$(document).ready(function(){
  
  if(window.location.hash == "#1"){
    $("#product_id").val('1');
  }else if(window.location.hash == "#2"){
    $("#product_id").val('2');
  }

  $("#transaction_country").val('France')

  $("#affiliate_help_icon").show().click(function(){ $("#affiliate_help").slideToggle() });
  $("#affiliate_help").hide();

  function SetCookie(cookieName,cookieValue,nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays==null || nDays==0) nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = cookieName+"="+escape(cookieValue)
    + ";expires="+expire.toGMTString()+";path=/";
  }
  
  function gup(name){
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
      return "";
    else
      return results[1];
  }

  if(/partenaire/.test(window.location.href) && !(/partner/.test(document.cookie))){
    // implementation en cours 
  }

  if(/partenaire/.test(window.location.href)){
    // track les ventes générées par le partenaire
    SetCookie("partner",gup("partenaire"),30);
  }
  
});

