﻿// JScript File

var hpos;
var minhpos;
var newhpos;
var picture;
var timer;
var slidefiles=['81','85','54','41','57','8','47','14','17','24'];
var slidenames=['Ashness Bridge','Dipper with Food','Doing a Wheelie','A Breezy Meadow','Clematis','Kingfisher','Lily','Peacock','Refuge on Causeway','The Bridge'];
var slidecounter=0;
function movex(hamount)
{
    picture=document.getElementById("moveablepanel");
    hpos=picture.offsetLeft;
    if (picture.offsetWidth>598)
    {
        minhpos=598-picture.offsetWidth;
    }
    else
    {
        minhpos=0;
    }
    if (hamount>0)
    {
        moveright(hpos);
    }
    else
    {
        moveleft(hpos);
    }
}
function moveright(hpos)
{
    if (hpos<-1)
    {
        picture.style.left= hpos + "px";
        hpos+=5;
        timer=setTimeout('moveright('+hpos+')',15);
    }      
    else
    {
        picture.style.left=0;
        stopscroll();
    } 
}
function moveleft(hpos)
{
    if (hpos>minhpos)
    {
        picture.style.left= hpos + "px";
        hpos-=5;
        timer=setTimeout('moveleft('+hpos+')',15);
    }      
    else
    {
        picture.style.left=minhpos;
        stopscroll();
    }
}
function stopscroll()
{
    clearTimeout(timer);
}
function showpicture(picname,pictitle)
{
    var chosen=document.getElementById("chosenpicture");
    chosen.src="images/" + picname + ".jpg";
    var pt=document.getElementById("imagetitle");
    pt.innerHTML="<h3>" + pictitle + "</h3>";
    chosen.style.visibility="visible";
}
function slideshow()
{
    showpicture(slidefiles[slidecounter],slidenames[slidecounter]);
    slidecounter=slidecounter+1;
    if (slidecounter==slidefiles.length)
    {
        slidecounter=0;
    }
    timer=setTimeout('slideshow();',10000);
}