/*************************************************************************
  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 = 600;	// millisecond duration of slide into view
var slide_out_speed = 500;// 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( 'productSlide', 0, 0 );

  for (var i=0; glideLyrs[i]; i++)
	{
		// hold original left position 
		glideLyrs[i].xOff = -(glideLyrs[i].w + 10);
		glideLyrs[i].shiftTo( glideLyrs[i].xOff, glideLyrs[i].y );
		glideLyrs[i].show();
  }
  slideEm('productSlide'); // 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(10, 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(0, null, slide_in_speed, -1);
  }
	curGlideLyr = id;
}
