/**
 *  students_testimonials.js
 */
window.onload = function ()  {
  LIGHTBOX.initialize();
}

var LIGHTBOX = {
  transition_time: 0.8
  , initialize : function ()
  {
    $("close").hide();
    $("close").removeClassName("hide-me");
    $("close").addClassName("text-overlay");

    // hide anchor to top
    $$(".to-testimonials").each(function(item) {
      item.hide()
    });
    
    // hide individual testimonials
    $$(".testimonial-popup").each(function(item) {
      item.hide()
    });
    
    $$(".thumbnail-link").each(function(item) {
      item.observe('click', LIGHTBOX.showTestimonial);
    });
    
    $("close").observe('click', LIGHTBOX.close);
  }
  
  , close : function (event) {
    $$(".visible").each(function(item) {
      new Effect.Fade(item, { duration: LIGHTBOX.transition_time });
    });
    new Effect.Fade($("close"), { duration: LIGHTBOX.transition_time });
    $("student-testimonials").scrollTo();
    Event.stop(event);
  }

  , showTestimonial : function (event) {
    $$(".testimonial-popup").each(function(item) {
    item.hide()
    });
    var elementid = event.element().identify()
    var testimonial = $(elementid.truncate(elementid.length-6, ''));
    testimonial.addClassName("visible");
    new Effect.Appear(testimonial, { duration: LIGHTBOX.transition_time });
    new Effect.Appear($("close"), { duration: LIGHTBOX.transition_time });
    testimonial.scrollTo();
    Event.stop(event);    
  }
}

