function switchsidebar() {
	if(!Element.visible("sidenav")) {
		Element.hide("sidecoups");
		Element.show("sidenav");
		$("switchsidebarimg").src="navigation/revoir_coups.gif";
		$("switchsidebarimg").alt="voir les Coups de coeur";
	} else {
		Element.hide("sidenav");
		Element.show("sidecoups");
		$("switchsidebarimg").src="navigation/trouvez_vin.gif";
		$("switchsidebarimg").alt="trouvez un vin en quelques clics";
	}
}

function switchinfos(id) {
	if(id=="w") {
		Element.hide("plusinfos");
		Element.show("winemaker");
		$("switchinfosimg").src="navigation/wine_maker.gif";
	} else {
		Element.hide("winemaker");
		Element.show("plusinfos");
		$("switchinfosimg").src="navigation/plus_infos.gif";
	}
}

function switchnews(id) {
	if(id=="a") {
		Element.hide("news");
		Element.show("newsall");
		$("switchnewsimg").src="navigation/news_all.gif";
	} else {
		Element.hide("newsall");
		Element.show("news");
		$("switchnewsimg").src="navigation/news.gif";
	}
}

function switchmets(id) {
	if(id=="a") {
		Element.hide("mets");
		Element.show("metsall");
		$("switchmetsimg").src="navigation/mets_all.gif";
	} else {
		Element.hide("metsall");
		Element.show("mets");
		$("switchmetsimg").src="navigation/mets.gif";
	}
}

function switchcoups(id) {
	if(id=="a") {
		Element.hide("coups");
		Element.show("coupsall");
		$("switchcoupsimg").src="navigation/coups_all.gif";
	} else {
		Element.hide("coupsall");
		Element.show("coups");
		$("switchcoupsimg").src="navigation/coups.gif";
	}
}

function activechamp(id) {
	id.style.backgroundColor="#fff0e6";
	id.style.borderColor="#333";
	id.style.color="#333"
}

function desactivechamp(id) {
	id.style.backgroundColor="#fff";
	id.style.borderColor="#666";
	id.style.color="#666";
}

function paysextras() {
	var extras = $("paysliste").getElementsByTagName("li");
	for(a=0;a<extras.length;a++) {
		if(!Element.visible(extras[a])) Element.show(extras[a]);
	}
	Element.hide("paysplus");
}

var vinActif;
function loadvin(article) {
	var myAjax = new Ajax.Updater(
				'colselection', 
				'vin_load.php', 
				{
					method: 'get', 
					parameters: 'article='+article,
					onComplete: function() {
						Element.removeClassName("vin_"+vinActif,"actif");
						Element.addClassName("vin_"+article,"actif");
						vinActif = article;
					}
				});
}

function popup(id) {
	var x = Math.floor((screen.availWidth-290)/2);
	var y = Math.floor((screen.availHeight-400)/2);
	var fenetre = window.open("vin_popup.php?article="+id,id,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=290,height=400,left="+x+",top="+y);
	fenetre.focus;
}

function preview(path,id,w,h) {
	win_w=parseInt(w);
	win_h=parseInt(h);
	var left = (screen.availWidth-win_w)/2;
	var top = ((screen.availHeight-win_h)/2)-30;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+win_w+',height='+win_h+',left='+left+',top='+top;
	var msgWindow = window.open("../admin/includes/view_image.php?path="+path+id+".jpg","img"+id, styleStr);
	msgWindow.focus();
}

function printresults(query) {
	var x = Math.floor((screen.availWidth-700)/2);
	var y = Math.floor((screen.availHeight-500)/2);
	var fenetre = window.open("print_results.php?"+query,"print","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=500,left="+x+",top="+y);
	fenetre.focus;
}

function printvin(id) {
	var x = Math.floor((screen.availWidth-700)/2);
	var y = Math.floor((screen.availHeight-500)/2);
	var fenetre = window.open("print_vin.php?article="+id,id,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=500,left="+x+",top="+y);
	fenetre.focus;
}