﻿// Custom script using jQuery to slide divs across within a containing div

var _slideWidth = 200;        // width of slide div without px at the end
var _slideCount = 0;          // number of slides
var _slideInterval = 5000;    // interval between slides in milleseconds
var _slideSpeed = 2000;       // time for transition in milleseconds

var _idSlide;
var _doSlide = 1;

// Set the slides going
_idSlide = setInterval(runSlider, _slideInterval);

function runSlider() {
    if (_slideCount == 0) {
        // Grab the number of slides
        _slideCount = document.getElementById("hfSlideCount").value;
    }

  if (_doSlide == 1) {
    for (sn = 1; sn < (_slideCount + 1); sn++) {
      if ($("#divSlide" + sn).css("left") == ("-" + _slideWidth + "px")) {
        document.getElementById("divSlide" + sn).style.left = ((_slideWidth * (_slideCount - 2)) + "px");
      } else {
        $("#divSlide" + sn).animate({ "left": ("-=" + _slideWidth + "px") }, _slideSpeed, "swing");
      }
    }
  }
}

function startSlider() {
  _doSlide = 1;
}

function stopSlider() {
  _doSlide = 0;
}

//function runSlider() {
//  for (sn = 1; sn < 8; sn++) {
//    if ($("#divSlide" + sn).css("left") == "-200px") {
//      //$("#divSlide" + sn).animate({ "left": "1000px" }, "10");
//      document.getElementById("divSlide" + sn).style.left = "1000px";
//    } else {
//      $("#divSlide" + sn).animate({ "left": "-=200px" }, "5000", "swing");
//    }
//  }
//}
