/**
 * @author Maurizio Mangione
 * @version 1.0
 */

$(document).ready(function(){
	
	//h1 & h2 text replacement
	$("h1").html("<img src=\"img/de-stefani.gif\" alt=\"De Stefani\" />");
	$("h2").html("<img src=\"img/mg-anodi-international.gif\" alt=\"De Stefani\" />");
		
	//products accordion
	if ($("#prod").size()) {
		$("#prod").accordion({
			autoHeight: false,
			header: ".hd"
		});
	};
	
	//flags behaviours
	$("#flags li a").each(function() {
		var lang = $(this).text();
		$(this).html('<img src="img/flag_' + lang + '.gif" alt="' + lang + '" />');
    });
	
	params = document.location.search;
	l = params.indexOf('lang=');
	code = params.substring(l+5, params.length)
	if(code==""){
		code = "it";
	}
	if(l=="-1"){
		var lang = "it"
	};
	$("#flags img").not("#flags li a.a img").css("opacity", 0.4);
	$("#flags img").hover(
      function() {
        $(this).stop().animate({
			opacity: 1
		},300);
      }, 
      function() {
        if ($(this).attr("alt")!=code) {
			$(this).stop().animate({
				opacity: 0.4
			}, 300);
		}
      }
    );
	
	//tab area clickable
	$("#menu li").not(".active").click(function(){
		dest = $(this).children("a").attr("href");
		document.location = dest; 
	});
	
	//brochure download
	$("#sel").css("display","none");
	
	$("#lang li").hover(
		function () {
			$("#lang li ul").css("display", "");
      },
      	function () {
        	$("#lang li ul").css("display", "none");
      }
    );

	
	
}); //end of document ready
