/** Bibliotheksdefinition */
var EtrackerMain = {

  /**
   * Methode fuer EventTracking von Reiternavigation und Klappboxen,
   * Auf- und Zuklappen von Klappboxen wird entsprechend getrackt
   */
  EventTracker: function(cat, obj, action, tag, idContainer) {
    contObj = jQuery("#"+idContainer);
    switcher = "";
    if(jQuery(contObj).hasClass(TsipMainConstants.CSS_CONT_ON)){
      switcher = TsipMainConstants.CSS_CONT_OFF;
    } else if (jQuery(contObj).hasClass(TsipMainConstants.CSS_CONT_OFF)) {
      switcher = TsipMainConstants.CSS_CONT_ON;
    }
    ET_Event.eventStart(cat, obj, action + " " + switcher, tag);
  },

  /**
   * Methode bindet an Events des aktuellen Media-Clips Methoden fuer 
   * das Tracking des Media-Clips.
   * Hinweis: benoetigt Javascripte fuer ETracker-Einbindung und flowplayer
   * 
   * @param {Object} type Art des Medien-Clips audio|video
   * @param {Object} playerID ID des Players(flowplayer)
   */
	MediaEventTracker: function (type, playerID) {
    var flowplayerObj = flowplayer(playerID);
    var clipUrl = flowplayerObj.getClip(0).url; 
    var objs = clipUrl.split("/");
    var fileName = "test" + objs[objs.length-1];
    
    if(type == "audio") {
      flowplayerObj.getClip(0).onStart(function (clip) {
        ET_Event.audioStart(fileName);
      }).onFinish(function (clip) {
        ET_Event.audioStop(fileName);
      }).onPause(function (clip) {
        ET_Event.audioPause(fileName);
      }).onStop(function (clip) {
        ET_Event.audioStop(fileName);
      }).onResume(function (clip) {
        ET_Event.audioStart(fileName);
      });
    }
    if(type == "video") {
      flowplayerObj.onFullscreen(function(){
        ET_Event.videoFullsize(fileName);
      }).getClip(0).onStart(function (clip) {
        ET_Event.videoStart(fileName);
      }).onFinish(function (clip) {
        ET_Event.videoStop(fileName);
      }).onPause(function (clip) {
        ET_Event.videoPause(fileName);
      }).onStop(function (clip) {
        ET_Event.videoStop(fileName);
      }).onResume(function (clip) {
        ET_Event.videoStart(fileName);
      });
    }
  }
}
