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

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
// Event.observe(window, 'load', externalLinks);

// Based on
// http://srinix.wordpress.com/2007/05/02/tutorial-how-to-make-scriptaculous-based-slideshow/

function SlideShow() {
    Effect.Fade(slides[i], { duration:2, from:1.0, to:0.0 }); 
    i++;
    if (i == slides.length) i = 0; 
    Effect.Appear(slides[i], { duration:2, from:0.0, to:1.0, delay:2 });
}

// the onload event handler that starts the fading. 
function start_slideshow() { 
    getSlideShowImages();
    setInterval('SlideShow()',5000); 
}

function getSlideShowImages() {
    slides = $$('#slideshow-content img');
    $A($R(1, slides.length-1)).each(function(n) {slides[n].hide()});
    $('slideshow-content').style.visibility = 'visible';
}
