//-------------------------FONCTIONS DE BASE--------------------//

function DJS_swapImgRestore() { //v3.0
  var i,x,a=document.DJS_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function DJS_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.DJS_p) d.DJS_p=new Array();
    var i,j=d.DJS_p.length,a=DJS_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.DJS_p[j]=new Image; d.DJS_p[j++].src=a[i];}}
}

function DJS_findObj(n, d) { //v4.01
  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=DJS_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function DJS_swapImage() { //v3.0
  var i,j=0,x,a=DJS_swapImage.arguments; document.DJS_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=DJS_findObj(a[i]))!=null){document.DJS_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//-------------------------FONCTIONS SPECIFIQUES--------------------//

function DJS_showimg(id)
{
	eval("infos_tab=document.ecog.infos_"+id+".value.split(';')");

	elem=document.getElementById('bigimg');
	
	elem.src=infos_tab[0];
	maxheight=430;
	maxwidth=550;
	w=infos_tab[1];
	h=infos_tab[2];
	if(infos_tab[1]>maxwidth)
	{
		w=maxwidth;
		h="";
		
		coef=maxwidth/infos_tab[1];
		if(coef*infos_tab[2]>maxheight)
		{
			w="";
			h=maxheight;
		}
	}
	else if(infos_tab[2]>maxheight)
	{
		h=maxheight;
		w="";
		
		coef=maxheight/infos_tab[2];
		if(coef*infos_tab[1]>maxwidth)
		{
			w=maxwidth;
			h="";
		}
	}

	if(w!='')
		elem.width=w;
	if(h!='')
		elem.height=h;
	
	elem=document.getElementById('galerie');
	elem.style.display='';
	elem=document.getElementById('topdiv');
	elem.style.display='none';
}

function DJS_retour()
{
	
	elem=document.getElementById('galerie');
	elem.src='';
	elem.style.display='none';
	elem=document.getElementById('topdiv');
	elem.style.display='';
}
