// JavaScript Document

//Variable globales
var dureeApparition = 0.20 ;
var dureeDisparition = 0.20 ;
var loader = '<img class="loaderAjax" src="images/ajax.gif" width="" height="" title="..." />'
//Variable globales : fin

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
<!--fonction pour faire apparaitre les <dd>
window.onload=montre;
function montre(menu, id) {
	if(id){
		var d = $(id);
	}

	var i = 1 ;
	while($(menu+i)){
		$(menu+i).setStyle({'display':'none'});
		i++ ;
		if(!$(menu+i)) i++ ;
	}

	if (d) {d.setStyle({'display':'block'});}
}


window.onload=voiress;
function voiress(menu) {
if(menu){
	var d = document.getElementById(menu);
}
	var i = 1;
	while (document.getElementById('smenu'+i)) {
	if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
		i++;
	}

	if (d) {d.style.display='block';}
}





function getPageSize(){

	 var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function afficherImage(){
	param=afficherImage.arguments ;
    if($(param[8]))	{
		//0 : defaut
		//1 : style
		//2 : dossier
		//3 : id
		//4 : hauteurFixe
		//5 : largeurFixe
		//6 : alt
		//7 : title
		//8 : identifiant balise
		new Ajax.Request("includes/afficherImage.php", {
			method: "post",
			parameters: { defaut: param[0], style: param[1], dossier: param[2], id: param[3], hauteurFixe: param[4], largeurFixe: param[5], alt: param[6], title: param[7] },
			onLoading:(function(){
				$(param[8]).update(loader) ;
			}),
			onComplete: (function(transport){
				if(transport.status = 200){
					$(param[8]).update(transport.responseText) ;
				}
			})
		});
	}
}

//PANIER
function afficherImgPanier(){
	if($('monpanier-img') && !$('monpanier-img').visible()){
		new Effect.Appear('monpanier-img', {
			duration:this.dureeApparition,
			to:1.0,
			from:0.0,
			queue: 'end'
		});
	}
}

function cacherImgPanier(){
	if($('monpanier-img') && $('monpanier-img').visible()){
		new Effect.Appear('monpanier-img', {
			duration:this.dureeDisparition,
			to:0.0,
			from:1.0,
			queue: 'end'
		});
	}
}
//PANIER : FIN

//FORMULAIRES
function erreurChamps(message, id){
	if($(id)) $(id).update(message) ;
}

function valeurChampsValide(id){
	if($(id)) $(id).update("Correct") ;
}
//FORMULAIRES : fin
