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 page_rub(rub) {
	new Ajax.Updater('page', 'index.php', {parameters:'rubrique=' + encodeURIComponent(rub), 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');
}

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)';
		}
	}
	
	var info = new Array();
	info = document.getElementsByClassName("info");
	for(i=0; i < info.length; i++) {
		nom2 = 'info_rub'+parent;
		if(nom2!=info[i].id)
		{
			info[i].style.display = "none";
		}
	}
	
	new Effect.toggle($(nom),'blind');
}

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

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

function orange(id){
	nom = 'rub_haut'+id;
	var info = new Array();
	info = document.getElementsByClassName("rub_haut");
	for(i=0; i < info.length; i++) {
		info[i].style.backgroundImage = 'url(images/pix_bleu.gif)';
	}
	document.getElementById(nom).style.backgroundImage = 'url(images/pix_orange.gif)';
}

function contact(){
	nom = 'contact';
	var info = new Array();
	info = document.getElementsByClassName("rub_haut");
	for(i=0; i < info.length; i++) {
		info[i].style.backgroundImage = 'url(images/pix_bleu.gif)';
	}
	document.getElementById(nom).style.backgroundImage = 'url(images/pix_orange.gif)';
}

function galerie(){
	nom = 'galerie';
	var info = new Array();
	info = document.getElementsByClassName("rub_haut");
	for(i=0; i < info.length; i++) {
		info[i].style.backgroundImage = 'url(images/pix_bleu.gif)';
	}
	document.getElementById(nom).style.backgroundImage = 'url(images/pix_orange.gif)';
}

function changeMiniature(id){
	/*new Effect.SlideUp(document.getElementById(id));*/
	nom = 'troisphoto'+id;
	info = document.getElementsByClassName("troisphoto");
	for(i=0; i < info.length; i++) {
		info[i].style.display = "none";
	}
	new Effect.Appear(document.getElementById(nom), {duration: 2.0});
}

function changePhoto(id,nom,largeur,hauteur,img,largeur2,hauteur2,img2,largeur3,hauteur3,img3,largeur4,hauteur4,img4){
	document.getElementById('loupe').style.display = "none";
	new Effect.Fade(document.getElementById('photo'), {duration: 1.5});
	switch (id){
		case 1:
			if(img2 != ""){
				document.getElementById('photo_zoom').innerHTML = '<img src="upload/'+img2+'" />';
			}
		break;
		case "2":
			if(img3 != ""){
				document.getElementById('photo_zoom').innerHTML = '<img src="upload/'+img3+'" />';
			}
		break;
		case "3":
			if(img4 != ""){
				document.getElementById('photo_zoom').innerHTML = '<img src="upload/'+img4+'" />';
			}
		break;
	}
	self.setTimeout('changePhoto2('+id+',"'+nom+'","'+largeur+'","'+hauteur+'","'+img+'","'+largeur2+'","'+hauteur2+'","'+img2+'","'+largeur3+'","'+hauteur3+'","'+img3+'","'+largeur4+'","'+hauteur4+'","'+img4+'")',1500);
}

function changePhoto2(id,nom,largeur,hauteur,img,largeur2,hauteur2,img2,largeur3,hauteur3,img3,largeur4,hauteur4,img4){
	if(id == 1){
		document.getElementById('photo').style.width = largeur+'px';
		document.getElementById('photo').style.height = hauteur+'px';
		document.getElementById('photo').style.backgroundImage = 'url(upload/'+img+')';
	}
	if(id == 2){
		document.getElementById('photo').style.width = largeur2+'px';
		document.getElementById('photo').style.height = hauteur2+'px';
		document.getElementById('photo').style.backgroundImage = 'url(upload/'+img2+')';
	}
	if(id == 3){
		document.getElementById('photo').style.width = largeur3+'px';
		document.getElementById('photo').style.height = hauteur3+'px';
		document.getElementById('photo').style.backgroundImage = 'url(upload/'+img3+')';
	}
	if(id == 4){
		document.getElementById('photo').style.width = largeur4+'px';
		document.getElementById('photo').style.height = hauteur4+'px';
		document.getElementById('photo').style.backgroundImage = 'url(upload/'+img4+')';
	}
	document.getElementById('titre_photo').innerHTML = nom;
	//Loupe moins
	idMoins = id-1;
	if(id == 1){
		document.getElementById('loupe_moins').innerHTML = "";
	}else{
		document.getElementById('loupe_moins').innerHTML = '<a href="javascript:changePhoto(\''+idMoins+'\',\''+nom+'\',\''+largeur+'\',\''+hauteur+'\',\''+img+'\',\''+largeur2+'\',\''+hauteur2+'\',\''+img2+'\',\''+largeur3+'\',\''+hauteur3+'\',\''+img3+'\',\''+largeur4+'\',\''+hauteur4+'\',\''+img4+'\')" title="Zoom arrière"><img src="images/loupe_moins.png" alt="Zoom arrière" /></a>';
	}
	//Loupe Plus
	idPlus = id+1;
	imgPlus = "img"+idPlus;
	switch(imgPlus){
		case "img2":
			if(img2 == ""){
				document.getElementById('loupe_plus').innerHTML = "";
			}else{
				document.getElementById('loupe_plus').innerHTML = '<a href="javascript:changePhoto(\''+idPlus+'\',\''+nom+'\',\''+largeur+'\',\''+hauteur+'\',\''+img+'\',\''+largeur2+'\',\''+hauteur2+'\',\''+img2+'\',\''+largeur3+'\',\''+hauteur3+'\',\''+img3+'\',\''+largeur4+'\',\''+hauteur4+'\',\''+img4+'\')" title="Zoom avant"><img src="images/loupe_plus.png" alt="Zoom avant" /></a>';
			}
		break;
		case "img3":
			if(img3 == ""){
				document.getElementById('loupe_plus').innerHTML = "";
			}else{
				document.getElementById('loupe_plus').innerHTML = '<a href="javascript:changePhoto(\''+idPlus+'\',\''+nom+'\',\''+largeur+'\',\''+hauteur+'\',\''+img+'\',\''+largeur2+'\',\''+hauteur2+'\',\''+img2+'\',\''+largeur3+'\',\''+hauteur3+'\',\''+img3+'\',\''+largeur4+'\',\''+hauteur4+'\',\''+img4+'\')" title="Zoom avant"><img src="images/loupe_plus.png" alt="Zoom avant" /></a>';
			}
		break;
		case "img4":
			if(img4 == ""){
				document.getElementById('loupe_plus').innerHTML = "";
			}else{
				document.getElementById('loupe_plus').innerHTML = '<a href="javascript:changePhoto(\''+idPlus+'\',\''+nom+'\',\''+largeur+'\',\''+hauteur+'\',\''+img+'\',\''+largeur2+'\',\''+hauteur2+'\',\''+img2+'\',\''+largeur3+'\',\''+hauteur3+'\',\''+img3+'\',\''+largeur4+'\',\''+hauteur4+'\',\''+img4+'\')" title="Zoom avant"><img src="images/loupe_plus.png" alt="Zoom avant" /></a>';
			}
		break;
		default:
			document.getElementById('loupe_plus').innerHTML = "";
		break;
	}
	
	
	new Effect.Appear(document.getElementById('photo'), {duration: 1.5});
	self.setTimeout('afficheLoupe()',1500);
}

function afficheLoupe(){
	document.getElementById('loupe').style.display = "block";
}

function change(id,url,caption) {
	img = document.getElementsByClassName('highslide-image');
	img[0].src= url;
}