/* Monta links de tags */
submit_tag = function(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,"_");
  argumento = argumento.replace(/-/g,"");
  window.open ("http://info.abril.com.br/reviews/tags/tagslist.shtml?"+argumento.toLowerCase()+"1");
}

/* Aplica cores nas notas dos reviews */
corReview = function(){
  var nota=new Array();
  nota[0] = ["0" ,"nota0"];
  nota[1] = ["1" ,"nota1"];
  nota[2] = ["2" ,"nota2"];
  nota[3] = ["3" ,"nota3"];
  nota[4] = ["4" ,"nota4"];
  nota[5] = ["5" ,"nota5"];
  nota[6] = ["6" ,"nota6"];
  nota[7] = ["7" ,"nota7"];
  nota[8] = ["8" ,"nota8"];
  nota[9] = ["9" ,"nota9"];
  nota[10]= ["10","nota10"];

  jQuery(".nota").each(function(){   
      var numNota = parseInt( jQuery(this).find('.num-nota').first().html() );
      for(i = 0; i < nota.length; i++) 
      {
        if( numNota == nota[i][0])
        {
          var str = jQuery(this).find(".num-nota").text();
          if(str == "10.0" || str == "9.0" || str == "8.0" || str == "7.0" || str == "6.0" || str == "5.0" || str == "4.0" || str == "3.0" || str == "2.0" || str == "1.0" || str == "0.0") {
            jQuery(this).find(" .num-nota").text(str.replace(".0", ""));
          }
          else 
          {
            jQuery(this).find(" .num-nota").text(str.replace(".", ","));    
          }
          jQuery(this).attr('class','nota ' + nota[i][1]);
        }
      }
  });
}
/* Remove o .00 do valor do produto */
addCommas = function(nStr) {
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + '.' + '$2');
  }
  return x1 + x2;
}

notaReview = function(){
  jQuery(".valor span").each(function(){
    var str2 = jQuery(this).html();
    var replaced = str2.replace(".00", "");
    jQuery(this).html(addCommas(replaced));
 });
}      
/* Muda imagens e video do review e */
imgsReview = function(){
  jQuery(".review-thumbs span a").click(function(){
    if(jQuery(this).attr("rel") == "video") 
    {
      jQuery(".review-imagem").html(pathVideo);
      jQuery(".review .nota-review").hide();
      jQuery(".credito-foto").hide();      
    }
    else 
    {
      jQuery(".review-imagem").html('<img src="http://info.abril.com.br' + jQuery(this).attr("href")+ '" />');
      jQuery(".review .nota-review").show();
      jQuery(".credito-foto").show();      
    }
    return false;
  });
}


