var $jQ = jQuery.noConflict();

/* Limpa string */
function limpa_string(argumento) {
  argumento = argumento.replace(/ /g,"_");
  argumento = argumento.replace(/Á/g,"A");
  argumento = argumento.replace(/á/g,"a");
  argumento = argumento.replace(/À/g,"A");
  argumento = argumento.replace(/à/g,"a");
  argumento = argumento.replace(/Â/g,"A");
  argumento = argumento.replace(/â/g,"a");
  argumento = argumento.replace(/ã/g,"a");
  argumento = argumento.replace(/Ã/g,"A");
  argumento = argumento.replace(/ç/g,"c");
  argumento = argumento.replace(/Ç/g,"C");
  argumento = argumento.replace(/É/g,"E");
  argumento = argumento.replace(/é/g,"e");
  argumento = argumento.replace(/Ê/g,"E");
  argumento = argumento.replace(/ê/g,"e");
  argumento = argumento.replace(/Í/g,"I");
  argumento = argumento.replace(/í/g,"i");
  argumento = argumento.replace(/Ó/g,"O");
  argumento = argumento.replace(/ó/g,"o");
  argumento = argumento.replace(/Ô/g,"O");
  argumento = argumento.replace(/ô/g,"o");
  argumento = argumento.replace(/õ/g,"o");
  argumento = argumento.replace(/Ú/g,"U");
  argumento = argumento.replace(/ú/g,"u");
  argumento = argumento.replace(/!/g,"_");
  return (argumento.toLowerCase());
}
/* SubMenu Flutuante */      
    function montaMenuFlut() {
      jQuery(".menu-links li").mouseover(function(){
        var id = jQuery(this).find("a").attr("id");
        var position = jQuery(this).position();

        if (jQuery(".flut-"+ id).is(":visible")){
            jQuery(".flut-"+ id).stop(true, true).show();    
         }
        else {       
          jQuery(".menu-flut").stop(true, true).hide();
                
          if(id == "nm-blogs") {
            jQuery(".flut-"+id).css("left",(position.left - 40));
            var bgPosition = ((jQuery(this).width() / 2) + 27) + "px 0";
          }
          else if(id == "nm-reviews") {
            jQuery(".flut-"+id).css("left",(position.left - 80));
            var bgPosition = ((jQuery(this).width() / 2) + 67) + "px 0";
          }        
          else if(id == "nm-gadgets") {
            jQuery(".flut-"+id).css("left",(position.left - 120));
            var bgPosition = ((jQuery(this).width() / 2) + 107) + "px 0";
          } 
          else if(id == "nm-downloads") {
            jQuery(".flut-"+id).css("left",(position.left - 160));
            var bgPosition = ((jQuery(this).width() / 2) + 147) + "px 0";
          }                
          else if(id == "nm-dicas") {
            jQuery(".flut-"+id).css("left",(position.left - 200));
            var bgPosition = ((jQuery(this).width() / 2) + 187) + "px 0";
          }             
          else if(id == "nm-forum") {
            jQuery(".flut-"+id).css("left",(position.left - 240));
            var bgPosition = ((jQuery(this).width() / 2) + 227) + "px 0";
          } 
          else if(id == "nm-tv") {
            jQuery(".flut-"+id).css("left",(position.left - 280));
            var bgPosition = ((jQuery(this).width() / 2) + 267) + "px 0";
          }             
          else if(id == "nm-dev") {
            jQuery(".flut-"+id).css("left",(position.left - 320));
            var bgPosition = ((jQuery(this).width() / 2) + 307) + "px 0";
          } 
          else if(id == "nm-revista") {
            jQuery(".flut-"+id).css("left",(position.left - 360));
            var bgPosition = ((jQuery(this).width() / 2) + 347) + "px 0";
          }
          else if(id == "nm-ping") {
            jQuery(".flut-"+id).css("left",(position.left - 400));
            var bgPosition = ((jQuery(this).width() / 2) + 387) + "px 0";
          }
          else if(id == "nm-topicos") {
            jQuery(".flut-"+id).css("left",(position.left - 440));
            var bgPosition = ((jQuery(this).width() / 2) + 427) + "px 0";
          }                                                                      
          else {
            jQuery(".flut-"+id).css("left",position.left);
            var bgPosition = ((jQuery(this).width() / 2) -13) + "px 0";
          }
            
            jQuery(".seta-menu").css('backgroundPosition', bgPosition);
            jQuery(".flut-"+id).css("top",position.top + 52);
            jQuery(".flut-"+ id).stop(true, true).show();
        }
      });
     jQuery(".menu-links li").mouseout(function(){
        var id = jQuery(this).find("a").attr("id");
        jQuery(".flut-"+ id).stop(true, true).hide();
      });  
      jQuery(".menu-flut").mouseenter(function(){
        jQuery(this).stop(true, true).show();   
      });
      jQuery(".menu-flut").mouseleave(function(){
        jQuery(this).stop(true, true).hide();
      }); 
    }  

/* Seleciona menu e mostra submenu superior */  
function mount_menu_sup() { 
  if(typeof(menuSelected) != "undefined") {  
    jQuery("#" + menuSelected).addClass("selected");
  }
  if(typeof(ativaSubMenu) != "undefined") {
    if(ativaSubMenu == "") {
      return false;
    }
    ativaSubMenu = limpa_string(ativaSubMenu);
    jQuery("." + ativaSubMenu).addClass("selected");
  }
} 
  

//Mostra e esconde sub-menu flutuante
function mshow(obj,id) {
//alert(id);
  if(id != undefined){
    var position = jQuery("#"+id).position();
    jQuery("#"+ obj).css("top",position.top + 25);
    jQuery("#"+ obj).css("left",position.left);
  }
  jQuery("#"+ obj).show();
}
function mhide(obj) {
	  jQuery("#"+ obj).hide();
}

function changeTabs(divName, desabilita_aba){
  //desabilita_aba = typeof(desabilita_aba) != 'undefined' ? desabilita_aba : true;
  if(desabilita_aba === undefined){
   desabilita_aba = false;
  }
  
  jQuery(divName + " .tab:first").show();
  jQuery(divName + " .topo-abas a.primeiro").addClass("selecionado");
  jQuery(divName + " .topo-abas a").click(function(){
    if (! jQuery(this).hasClass('selecionado')) {
      jQuery(divName + " .topo-abas a").removeClass("selecionado");
      jQuery(divName + " .tab").hide();
      jQuery(this).addClass("selecionado");      
      jQuery(jQuery(this).attr("href")).show();
    } else if (! desabilita_aba) {
      jQuery(divName + " .topo-abas a").removeClass("selecionado");
      jQuery(jQuery(this).attr("href")).hide();
      jQuery(divName + " .topo-abas a.primeiro").addClass("selecionado");
      jQuery(divName + " .tab:first").show();
    }
    return false;
  });
};
showHide = function(divName2,statusDiv){
  var imgMode = statusDiv; 
  if(statusDiv == "fechado") {
    jQuery(jQuery(divName2 + " .topo-tit-box a").attr("href")).hide();
    jQuery(divName2 + " .topo-tit-box img").attr("src","/v0/imagem/icones/seta-abaixo-preta.jpg");  
  }
  else {
    jQuery(divName2 + " .topo-tit-box img").attr("src","/v0/imagem/icones/seta-acima-preta.jpg");
  }
  jQuery(divName2 + " .topo-tit-box a").click(function(){
    jQuery(jQuery(this).attr("href")).slideToggle('slow');
    if(imgMode == "fechado") {
      jQuery(divName2 + " .topo-tit-box img").attr("src","/v0/imagem/icones/seta-acima-preta.jpg");
      imgMode = "aberto";
    }
    else {
      jQuery(divName2 + " .topo-tit-box img").attr("src","/v0/imagem/icones/seta-abaixo-preta.jpg");
      imgMode = "fechado";
    }
    return false;
  });
};
showHideMenu = function(divName2){
  var imgMode = "desce";
  jQuery(divName2 + " a.link-menu").click(function(){
    jQuery(jQuery(this).attr("href")).slideToggle('slow');
    if(imgMode == "desce") {
      jQuery(divName2 + " img").attr("src","/v0/imagem/icones/seta-acima-preta-menu.jpg");
      imgMode = "sobe";
    }
    else {
      jQuery(divName2 + " img").attr("src","/v0/imagem/icones/seta-abaixo-preta-menu.jpg");
      imgMode = "desce";
    } 
    return false;
  });
}; 
/* Transporta as divs com publicidade */
teletransporte = function(nameDivOas, nameDivOasDisplay) {
  var elemDivOas = document.getElementById(nameDivOas);
  var elemDivOasDisplay = document.getElementById(nameDivOasDisplay);
  if(elemDivOasDisplay != null && elemDivOas != null){
    elemDivOasDisplay.innerHTML='';
    elemDivOasDisplay.appendChild(elemDivOas);
    elemDivOas.style.display='block';
  }
}
function setCookie(cookie_name, cookie_value, expire_in_days)
{
	var cookie_expire = "; path=/";

	  if (expire_in_days != null)
	  {
	    var expire = new Date();
	    expire.setTime(expire.getTime() + 1000*60*60*parseInt(expire_in_days));
	    cookie_expire += "; expires=" + expire.toGMTString();
	  }

	  document.cookie = escape(cookie_name) + "=" + escape(cookie_value) + cookie_expire;
}

function getCookie(cookie_name)
{
  if (!document.cookie.match(eval("/" + escape(cookie_name) + "=/")))
  {
   return false;
  }

return unescape(document.cookie.replace(eval("/^.*?" + escape(cookie_name) + "=([^\\s;]*).*$/"), "$1"));
}
/* Share Orkut */
function enviarOrkut(titulo, subtitulo, link, imgParentSelector){
  var params = {};
  params[google.orkut.share.Field.TITLE] = titulo;
  params[google.orkut.share.Field.DESTINATION_URL] = link;
  imgs = [];
  jQuery( imgParentSelector+' img').each(function() {
      imgs.push(jQuery(this).attr('src'));
  });
  params[google.orkut.share.Field.CONTENT] = subtitulo;
  params[google.orkut.share.Field.THUMBNAIL] = imgs;
  var connection = new google.orkut.share.Connection(params);
  connection.send('orkut.com', {}); 
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
	  
