/**
 * JavaScript tip.js
 * @version 1.0
 * @Created: 2011-02-19
 * @Author: Oscar Engström, http://www.engstream.se/
 *
 * Comment to this document:
 * For handling advertisement on site
 */

$(document).ready(function(){
  //Initialize
  performerAd.init();
});

var performerAd = {
  /**
   * Run this function once for initializing and binding
   */
  init: function(){
    $("a.banner").live('click', function(){
      //Capture the click, but let it go where it wants to go
      var tmp = $(this).attr('id');
          tmp = filterString(tmp, 'adID_');
      performerAd.performAddClick(tmp);
    });


  },

  performAddClick: function(adID){
    var data = new Object();
        data.action = 'addClick';
        data.adID = adID;

        var dataString = $.toJSON(data);

        $.post('ajax/advertise.php', {data: dataString}, function(res){
            var obj = $.evalJSON(res);
            if(obj.success == 1){
              //Action was successfully performed
            } else {
              //Action failed
            }
        });
  }
};
