$(document).ready (function () {
    $("#menu_produtos_servicos > .menu_link_esquerda > a").click(
      function () {
        $("#menu_produtos_servicos").hide();
        $("#menu_lojas").show();
        return false;
      }
    );
    $("#menu_lojas > .menu_link_esquerda > a").click(
      function () {
        $("#menu_lojas").hide();
        $("#menu_produtos_servicos").show();
        return false;
      }
    );
    
    
    // ORIGINAL
    /*
     
    $('.link_menu_esquerda').click(
      function() {
        $(this).siblings('.sub_menu_esquerda').slideToggle(
          null, 
          function() {
            $(this).parents('.item_menu_esquerda').siblings('.item_menu_esquerda').children('.sub_menu_esquerda').slideUp();
          }
        );
        return $(this).siblings('.sub_menu_esquerda').html() == null;
      }
    );
    
    */
    
    $('.link_menu_esquerda').click(
      function() {
        
        $(this).parents('.item_menu_esquerda').siblings('.item_menu_esquerda').children('.sub_menu_esquerda').hide();
        
        $(this).siblings('.sub_menu_esquerda').slideToggle(
          null, 
          function() {
            $(this).parents('.item_menu_esquerda').siblings('.item_menu_esquerda').children('.sub_menu_esquerda').slideUp();
          }
        );
        return $(this).siblings('.sub_menu_esquerda').html() == null;
      }
    );
    
    
});

/*
function (e) {
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
var key = (isIE) ? window.event.keyCode : e.which;
var obj = (isIE) ? event.srcElement : e.target;
var isNum = (key > 47 && key < 58) ? true:false;
var dotOK = false;
if(key < 32)
   return true;
return (isNum || dotOK);
}
*/

function number_format(a, b, c, d) {
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}

$(document).ready (
  function () {
    function isIE6() {
      if (navigator.appVersion.indexOf("MSIE")!=-1) {
        temp = navigator.appVersion.split("MSIE");
        temp2 = temp[1].split("version");
        version = parseFloat(temp2[0]);
        return version < 7;
      }
      else
        return 0;
    }
    if (true || isIE6()) {
      $('.rollover').not('a').each(
        function() {
          $(this).attr('original_background-image', $(this).attr('background-image'));
          $(this).attr('original_background-color', $(this).attr('background-color'));
          $(this).attr('original_cursor', $(this).attr('cursor'));
          $(this).hover(
            function() {
              $(this).attr('background', 'transparent none');
              $(this).attr('cursor', 'pointer');
              return false;
            },
            function() {
              $(this).attr('background', $(this).attr('original_background-color') + " " + $(this).attr('original_background-image'));
              $(this).attr('cursor', $(this).attr('original_cursor'));
              return false;
            }
          );
        }
      );
    }
    $('.autoclean').each(
      function() {
        if (!$(this).attr('original_value'))
          $(this).attr('original_value', $(this).val());
        $(this).hover(
          function() {
            if (($(this).val() == $(this).attr('original_value'))  && (!$(this).is('.focused')))
              $(this).val('');
            return false;
          },
          function() {
            if (($(this).val() == '') && (!$(this).is('.focused')))
              $(this).val($(this).attr('original_value'));
            return false;
          }
        );
        $(this).focus(
          function() {
            $(this).addClass("focused");
            if ($(this).val() == $(this).attr('original_value'))
              $(this).val('');
            return false;
          }
        );
        $(this).blur(
          function() {
            $(this).removeClass("focused");
            if ($(this).val() == '')
              $(this).val($(this).attr('original_value'));
            return false;
          }
        );
      }
    );
    $('#fake_password').focus(
      function() {
        $(this).hide();
        $('#password').show().focus();
      }
    );
    $('#password').blur(
      function() {
        if ($(this).val() == "") {
          $(this).hide();
          $('#fake_password').show();
        }
      }
    );
    $("input.numeric").numeric();
    $('#ulnoticias').newsTicker();
    $('.addfavorite').click(
      function() {
        if (window.sidebar) {
          window.sidebar.addPanel(document.title, location.href , "");
        } 
        else if( window.external ) {
          window.external.AddFavorite(location.href, document.title); 
        }
        return false;
      }
    );
    $('#qtd_carrinho, .qtd_carrinho').keypress(
      function (e) {
        var isIE = document.all?true:false;
        var isNS = document.layers?true:false;
        var key = (isIE) ? window.event.keyCode : e.which;
        var obj = (isIE) ? window.event.srcElement : e.target;
        var isNum = (key > 47 && key < 58) ? true:false;
        var dotOK = false;
        if(key < 32)
           return true;
        return (isNum || dotOK);
      }
    );
  }
);