function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function test()
{
    //alert(document.getElementById('imgCorps3d10').id);
    slowhigh(document.getElementById('imgCorps3d10'));
}
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'];
 var txtRef = MM_findObj(myName + 'Txt');
 //alert(picTargets[currImg]);
 var imgPicTarget= parLyr.document.images[picTargets[currImg]];
 browserdetect=imgPicTarget.filters? "ie" : typeof imgPicTarget.style.MozOpacity=="string"? "mozilla" : ""
 if (browserdetect=="mozilla")
{
  parLyr.document.images['imgCorps3d01'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d02'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d03'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d04'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d05'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d06'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d07'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d08'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d09'].style.MozOpacity=0
  parLyr.document.images['imgCorps3d10'].style.MozOpacity=0
}
 else if (browserdetect=="ie")
{
  parLyr.document.images['imgCorps3d01'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d02'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d03'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d04'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d05'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d06'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d07'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d08'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d09'].filters.alpha.opacity=0;
  parLyr.document.images['imgCorps3d10'].filters.alpha.opacity=0;
}
 
 //parLyr.document.images['imgCorps3d01'].src="images/null.gif"
 //parLyr.document.images['imgCorps3d02'].src="images/null.gif"
 //parLyr.document.images['imgCorps3d03'].src="images/null.gif"
 
 // 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;

 if (imgPicTarget.filters)
    imgPicTarget.filters.alpha.opacity=100;
 imgPicTarget.src = picContents[currImg];
 if (f&&f.length&&f[0]) f[0].Play();
 var sHead="<table border='0' cellspacing='0' cellpadding = '0' height='100' width='240'><tr><td align='left' valign='bottom' class='std'>";
 var sFoot="</td></tr></table>";
  with (txtRef) {
  if (document.layers) 
   {document.write(unescape(sHead+this.txts[currImg])+sFoot); document.close();}
  else innerHTML = unescape(sHead+this.txts[currImg]+sFoot);
}
}}


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();

 // cache l'image en cours
 if (parLyr.document.images[picTargets[currImg]].filters)
    parLyr.document.images[picTargets[currImg]].filters.alpha.opacity=0;

 // 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'];
 var txtRef = MM_findObj(myName + 'Txt');
 
 // 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;
 if (f&&f.length&&f[0]) f[0].Play();
 
 var sHead="<table border='0' cellspacing='0' cellpadding = '0' height='100' width='240'><tr><td align='left' valign='bottom' class='std'>";
 var sFoot="</td></tr></table>";
  with (txtRef) {
  if (document.layers) 
   {document.write(unescape(sHead+this.txts[currImg])+sFoot); document.close();}
  else innerHTML = unescape(sHead+this.txts[currImg]+sFoot);
}

}}

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)
{
 this.myName = myName;
 this.delay = delay;
 this.timer = 0;
 this.parLyr = (document.layers && parLyr ? eval(parLyr) : window);
 this.currImg = 0;

 this.data = new Array();
 this.txts = new Array();
 this.picTargets = new Array();
 this.picContents = new Array();
  var j=0
 for (var i = 3; i < arguments.length; i+=4)
 {
 
  // Preload images into an array before swapping.
  this.data[j] = new Image();
  this.data[j].src = arguments[i];
  this.txts[j] = arguments[i+1];
  this.picTargets[j] = arguments[i+2];
  this.picContents[j] = arguments[i+3];
 j++;
 }
 
 this.cycle = imgCycle;
 this.play = imgPlay;
 this.stop = imgStop;
 this.gotopicture = imgGo;
 this.reset = imgReset;
 this.zoom = imgZoom;
}
