﻿//This file will produce an in-window slide show with forward, back and autoplay buttons.
// The file itself resides in the root document directory, i.e. httpdocs and does not need to be copied or changed.
//1. Create a subdirectory of httpdocs, put all the images for this particular slide show 
//      in that directory along with a copy of getpic.php.
//2. Place the following two calls in the <head> section of the html document in which you want the slide show to appear:
//      <script src="http://www.nvvfd.org/Subdirectory-name/getpics.php" type="text/javascript"></script>
//      <script type="text/javascript" src="http://www.nvvfd.org/PicShow.js"></script>
//3. Place the following code in the html document at the point where you want the slide show positioned:
//      <script type="text/javascript"> PlacePicsHere() </script>
//Proper display can sometimes be facilitated by placing the script call as the only element in a table


document.write("<style type='text/css'>#picturearea{");
            document.write("filter:alpha(opacity=100);");
            document.write("-moz-opacity: 0;}</style>");
            
function PlacePicsHere(){
document.write("<form id='picsform'>");
document.write("<div  style=' display:none; width: 0px;'>");
document.write("<select name='picslist' size='0' style='width: 0px' onClick=''>");
document.write("</select></div>");
document.write("<div style=' margin-left: 20px '>");
     document.write("<INPUT type='button' onClick='Oneprevious();' value='<<' title='Previous'>");
     document.write("<INPUT type='button' name='picslistbutton' onClick='Oneap(this.value);' value='Start' title='AutoPlay'>");
     document.write("<INPUT type='button' onClick='Onenext();' value='>>' title='Next'></div>");
document.write("<div id='picturearea'  style=' width: 300px; height: 250px; margin-left: 20px'>");
document.write("</div></form>");
}

var Onerotate_delay = 2000; // delay in milliseconds (5000 = 5 secs)
Onecurrent = 0;

function Onenext() {
if (document.getElementById("picsform").picslist[Onecurrent+1]) {
//document.images.Oneshow.src = document.picsform.picslist[Onecurrent+1].value;
showpicture(document.getElementById("picsform").picslist);
document.getElementById("picsform").picslist.selectedIndex = ++Onecurrent;
   }
else Onefirst();
}
function Oneprevious() {
if (Onecurrent-1 >= 0) {
//document.images.Oneshow.src = document.picsform.picslist[Onecurrent-1].value;
showpicture(document.getElementById("picsform").picslist);
document.getElementById("picsform").picslist.selectedIndex = --Onecurrent;
   }
else Onelast();
}
function Onefirst() {
Onecurrent = 0;
//document.images.Oneshow.src = document.picsform.picslist[0].value;
showpicture(document.getElementById("picsform").picslist);
document.getElementById("picsform").picslist.selectedIndex = 0;
}
function Onelast() {
Onecurrent = document.picsform.picslist.length-1;
//document.images.Oneshow.src = document.picsform.picslist[Onecurrent].value;
showpicture(document.getElementById("picsform").picslist);
document.getElementById("picsform").picslist.selectedIndex = Onecurrent;
}
function Oneap(text) {
document.getElementById("picsform").picslistbutton.value = (text == "Stop") ? "Start" : "Stop";
Onerotate();
}

function Onerotate() {
if (document.getElementById("picsform").picslistbutton.value == "Stop") {
Onecurrent = (Onecurrent == document.getElementById("picsform").picslist.length-1) ? 0 : Onecurrent+1;
//document.images.Oneshow.src = document.picsform.picslist[Onecurrent].value;
showpicture(document.getElementById("picsform").picslist);
document.getElementById("picsform").picslist.selectedIndex = Onecurrent;
window.setTimeout("Onerotate()", Onerotate_delay);
}
}

function populateSelect(selectobj){
for (var i=0; i<picsarray.length; i++)
selectobj.options[selectobj.options.length]=new Option(picsarray[i], picsarray[i])
if (selectobj.options.length>1){
selectobj.selectedIndex=0
showpicture(document.getElementById("picsform").picslist)
}
}

function showpicture(selectobj){
piccontainerobj=document.getElementById("picturearea")
resetfade(10)
piccontainerobj.innerHTML='<img src="'+locationstring+selectobj.options[selectobj.selectedIndex].value+'">'
fadepictoview=setInterval("gradualfade(piccontainerobj)",50)
}

function resetfade(degree){
if (window.fadepictoview)
clearInterval(fadepictoview)
if (typeof piccontainerobj.style.MozOpacity=="string")
piccontainerobj.style.MozOpacity=degree/100
else if (piccontainerobj.filters)
piccontainerobj.filters.alpha.opacity=degree
}

function gradualfade(){
if (typeof piccontainerobj.style.MozOpacity=="string" && piccontainerobj.style.MozOpacity<1)
piccontainerobj.style.MozOpacity=Math.min(parseFloat(piccontainerobj.style.MozOpacity)+0.2, 0.99)
else if (piccontainerobj.filters && piccontainerobj.filters.alpha.opacity<100)
piccontainerobj.filters.alpha.opacity+=20
else //if not IE or Moz
clearInterval(fadepictoview)
}

window.onload=function(){
populateSelect(document.getElementById("picsform").picslist)
}