
  /**
        application's common javascript file
  */

  /**

    Mad Rabbit CMS - PHP Templated Website Content Management System
    (c) copyright july 2008 Raphaël SEBAN.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  */


  // OOP object
  function RfiSWFRoller(divid, width, height, list) {

    // member inits
    this.divid = '#' + String(divid);
    this.width = String(width);
    this.height = String(height);
    this.list = list;
    this.index = 0;

    // method def
    this.rotate = function() {

       // inits
      var _html = '<object type="application/x-shockwave-flash" data="%uri%" style="width: %width%px; height: %height%px; margin: 0; padding: 0;"><param name="movie" value="%uri%" /></object>';
      var _uri = '/cms/pub/share/images/publicite/' + String(this.list[this.index]);

      // update index counter
      this.index = ++this.index % this.list.length;
   
      // set swf movie params
      _html = _html.replace(/%width%/ig, this.width);
      _html = _html.replace(/%height%/ig, this.height);
      _html = _html.replace(/%uri%/ig, _uri);

      // update attributes
      $(this.divid).html(_html);

    };

    // instantiate object
    return this;

  } // end function



  function rfi_set_video(code, caller, noautoplay) {

    // inits
    var _uri = 'http://www.dailymotion.com/swf/%s&amp;hideInfos=1&amp;' + (noautoplay ? 'related=0' : 'autoPlay=1');
    var _content = '<object type="application/x-shockwave-flash" data="' + _uri + '"><param name="movie" value="' + _uri + '" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /></object>';

    // set new video
    _content = _content.replace(/%s/g, code);

    // reset content
    $('#dm_box').attr('innerHTML', _content);
    
    // set visible
    $('#dm_box').css('visibility', 'visible');

    // got a caller?
    if(caller) {
      // set href
      caller.href = '#';
      // mouse click event validation
      return true;
    }

    // mouse click event validation
    return false;

  } // end function


  function rfi_set_audio(playerId, filePath, caller) {

    // inits
    var _player = '#' + (playerId ? String(playerId) : 'dewplayer');
    var _uri = '/cms/usr/inc/dewplayer.swf?mp3=%s&amp;showtime=1';
    var _content = '<object type="application/x-shockwave-flash" data="' + _uri + '" style="width: 240px; height: 20px; vertical-align: middle; margin: 0; padding: 0;"><param name="movie" value="' + _uri + '" /><param name="allowScriptAccess" value="always" /></object>';

    // set new video
    _content = _content.replace(/%s/g, filePath);

    // reset content
    $(_player).attr('innerHTML', _content);
    
    // set visible
    $(_player).css('visibility', 'visible');

    // got a caller?
    if(caller) {
      // set href
      caller.href = '#';
      // mouse click event validation
      return true;
    }

    // mouse click event validation
    return false;

  } // end function



