/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2002-4 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// change speed of slide here
var slide_in_speed = 0;	// millisecond duration of slide into view
var slide_out_speed = 0;// millisecond duration of slide out of view

function initGlideLayers() {
  var glideLyrs = new Array();
  
  // Set up your layers here
  // arguments: id, left=0 (offset calculated based on width), top
  glideLyrs[0] = new dynObj('glideDiv0', 0, 109);
  glideLyrs[1] = new dynObj('glideDiv1', 0, 109);
  glideLyrs[2] = new dynObj('glideDiv2', 0, 109);
  glideLyrs[3] = new dynObj('glideDiv3', 0, 109);
  glideLyrs[4] = new dynObj('glideDiv4', 0, 109);  

  for (var i=0; glideLyrs[i]; i++) {
		// hold original left position 
		glideLyrs[i].xOff = -(glideLyrs[i].w + 311);
		glideLyrs[i].shiftTo( glideLyrs[i].xOff, glideLyrs[i].y );
		glideLyrs[i].show();
  }
  slideEm('glideDiv0'); // Slide first one into view 
}

var curGlideLyr;
function slideEm(id) {
  var oldLyr, newLyr;
  // if link for current layer clicked, slide it out of view 
	if (curGlideLyr == id) { 
    oldLyr = dynObj.getInstance(curGlideLyr);
		oldLyr.slideTo(oldLyr.xOff, null, slide_out_speed, -1);
    curGlideLyr = ""; return; 
  }
	// if layer currently in view, set up to slide new one into view
	// after current one slides away
	if (curGlideLyr) {
    oldLyr = dynObj.getInstance(curGlideLyr);
		oldLyr.onSlideEnd = function() { 
			dynObj.holder[curGlideLyr].slideTo(311, null, slide_in_speed, -1); 
			this.onSlideEnd = function() { if (this.el) this.el = null } 
		}
		// slide current layer out of view
		oldLyr.slideTo(oldLyr.xOff, null, slide_out_speed, -1);
	} else { 	// if no layer currently in view
    newLyr = dynObj.getInstance(id);
    newLyr.slideTo(311, null, slide_in_speed, -1);
  }
	curGlideLyr = id;
}

