//////////////////////////////////////////////////////////
//
//  File: RCI global javascript file
//  Author: Craig Nelson - Classic Labs
//
  
  // main menu rollovers
  var menuHover = function() {
  	var elements = $$('#nav li');
  	elements.each(function(e) {
  	  e.onmouseover = function() {
  			this.addClassName('hov');
  		}
  		e.onmouseout = function() {
  			this.removeClassName('hov');
  		}
  	});
  }
  if (window.attachEvent) {
    window.attachEvent("onload", menuHover);
  }
  // --main menu rollovers

  // non-clickable and external links
  function setLinks(anchors) {
    anchors.each(function (e) {
      if (e.getAttribute('rel') == 'no-click') {
        e.onclick = function() {
          return false;
        }
      }
      if (e.getAttribute("rel") == "external") {
        e.target = "_blank";
      }
    });
    return;
  }
  // --non-clickable and external links
  
  // slideshows
	function setSlideShow(slides) {
	  var currentSlide = 0;
  	var nextSlide = 1;
  	var slideShow = function () {
  	  if (slides.length === 0) { // does the current page have a slideshow?
  	    return;
  	  }
  	  Effect.Fade(slides[currentSlide], { duration: .5 });
      Effect.Appear(slides[nextSlide], { duration: .5 });
      currentSlide++;
      nextSlide++;
      if (nextSlide == slides.length) {
        nextSlide = 0;
      }
      if (currentSlide == slides.length) {
        currentSlide = 0;
      }
      setTimeout(function () {
        slideShow();
      }, 8000);
  	};
  	return slideShow;
	}
	// --slideshows
	
	// events
  Event.observe(window, "load", function () {
    setLinks($$("a"));
    var slideShow = setSlideShow($$(".slideshow .slide"));
    setTimeout(function () {
      slideShow();
    }, 8000);
  }); // window load
  // --events
