$(document).ready(function() {
/** Nav **/
$("#nav").hover(
     function() {},
     function() {        
       $('#nav>li').fadeTo("fast", 1.0);
     }
);

$("#nav>li").hoverIntent(
    function(){
       $(this).siblings().fadeTo("fast", 0.2); // Fade other items to 30%
       $(this).fadeTo("slow", 1.0); // Fade current to 100%

    },
    function(){            
       $(this).fadeTo("fast", 1.0); // This should set the other's opacity back to 100% on mouseout   
    });

/** Replace flags inverter para quando ingles estiver ativado **/
    $('li.pt-br a').each(function() {
      string = $(this).text();
      filename = string.toLowerCase().replace(/ /g, '-').replace(/([^0-9a-z-])/g,'');
      $(this).html('<img src="http://www.santaluzlingerie.com/img/' + filename + 'off.gif" alt="' + string + '" />');
    });  
	$('li.en-us').each(function() {
      string = $(this).text();
      filename = string.toLowerCase().replace(/ /g, '-').replace(/([^0-9a-z-])/g,'');
      $(this).html('<img src="http://www.santaluzlingerie.com/img/' + filename + '.gif" alt="' + string + '" />');
    });  
// newsletter 
	var newsletter = $("#news-box"); 
	var abrenews = $("a.newslnk");
	 // escona inicialmente
   newsletter.hide();
   // se clicar fora esconda
$('body').click(function() {
	newsletter.hide();
 });
// se clicar dentro pare de propagar
 newsletter.click(function(event){
     event.stopPropagation();
 });
//quando clicar no link mostre a caixa
   	abrenews.click(function(){
	newsletter.show(100);
	});  

});
