// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var Message = {

  show: function(url) {
    // $('mail-message').innerHTML = url;
    $('mask').show();
    $('mail-message-wrapper').visualEffect('appear', {duration:0.2});
  },

  hide: function() {
    $('mask').hide();
    $('mail-message-wrapper').visualEffect('fade', {duration:0.2});
  },

  currentIndex: function() {
    return this.urls().indexOf($('mail-message').src);
  },

  prev: function() {
    if(this.urls()[this.currentIndex()-1]) {
      this.show(this.urls()[this.currentIndex()-1])
    }
  },

  next: function() {
    if(this.urls()[this.currentIndex()+1]) {
      this.show(this.urls()[this.currentIndex()+1])
    }
  },

  urls: function() {
    if (!this.cached_urls) {
      this.cached_urls = $$('a.show').collect(function(el){
        return el.onclick.toString().match(/".*"/g)[0].replace(/"/g,'');
      });
    }
    return this.cached_urls;
  }

}

var Login = {
  
  hide: function () {
    $('mask').hide();
    $('login-wrapper').visualEffect('fade', {duration:0.2}); 
    },
  
  show: function() {
    // $('mail-message').innerHTML = url;
    $('mask').show();
    $('login-wrapper').visualEffect('appear', {duration:0.2});
  } 
}

