function showSubMenu(id) {
	if ($("div#sm_"+id).css("display") == "none") {
		var colors = new Array("#e4c208", "#cc061d", "#b37915", "#b2ca21", "#e4c208", "#cc061d", "#b37915", "#b2ca21", "#e4c208", "#cc061d", "#b37915", "#b2ca21");
		$("div#top_menu > a").css({"border-bottom": 0});
		$("a#tm_"+id).css({"border-bottom": "4px solid "+colors[id]});
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div#sub_menu > div").css({"display": "none"});
			$("div#sm_" + id).css({"display": "block"});
		} else {
			$("div#sub_menu > div").fadeOut('fast');
			$("div#sm_" + id).fadeIn('fast');
		}
	}
}

function switchProduct(id) {
	if ($("img#product_img_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div#products_image > img").css({"display": "none"});
			$("div#products_text > div").css({"display": "none"});
			$("img#product_img_" + id).css({"display": "block"});
			$("div#product_text_" + id).css({"display": "block"});
		} else {
			$("div#products_image > img").fadeOut('fast');
			$("div#products_text > div").fadeOut('fast');
			$("img#product_img_" + id).fadeIn('fast');
			$("div#product_text_" + id).fadeIn('fast');
		}
	}
}

function switchChef(id) {
	if ($("div#chef_text_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div#chefs_text > div").css({"display": "none"});
			$("div#chef_text_" + id).css({"display": "block"});
		} else {
			$("div#chefs_text > div").fadeOut('fast');
			$("div#chef_text_" + id).fadeIn('fast');
		}
	}
}

function switchText(id) {
	if ($("div#text_switch_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div.text_switch").css({"display": "none"});
			$("div#text_switch_"+id).css({"display": "block"});
		} else {
			$("div.text_switch").fadeOut('fast');
			$("div#text_switch_"+id).fadeIn('fast');
		}
	}
}

function switchNews(id) {
	if ($("div#news_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div.news_content").css({"display": "none"});
			$("div#news_"+id).css({"display": "block"});
		} else {
			$("div.news_content").fadeOut('fast');
			$("div#news_"+id).fadeIn('fast');
		}
	}
}

function switchCoupdecoeur(id) {
	if ($("div#coupdecoeur_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div.coupdecoeur_content").css({"display": "none"});
			$("div#coupdecoeur_"+id).css({"display": "block"});
		} else {
			$("div.coupdecoeur_content").fadeOut('fast');
			$("div#coupdecoeur_"+id).fadeIn('fast');
		}
	}
}

function switchMoutarde(id) {
	if ($("div#moutarde_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div#moutardes > div").css({"display": "none"});
			$("div#moutarde_" + id).css({"display": "block"});
		} else {
			$("div#moutardes > div").fadeOut('fast');
			$("div#moutarde_" + id).fadeIn('fast');
		}
	}
}

function switchProcede(id) {
	if ($("div#procede_text_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div.procede_text").css({"display": "none"});
			$("div#procede_text_"+id).css({"display": "block"});
		} else {
			$("div.procede_text").fadeOut('fast');
			$("div#procede_text_"+id).fadeIn('fast');
		}
	}
}

function switchHistoire(id) {
	if ($("p#histoire_text_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("p.histoire_text").css({"display": "none"});
			$("p#histoire_text_"+id).css({"display": "block"});
		} else {
			$("p.histoire_text").fadeOut('fast');
			$("p#histoire_text_"+id).fadeIn('fast');
		}
	}
}

function switchMoutardePopup(id) {
	if ($("div#moutardepopup_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div.moutardepopup").css({"display": "none"});
			$("div#moutardepopup_"+id).css({"display": "block"});
		} else {
			$("div.moutardepopup").fadeOut('fast');
			$("div#moutardepopup_"+id).fadeIn('fast');
		}
	}
}

$(document).ready(function() {
	// ticker
	//$("ul#ticker").liScroll();
	
	// menu -> sous menus au survol
	$("#top_menu > a").mouseover(function() {
		var sm = $(this).attr("id").substr(3, 1); // bug de IE, on ne peut pas faire négatif genre substr(-1)
		showSubMenu(sm);
	});
	
	// apparition des produits au survol des miniatures
	$("#products_thumbs > a").mouseover(function() {
		var p = $(this).attr("id").substr(14, 1); // bug de IE, on ne peut pas faire négatif genre substr(-1)
		switchProduct(p);
	});
	$("#chefs_thumbs > a").mouseover(function() {
		var p = $(this).attr("id").substr(11, 1); // bug de IE, on ne peut pas faire négatif genre substr(-1)
		switchChef(p);
	});
	
	// pop-up de news
	$("a.news_thumb").click(function() {
		var id = $(this).attr("id");
		var nid = id.split('_');
		//alert(nid[2]);
		$("#dialog").load("/fr/news.php?id="+nid[2]).dialog({
			modal: true,
			overlay: true,
			shadow: true,
			width: 700,
			height: 400,
			resizable: false,
			close: function() {$("#dialog").dialog('destroy');},
			title: '<img src="/fr/img/actualites.png" />'
		});
	});
	
	// pop-up de coup de coeur
	$("a.coupdecoeur_thumb").click(function() {
		var id = $(this).attr("id");
		var nid = id.split('_');
		$("#dialog").load("/fr/coups-de-coeur.php?id="+nid[2]).dialog({
			modal: true,
			overlay: true,
			shadow: true,
			width: 700,
			height: 400,
			resizable: false,
			close: function() {$("#dialog").dialog('destroy');},
			title: '<img src="/fr/img/coup_de_coeur.png" />'
		});
	});
	
	// pop-up de livred'or
	$("a#new_message").click(function() {
		var id = this.id.substr(11, 1);
		$("#dialog").load("/fr/guestbook_form.php").dialog({
			modal: true,
			overlay: true,
			shadow: true,
			width: 700,
			height: 400,
			resizable: false,
			close: function() {$("#dialog").dialog('destroy');},
			title: '<img src="/fr/img/livre_d_or.png" />'
		});
	});
	
	// pop-up de réservation
	$("a.reservez").click(function() {
		var id = this.id.substr(11, 1);
		$("#dialog").load("/fr/reservez.php").dialog({
			modal: true,
			overlay: true,
			shadow: true,
			width: 800,
			height: 550,
			resizable: false,
			close: function() {$("#dialog").dialog('destroy');},
			title: '<img src="/fr/img/reservez.jpg" />'
		});
	});
	
	// pop-up de moutardes
	$("a.moutardes").click(function() {
		var id = this.id.substr(11, 1);
		$("#dialog").load("/fr/moutardes_popup.php").dialog({
			modal: true,
			overlay: true,
			shadow: true,
			width: 700,
			height: 400,
			resizable: false,
			close: function() {$("#dialog").dialog('destroy');},
			title: '<img src="/fr/img/les_moutardes.png" />'
		});function switchProduct(id) {
	if ($("img#product_img_"+id).css("display") == "none") {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			$("div#products_image > img").css({"display": "none"});
			$("div#products_text > div").css({"display": "none"});
			$("img#product_img_" + id).css({"display": "block"});
			$("div#product_text_" + id).css({"display": "block"});
		} else {
			$("div#products_image > img").fadeOut('fast');
			$("div#products_text > div").fadeOut('fast');
			$("img#product_img_" + id).fadeIn('fast');
			$("div#product_text_" + id).fadeIn('fast');
		}
	}
}
	});
	
	$("#marquee").marquee();
	
	$('#manger_bouger').innerfade({
		speed: 'slow', 
		timeout: 4000, 
		type: 'sequence', 
		containerheight: '30px' 
	});
	
	/*$('#news_right').innerfade({
		speed: 'slow', 
		timeout: 4000, 
		type: 'sequence', 
		containerheight: '150px' 
	});

	
	$('#coupdecoeur_right').innerfade({
		speed: 'slow', 
		timeout: 4000, 
		type: 'sequence', 
		containerheight: '150px' 
	});*/

	$('#news_right').cycle({
		fx: 'fade'
	});

	$('#coupdecoeur_right').cycle({
		fx: 'fade'
	});
	
	$('#defil_visites div').innerfade({
		speed: 'slow', 
		timeout: 5000, 
		type: 'sequence', 
		containerheight: '30px' 
	});
	
	//var colors = new Array("#e4c208", "#cc061d", "#b37915", "#b2ca21");
	//var random_color = colors[Math.floor(Math.random()*colors.length)] 
	//$("div#bottom").css({"background-color":  random_color});

});

