﻿function imgCycle(dir) { with (this)
{
 // Stop any exiting play function if this is called manually.
 stop();

 // Increment and mod by the image array length.
 currImg += dir;
 currImg = currImg % data.length;
 if (currImg < 0) currImg += data.length;

 // The image in question -- perhaps nested within its parent layer for NS4.
 var imgRef = parLyr.document.images[myName + 'Img'];

 // IE filters active?
 var f = imgRef.filters;
 if (f&&f.length&&f[0]) f[0].Apply();
 // Swap the image, and play the filter if applicable.
 imgRef.src = data[currImg].src;
 
 //Swap the text if available
 if (myTextName)
  {
  var txtRef = parLyr.document.forms[0].elements[myTextName];
  txtRef.value = data2[currImg];
 }
 
 if (f&&f.length&&f[0]) f[0].Play();
}}

function imgReset(index) { with (this)
{
 // Cycle one image forwards -- cycle() will stop an existing timeout if applied.
 currImg=-1;
 cycle(1);
 timer = setTimeout(myName + '.play()', delay);
}}

function imgGo(index) { with (this)
{
 // Stop any exiting play function if this is called manually.
 stop();

 // Increment and mod by the image array length.
 currImg = index-1;
 currImg = currImg % data.length;
 if (currImg < 0) currImg += data.length;

 // The image in question -- perhaps nested within its parent layer for NS4.
 var imgRef = parLyr.document.images[myName + 'Img'];

 // IE filters active?
 var f = imgRef.filters;
 if (f&&f.length&&f[0]) f[0].Apply();
 // Swap the image, and play the filter if applicable.
 imgRef.src = data[currImg].src;

 //Swap the text
 if (myTextName)
 {
  var txtRef = parLyr.document.forms[0].elements[myTextName];
  txtRef.value = data2[currImg];
 }
 if (f&&f.length&&f[0]) f[0].Play();
}}

function imgPlay() { with (this)
{
 // Cycle one image forwards -- cycle() will stop an existing timeout if applied.
 cycle(1);
 timer = setTimeout(myName + '.play()', delay);
}}

function imgStop()
{
 // Clear the play timer to stop autocycling.
 clearTimeout(this.timer);
 this.timer = null;
}
function imgZoom() { with(this) {
 stop();
 var NS = (navigator.appName=="Netscape")?true:false; 
 if (!win) var win=window.open( "zoom.htm?" + data[currImg].src.replace(".jpg","l.jpg"), "zoom","resizable=0, height=520, width=370"); 

 /*//if (!win) var win=window.open( "", "zoom","resizable=0"); 
 if (!win) var win=window.open( "zoom.htm?" + data[currImg].src.replace(".jpg","l.jpg"), "zoom","resizable=0"); 
 win.document.write("<html><head><title>Robes des Sables</title></head><body bgcolor='#990000' leftmargin='10' topmargin='10' ><img src='" + data[currImg].src.replace(".jpg","l.jpg") + "'></body></html>");
 iWidth = win.document.images[0].width// - iWidth;
 iHeight = win.document.images[0].height// - iHeight; 
 //alert(iWidth + " " + iHeight);
 win.resizeTo(iWidth+32, iHeight+50); 
 win.focus;
*/

// alert (currImg);
}}

//function imgZoom() {  with(this) {
// stop();
// var NS = (navigator.appName=="Netscape")?true:false; 
// if (!win) var win=window.open( "zoom.htm?" + data[currImg].src.replace(".jpg","l.jpg"), "zoom","resizable=0, height=520, width=370"); 
//}}

//function ImageCycle(myName, delay, parLyr)
function ImageCycle(myName, myTextName, delay, parLyr, arrayImg, arrayText)
{
 this.myName = myName;
 this.myTextName = myTextName;
 this.delay = delay;
 this.timer = 0;
 this.parLyr = (document.layers && parLyr ? eval(parLyr) : window);
 this.currImg = 0;

 this.data = new Array();
 /*for (var i = 3; i < arguments.length-1; i++)
 {
  // Preload images into an array before swapping.
  this.data[i - 3] = new Image();
  this.data[i - 3].src = arguments[i];
 }*/
 for (var i = 0; i < arrayImg.length; i++)
 {
   // Preload images into an array before swapping.
  this.data[i] = new Image();
  this.data[i].src = arrayImg[i];
 }
 if (myTextName)
 {
  this.data2 = new Array();
  /*for (var i = 3; i < arguments.length-1; i++)
  {
   // Preload images into an array before swapping.
   this.data[i - 3] = new Image();
   this.data[i - 3].src = arguments[i];
  }*/
  for (var i = 0; i < arrayText.length; i++)
  {
    // Preload images into an array before swapping.
   this.data2[i] = arrayText[i];
  }
 } 
 this.cycle = imgCycle;
 this.play = imgPlay;
 this.stop = imgStop;
 this.go = imgGo;
 this.reset = imgReset;
 this.zoom = imgZoom;
}