/**
 *  Tracking Sm360
 *  Author : Antoine Brault
 *  Version: 1.0
 */
(function($){
  var options = {
    context : ''
  };

  var methods = {
    init : function( o ) {
        options = $.extend({}, options, o || {});
    },
    trackCurrentPage : function() {
        methods.trackPage(document.location, document.referrer);
    },
    trackPage : function(url, referer) {
        url = encodeURIComponent(url);
        referer = encodeURIComponent(referer);
        new Image().src = options.context + '/tr.gif?url='+url+"&ref="+referer+"&d="+new Date().getTime();
    }
  };

  $.trSm360 =  function( method ) {
    // Method calling logic
    if ( methods[method] ) {
      return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
    } else if ( typeof method === 'object' || ! method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error( 'Method ' +  method + ' does not exist on jQuery.trSm360' );
    }
  };
})( jQuery );

