jQuery(function() {
	// Initialisation du menu deroulant
	$("ul#menu").superfish({
		autoArrows: false,
		animation: {height: "show"},
		speed: "fast",
		delay: 400
	});

	$("#privacy span").click(function() {
		var tab = $("body").attr("id").split("_");
		window.open("privacypolicy_" + tab[1] + ".html", "", "scrollbars=yes,width=800,height=550,top=50,left=150");
	});

	// Initialisation des input text
	// Pour que la valeur par defaut s'efface quand on clique dedans
	$("#user").focus(function() {
		if($(this).val() == "Login")
			$(this).val("");
	});

	$("#password").focus(function() {
		if($(this).val() == "Password")
			$(this).val("");
	});

	$("#user").blur(function() {
		if($(this).val() == "")
			$(this).val("Login");
	});

	$("#password").blur(function() {
		if($(this).val() == "")
			$(this).val("Password");
	});

	$("#msds_textbox").focus(function() {
		if($(this).val() == "MSDS search by item name" || $(this).val() == "Recherche MSDS par nom d'article")
			$(this).val("");
	});

	$("#search_textbox").focus(function() {
		if($(this).val() == "Enter product name" || $(this).val() == "Entrez un nom de produit")
			$(this).val("");
	});

	$("#msds_textbox").blur(function() {
		if($(this).val() == "")
			var tab = $("body").attr("id").split("_");
		if(tab[1] == "fr")
			$(this).val("Recherche MSDS par nom d'article");
		else if(tab[1] == "en")
			$(this).val("MSDS search by item name");
	});

	$("#search_textbox").blur(function() {
		if($(this).val() == "")
			var tab = $("body").attr("id").split("_");
		if(tab[1] == "fr")
			$(this).val("Entrez un nom de produit");
		else if(tab[1] == "en")
			$(this).val("Enter product name");
	});

	$("#search_textbox").autocomplete("search.php", {width: 165, selectFirst: false});
	$("#msds_textbox").autocomplete("msds.php", {width: 165, selectFirst: false});

	$("#msds_textbox").result(
		function(event, data, formatted) {
			if(data) window.open(data[1]);
		}
	);
});

