/*
  Simple slideshow using prototype and scriptaculous.
  
  Usage:
  
    <script src="prototype.js"></script>
    <script src="effects.js"></script>
    <script src="slideshow.js"></script>
    <style type="text/css">
      #slideshow { position: relative; width: 100px; height: 100px; }
      #slideshow div { position: absolute; left: 0; top: 0; }
    </style>
    <div class="slideshow" id="slideshow">
      <div class="slide"><img src="slide1.jpg"></div>
      <div class="slide"><img src="slide2.jpg"></div>
      <div class="slide"><img src="slide3.jpg"></div>
    </div>
    <script type="text/javascript">new Slideshow('slideshow', 3000);</script>
  
  See also: http://blog.remvee.net/post/17
  
  Copyright (c) 2006 - R.W. van 't Veer
  sliding text added by Quikbook.com
*/

function Slideshow(slideshow, timeout) {
  this.slides = [];
  var nl = $(slideshow).getElementsByTagName('div');
  for (var i = 0; i < nl.length; i++) {
    if (Element.hasClassName(nl[i], 'slide')) {
      this.slides.push(nl[i]);
    }
  }
  this.timeout = timeout;
  this.current = 0;
  this.flag = 0;



  
  for (var i = 0; i < this.slides.length; i++) {
    this.slides[i].style.zIndex = this.slides.length - i;
	this.slides[i].style.visibility = "visible";
  }

  Element.show(slideshow);
  setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
}
Slideshow.prototype = {
  next: function() {
    for (var i = 0; i < this.slides.length; i++) {
      var slide = this.slides[(this.current + i) % this.slides.length];
      slide.style.zIndex = this.slides.length - i;
    }

    Effect.Fade(this.slides[this.current], {
      afterFinish: function(effect) {
        effect.element.style.zIndex = 0;
        Element.show(effect.element);
        Element.setOpacity(effect.element, 1);
      }
    });

/*new stuff 091508 */

if (0 == this.flag) {   
	
	
	  var sliding = document.getElementsByClassName('slidingtextcontainer');
  
/*new stuff   */
 
 var slidingtext_msg = new Array("Pittcon’s Headquarter Hotel, the Peabody Orlando. Rates as low as $229!");
 
  var slidingtext = document.getElementsByClassName('slidingtext');
  var newNode = document.createElement("p");
  var newTextNode = document.createTextNode(slidingtext_msg[this.current]);
  newNode.appendChild(newTextNode);
  slidingtext[0].replaceChild(newNode,slidingtext[0].firstChild);
  
  var startmargin = -420;
  var endmargin = -10;
  var actStep = 0;
  var steps = 19;
  
  sliding[0].currentMargin = startmargin;
  
  
   if (sliding[0].marginChangeMemInt)
	{window.clearInterval(sliding[0].marginChangeMemInt);}
    
    sliding[0].marginChangeMemInt = window.setInterval(
	function() { 
	  sliding[0].currentMargin += 20;
	  sliding[0].style.marginLeft = sliding[0].currentMargin + "px"; 
	  actStep++;
	  if (actStep > steps) {
		actStep = 0;
		sliding[0].currentMargin = startmargin;
		window.clearInterval(sliding[0].marginChangeMemInt);
		}
	} 
	,50)

this.flag = 1;

 
/*end new stuff*/
	
}
	
    this.current = (this.current + 1) % this.slides.length;
    setTimeout((function(){this.next();}).bind(this), this.timeout + 3850);
  }
}

