var myZoom;

function init() {
	if(document.getElementById("zoom")) {
		myZoom = new fx.Combo('zoom', {height: true, opacity: true, duration: 1000});
		myZoom.hide('height');
	}
	
	var	info = document.getElementsByClassName("info");
	for(i=0; i < info.length; i++) {
		info[i].style.display = "none";
	}
}

function zoom() {
	myZoom.toggle();
}

function openrub(id,e,parent) {
	nom = 'info_rub'+id;
	
	if(parent != 0) {
		if(document.getElementById(e).style.backgroundImage == 'url(images/puce_menu_2.gif)') {
			document.getElementById(e).style.backgroundImage = 'url(images/puce_menu.gif)';
			self.setTimeout('invisible("'+nom+'")',900);
		}
		else {
			document.getElementById(e).style.backgroundImage = 'url(images/puce_menu_2.gif)';
		}
	}
	
	new Effect.toggle($(nom),'blind');
}


function DisplayZoomPopUp(url) {
	window.open(url,'Zoom','height=500,width=500,left=0,top=0,scrollbars=yes');
}

/****** Menu principal de gauche *******/

/* Fonction qui permet d'ouvrir et de fermer une catégorie */
function openmenu(id,e,parent) {
	nom = 'info'+id;
	
	if(parent==0)
	{
		var info = new Array();
		info = document.getElementsByClassName("info");
		for(i=0; i < info.length; i++) {
			info[i].style.display = "none";
			
		}
		var info = new Array();
		info = document.getElementsByClassName("toggleinfo");
		for(i=0; i < info.length; i++) {
			info[i].style.backgroundImage = 'url(images/puce_menu.gif)';
		}
		
	}	
	if(parent == 0) {
		if(document.getElementById(e).style.backgroundImage == 'url(images/puce_menu_2.gif)') {
			document.getElementById(e).style.backgroundImage = 'url(images/puce_menu.gif)';
		//	self.setTimeout('invisible("'+nom+'")',900);
		}
		else {
			document.getElementById(e).style.backgroundImage = 'url(images/puce_menu_2.gif)';
		}
	}
	new Effect.toggle($(nom),'blind');
	
}

/* Rend invisible e */	
function invisible(e) {
	document.getElementById(e).style.display = "none";
}

/* rend visible e et change la puce à droite */
function visible1(e,toggle,parent) {
	document.getElementById(e).style.display = "block";

}

function fond_rose(idmenu)
{
	toggle='toggleinfo'+idmenu;
	document.getElementById(toggle).style.backgroundImage = 'url(images/puce_menu_2.gif)';
}

/* Au chargement de la page on regarde si un lien a été cliqué et on ouvre la catégorie ou le lien figure */
function ouvrir(idmenu,parent) {
	menuid = 'info'+idmenu;
	toggleinfo = 'toggleinfo'+idmenu;
	visible1(menuid,toggleinfo,parent);
}

function ouvrir_rub(idmenu,parent) {
	menuid = 'info_rub'+idmenu;
	toggleinfo = 'toggleinfo_rub'+idmenu;
	visible1(menuid,toggleinfo,parent);
}

function addToFavorites() {
	if (document.all) { window.external.AddFavorite(location.href, document.title); }
	else { alert('Vous pouvez faire CTRL + D pour ajouter cette page dans vos signets, ou favoris.') }
}

function opacity(id,opc) {
	document.getElementById(id).style.filter = "alpha(Opacity="+opc+")";
	document.getElementById(id).style.opacity = opc/100;
}

function page(cat) {
	new Ajax.Updater('page', 'index.php', {parameters:'categorie=' + encodeURIComponent(cat), asynchronous:true, evalScripts:true});
}

function retour() {
	history.go(-1);	
}

function qte_moins(champ) {
	champ2 = champ + "_2";
	qte = document.getElementById(champ).value;
	document.getElementById(champ).value = Number(qte) - 1;
	document.getElementById(champ2).value = Number(qte) - 1;
	frmsubmit('recalc');
}

function qte_plus(champ) {
	champ2 = champ + "_2";
	qte = document.getElementById(champ).value;
	document.getElementById(champ).value = Number(qte) + 1;
	document.getElementById(champ2).value = Number(qte) + 1;
	frmsubmit('recalc');
}

function OpenWin(URL,width,height,nom) {
	window.open(URL,nom,"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height + ",resizable=no");
}

function OpenWin2(URL,width,height,nom) {
	window.open(URL,nom,"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height + ",resizable=yes");
}

function DisplayZoomPopUp(url) {
	window.open(url,'Zoom','height=500,width=500,left=0,top=0,scrollbars=yes');
}