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

function apparition(id) {
	var opc = new fx.Opacity(id, {duration: 2200});
	opc.hide();
	opc.toggle();
}

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 gotobrand(ident){
	document.location="<?=$wwwroot?>/achat/brand.php?"+ident;
}

function gotocategorie(ident){
	document.location="<?=$wwwroot?>/achat/index.php?catid="+ident;
}

function coordonnee(event,id, x1, y1) {
	margingTop = 76;
	marginLeft = 9;
	
	document.getElementById(x1).value = document.getElementById(id).offsetLeft - 9;
	document.getElementById(y1).value = document.getElementById(id).offsetTop - 76;
}

function addtable(num,img,fumeur) {
	
	for (var i=0; i<img.length;i++) {
		if (img[i].checked) {
			img2 = img[i].value;
		}
	}
	
	if(!isNaN(num)) {
		new Ajax.Updater('plan', 'gestion.php', {parameters:'img=' + encodeURIComponent(img2) + '&num=' + encodeURIComponent(num) + '&fumeur=' + encodeURIComponent(fumeur) + '&action=add', asynchronous:true, evalScripts:true});
	}
}

function savetable(id,x,y) {
	new Ajax.Updater('plan', 'gestion.php', {parameters:'id=' + encodeURIComponent(id) + '&x=' + encodeURIComponent(x) + '&y=' + encodeURIComponent(y) + '&action=update', asynchronous:true, evalScripts:true});
}

function removetable(id) {
	new Ajax.Updater('plan', 'gestion.php', {parameters:'id=' + encodeURIComponent(id) + '&action=remove', asynchronous:true, evalScripts:true});
}

function searchtables(jour,mois,annee,heure,pers,duree) {
	new Ajax.Updater('plan_reserve', 'reservation.php', {onLoading:function(request){Element.show('indicator')}, onComplete:function(request){Element.hide('indicator')},parameters:'jour=' + encodeURIComponent(jour) + '&mois=' + encodeURIComponent(mois) + '&annee=' + encodeURIComponent(annee) + '&heure=' + encodeURIComponent(heure) + '&pers=' + encodeURIComponent(pers) + '&duree=' + encodeURIComponent(duree) + '&action=search', asynchronous:true, evalScripts:true});
}

function select_table(date,heure,pers,id,numero,duree) {
	new Ajax.Updater('plan_reserve', 'reservation.php', {onLoading:function(request){Element.show('indicator')}, onComplete:function(request){Element.hide('indicator')},parameters:'date=' + encodeURIComponent(date) + '&heure=' + encodeURIComponent(heure) + '&pers=' + encodeURIComponent(pers) + '&id=' + encodeURIComponent(id) + '&numero=' + encodeURIComponent(numero) + '&duree=' + encodeURIComponent(duree) + '&action=reserve', asynchronous:true, evalScripts:true});
}

function reserve_table(date,heure,pers,id,numero,nom,duree) {
	new Ajax.Updater('plan_reserve', 'reservation.php', {onLoading:function(request){Element.show('indicator')}, onComplete:function(request){Element.hide('indicator')},parameters:'date=' + encodeURIComponent(date) + '&heure=' + encodeURIComponent(heure) + '&pers=' + encodeURIComponent(pers) + '&id=' + encodeURIComponent(id) + '&numero=' + encodeURIComponent(numero) + '&nom=' + encodeURIComponent(nom) + '&duree=' + encodeURIComponent(duree) + '&action=add', asynchronous:true, evalScripts:true});
}

function winClose() {
	document.getElementById('success').style.display = "none"	
}

function update_config(action,valeur) {
	new Ajax.Updater('configuration', 'config.php', {parameters:'action=' + encodeURIComponent(action) + '&valeur=' + encodeURIComponent(valeur), asynchronous:true, evalScripts:true});
}

function remove_reserve(id) {
	new Ajax.Updater('configuration', 'view.php', {parameters:'action=remove' + '&id=' + encodeURIComponent(id), asynchronous:true, evalScripts:true});
}

function select_horaire(jour,mois,annee) {
	new Ajax.Updater('hours', 'reservation.php', {parameters:'jour=' + encodeURIComponent(jour) + '&mois=' + encodeURIComponent(mois) + '&annee=' + encodeURIComponent(annee) + '&action=maj_hours', asynchronous:true, evalScripts:true});
}