var carrinhoTimer;
var openByHover = true;
carrinho_fechado = true;
$(function()
    {
	$('.comunidades').parent().hover(function(e){

	    $('.comunidades').addClass('selected');
	    $(".comunidades").parent().addClass('selected');
	}, function(e){
	    $('.comunidades').removeClass('selected');
	    $(".comunidades").parent().removeClass('selected');

	})
	$('.produtos').parent().hover(function(e){

	    $('.produtos').addClass('selected');
	    $(".produtos").parent().addClass('selected');
	}, function(e){
	    $('.produtos').removeClass('selected');
	    $(".produtos").parent().removeClass('selected');

	})
	
		$("#carrinho").hover(function(e){
							clearTimeout(carrinhoTimer);	  
						}
						,
						function(e)
						{
								if(!carrinho_fechado)
								{
									carrinhoTimer = setTimeout("mostra_carrinho()",2000)
								}
							
						});
});

function change_foto()
{
    if($('div.scrollable div.active div.img_panel_content'))
    {
		$('div#img_placeholder').hide();
		nsrc = $('div.scrollable div.active img').attr('src').split('/',-1);
		nsrc = base_url+nsrc[nsrc.length -1];
		$('div#img_placeholder img').attr('src',nsrc);
		$('div#img_placeholder').fadeIn(300);
    }
    
}
var obj = null;

function checkHover() {
      if (obj) {
          obj.find('ul').fadeOut('fast');
       } //if
    } //checkHover
 
    $(document).ready(function() {
      $('#Nav > li').hover(function() {
        if (obj) {
            obj.find('ul').fadeOut('fast');
           obj = null;
       } //if

        $(this).find('ul').fadeIn('fast');
     }, function() {
        obj = $(this);
         setTimeout(
            "checkHover()",
            400);
      });
   });


	



function mostra_carrinho()
{	
		if(!carrinho_fechado)
		{
			carrinho_fechado = true;
			$("#carrinho").animate({ 
				width: "115px",
				right: "170px",
				height: "23px",
				overflow: "hidden"
			  }, 200 );
			openByHover = true;
		}
		else {
			carrinho_fechado = false;
			 $("#carrinho").animate({ 
				width: "250px",

				right: "20px",
				height: "300px",
				overflow: "auto"
			  }, 200 );
			 openByHover = false
		} 
}

