/**
 * Presentation-Animtation utility
 * 
 * @autor Eric Bartels <e.bartels@customsoft.de>
 */
var SWS = {};

/**
 * @constructor
 */
SWS.Presentation = function (locale) {
    this.basePath = window.location.protocol + '//' + window.location.host + '/'; /* + '/sws-gmbh.de/'; <- Param for Testserver */
    this.target = 'presentation.php5';
    this.locale = locale;
}

/**
 * Set the locale for the content
 * 
 * @class Presentation
 */
SWS.Presentation.prototype.setLocale = function (locale) {
    this.locale = locale;
}

/**
 * Initialize the presentation
 * 
 * @class Presentation
 */
SWS.Presentation.prototype.init = function () {
    this._call ();
}

/**
 * @class Presentation
 */
SWS.Presentation.prototype._call = function () {
    var me = this;
    var req = new Ajax.Updater (
      'presentationTarget',
      me.basePath + 'presentation/' + me.target,
      {
          onLoading: function (req, json) {
              YAHOO.util.Dom.setStyle ('loadingIndicator', 'display', 'block');
          },
          onComplete: function (req, json) {
              YAHOO.util.Dom.setStyle ('loadingIndicator', 'display', 'none');
              me._onDataComplete (req, json);
          },
          method: 'get',
          parameters: "locale=" + me.locale
      }
    );
}

/**
 * Loading is complete
 * 
 * @class Presentation
 */
SWS.Presentation.prototype._onDataComplete = function (req, json) {
    $('loadingIndicator').style.display = 'none';
    YAHOO.util.Dom.setStyle ('presentationItem', 'opacity', 0);
    YAHOO.util.Dom.setStyle ('presentationItem', 'display', 'block');
    
    var anim = new YAHOO.util.Anim ('presentationItem',
       {
           opacity: { to: 1 }
       });
    anim.duration = 2;
    anim.method = YAHOO.util.Easing.easeOut; 
    anim.animate ();
}
var presentation = new SWS.Presentation (Locale);
YAHOO.util.Event.addListener(window, 'load',
function ()
{
 presentation.init();
},
false);
