// Script to produce a slide show for a given html <img> element

// Script name:  "slideTimer(q)"
// File name:    "slideShow.js"

//**********************************************
// parameters/requirements:
// (1) receive param (q) which is the quantity of pictures in the show
// (2) pictures for the show should all be the same relative dimention
// (3) store pictures in the directory "slides" - 
//       which is located in the same directory as the calling page
// (4) pictures should be named "0.jpg", "1.jpg", "2.jpg" ... (q-1).jpg
// (5) the <img> element should have the attribute: name="slide"
// (6) tested by calling from body with attribute: onLoad="slideTimer(22)"
// (7) optional function to preload images can be caled from img element
//       with attribute: onLoad="MM_preloadImages('/slides/0.jpg', ... )
//**********************************************

    var slideNumber=0;
    var qty=1;

    function slideTimer(q)
    {
      qty=q;
      slideNumber=Math.floor(Math.random()*qty);
      setInterval("slideShow()", 4500);
    }  //end function slideTimer()

    function slideShow()
    {
      if(slideNumber>=qty)
        {slideNumber=0;}
      var slideName="slides/" + slideNumber.toString() + ".jpg";
      document.slide.src=slideName;
	  document.slide.height="200";   //temporary line
      slideNumber++;
    }  //end function slideShow()
	
	function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}




// Script to produce a slide show for a given html <img> element
//   that only alternates between two pictures

// Script name:  "slideTimerAlt()"
// File name:    "slideShow.js"

//**********************************************
// parameters/requirements:
// (1) receive param (p1, p2) which are the file names of the two
//       pictures to alternate between
// (2) pictures for the show should all be the same relative dimention
// (3) store pictures in the directory "images" - 
//       which is located in the root directory
// (4) the <img> element should have the attribute: name="slide"
// (5) tested by calling from body with attribute: onLoad="slideTimerAlt('xxx.jpg', 'xyz.jpg')"
// (6) optional function to preload images can be caled from img element
//       with attribute: onLoad="MM_preloadImages('/images/xxx.jpg', ... )
//**********************************************

    var alt=1;
	var pic1="";
	var pic2="";

    function slideTimerAlt(p1, p2)
    {
      pic1=p1;
	  pic2=p2;
      slideNumber=Math.floor(Math.random()*qty);
      setInterval("slideShowAlt()", 4500);
    }  //end function slideTimer()

    function slideShowAlt()
    {
      if(alt==1)
      {
		  alt++;
		  var slideName="/images/" + pic2;
	  }
	  else
	  {
		  alt=1;
          var slideName="/images/" + pic1;
	  }
      document.slide.src=slideName;
    }  //end function slideShow()
	

