﻿var IsPaused = false;
var pix = 0;
var Whichbutton = 0;
var boundry = 0;
var speed = 2;

function Start(noOfimages) {
    boundry = 136 * (noOfimages-3);
    IsPaused = false;
}

function Stop() {
    IsPaused = true;
}

function MoveLeft() {
    Whichbutton = 0;
    if (IsPaused || pix <= -boundry) return; 

    var objtbl = document.getElementById('SlideShow1_tblBase');

    if (objtbl == null)
    {
        objtbl = document.getElementById('ctl00_mainContent_SlideShow1_tblBase');   
    }

    if (objtbl == null) return
        
    pix = parseInt(objtbl.style.left.replace("px", ""));
    pix = pix - speed;
    objtbl.style.left = pix.toString() + "px";
    setTimeout("MoveLeft()", "10");
}

function StopMoveLeft() {
    Whichbutton = 0;
    if (!IsPaused || pix % boundry <= 0) return;

    var objtbl = document.getElementById('SlideShow1_tblBase');

    if (objtbl == null) {
        objtbl = document.getElementById('ctl00_mainContent_SlideShow1_tblBase');
    }

    if (objtbl == null) return
   
    pix = parseInt(objtbl.style.left.replace("px", ""));
    pix = pix - speed;
    objtbl.style.left = pix.toString() + "px";
    setTimeout("StopMoveLeft()", "10");
}

function MoveRight() {
    Whichbutton = 1;
    if (IsPaused || pix >= 0) return;

    var objtbl = document.getElementById('SlideShow1_tblBase');

    if (objtbl == null) {
        objtbl = document.getElementById('ctl00_mainContent_SlideShow1_tblBase');
    }

    if (objtbl == null) return
    
    pix = parseInt(objtbl.style.left.replace("px", ""));
    pix = pix + speed;
    objtbl.style.left = pix.toString() + "px";
    setTimeout("MoveRight()", "10");
}

function StopMoveRight() {
    Whichbutton = 1;
    if (!IsPaused || pix % boundry == 0) return;

    var objtbl = document.getElementById('SlideShow1_tblBase');

    if (objtbl == null) {
        objtbl = document.getElementById('ctl00_mainContent_SlideShow1_tblBase');
    }

    if (objtbl == null) return
    
    pix = parseInt(objtbl.style.left.replace("px", ""));
    pix = pix + speed;
    objtbl.style.left = pix.toString() + "px";
    setTimeout("StopMoveRight()", "10");
}

function Pause() {

    IsPaused = true;

    if (Whichbutton == 0) {
        setTimeout("Stop()", "0");
    }
    if (Whichbutton == 1) {
        setTimeout("Stop()", "0");
    }
    
    clearInterval(0);
}