function BrowserUpdate(conteiner){
  if(jQuery.browser.mozilla && jQuery.browser.version.substr(2,1)<"9" || jQuery.browser.msie && jQuery.browser.version.substr(0,1) < "7"){
    this.conteiner = conteiner;
    this.base_url = "http://www.baixatudo.com.br/";
    this.barra;
    this.btfechar;

    this.init();
  }
};

BrowserUpdate.prototype.init = function() {
  this.createDom();
};

BrowserUpdate.prototype.createDom = function() {
  var versionBrowser;

  if(jQuery.browser.mozilla) versionBrowser = "Firefox";
  if(jQuery.browser.msie) versionBrowser = "Internet Explorer";

  var dom ="<div id='barra-BrowserUpdate'>";
  dom +="<div id='barra-BrowserUpdate-content' style='float:left;padding-left:10px;'>";
  dom +="<p><strong>Seu " + versionBrowser + " est&aacute; desatualizado.</strong><br />";
  dom +="Para uma melhor visualiza&ccedil;&atilde;o do site atualize-o ou escolha outro navegador.</p>";
  dom +="<ul>";
  if(jQuery.browser.msie){
    dom +="<li><a href='http://www.baixatudo.com.br/internet-explorer-8?utm_source=BrowserUpdate' class='barra-BrowserUpdate-ie' title='Internet Explorer 8'><img src='"+this.base_url+"/images/browser-update/ie.gif' alt='Internet Explorer' /></a></li>";
    dom +="<li><a href='http://www.baixatudo.com.br/mozilla-firefox-3-6?utm_source=BrowserUpdate' class='barra-BrowserUpdate-ff' title='Mozilla Firefox 3.6'><img src='"+this.base_url+"/images/browser-update/ff.gif' alt='Mozilla Firefox' /></a></li>";
  }
  else{
    dom +="<li><a href='http://www.baixatudo.com.br/mozilla-firefox-3-6?utm_source=BrowserUpdate' class='barra-BrowserUpdate-ff' title='Mozilla Firefox 3.6'><img src='"+this.base_url+"/images/browser-update/ff.gif' alt='Mozilla Firefox' /></a></li>";
    dom +="<li><a href='http://www.baixatudo.com.br/internet-explorer-8?utm_source=BrowserUpdate' class='barra-BrowserUpdate-ie' title='Internet Explorer 8'><img src='"+this.base_url+"/images/browser-update/ie.gif' alt='Internet Explorer' /></a></li>";
  }
  dom +="<li><a href='http://www.baixatudo.com.br/google-chrome-4?utm_source=BrowserUpdate' class='barra-BrowserUpdate-gc' title='Google Chrome 4'><img src='"+this.base_url+"/images/browser-update/gc.gif' alt='Google Chrome' /></a></li></ul>";
  dom +="<a href='#' class='barra-BrowserUpdate-fechar' title='Fechar'>fechar</a>";
  dom +="</div>";
  dom +="</div>";
  $(this.conteiner).append(dom);

  this.barra = $("#barra-BrowserUpdate");
  this.btfechar = $(".barra-BrowserUpdate-fechar", this.barra);
  this.createStyle();
};

BrowserUpdate.prototype.createStyle = function() {
  this.barra.css({
    'background' : '#ffffd6',
    'border-bottom' : '1px solid #f0e4c3',
    'border-top' : '1px solid #f0e4c3',
    'display' : 'none',
    'font-family' : 'arial',
    'margin' : '0',
    'padding' : '9px 0',
    'position' : 'relative',
    'width' : '100%'
  });
  $("#barra-BrowserUpdate-content", this.barra).css({
    'height' : '40px',
    'margin' : '0 auto',
    'width' : '940px'
  });
  $("strong", this.barra).css({
    'color' : '#333',
    'font-size' : '14px'
  });
  $("p", this.barra).css({
    'color' : '#666',
    'float' : 'left',
    'font-size' : '12px',
    'line-height' : '18px',
    'margin' : '2px 20px 0 0',
    'text-align' : 'left'
  });
  $("li", this.barra).css({
    'float' : 'left',
    'list-style' : 'none',
    'margin-right' : '5px'
  });
  $("a", this.barra).css({
    'background' : '#fff url('+this.base_url+'/images/browser-update/sprite-bt.gif) no-repeat 0 0',
    'display' : 'block',
    'height' : '40px',
    'outline' : 'none',
    'overflow' : 'hidden',
    'width' : '150px'
  });
  this.btfechar.css({
    'background' : 'url('+this.base_url+'/images/browser-update/bt-close.gif) no-repeat 0 0',
    'height' : '15px',
    'position' : 'absolute',
    'right' : '5px',
    'text-indent' : '-99999px',
    'top' : '5px',
    'width' : '15px'
  });
  this.creatEvents();
};

BrowserUpdate.prototype.creatEvents = function() {
  $(window).resize(function() {
    $("#barra-BrowserUpdate").css({
      'width' : $(window).width() + 'px'
    });
    $(".barra-BrowserUpdate-fechar", "#barra-BrowserUpdate").css({
      'right' : '5px'
    });
  });
  this.barra.slideDown('slow');
  $("a", this.barra).bind('mouseover', function() {
    $(this).css({
      'background-position' : '0 -40px'
    });
  }).bind('mouseout', function() {
      $(this).css({
        'background-position' : '0 0'
      });
    }).bind('mousedown', function() {
      $(this).css({
        'background-position' : '0 -80px'
      });
      $(this).children('img').css({
        'margin-top' : '1px'
      });
    });
  this.btfechar.bind('click', function() {
    $("#barra-BrowserUpdate").slideUp('slow', function() {
      $(this).css({
        'display' : 'none'
      });
      $(this).remove();
    });
    return false;
  }).bind('mouseover', function() {
    $(this).css({
      'background-position' : '0 -15px'
    });
  }).bind('mouseout', function() {
    $(this).css({
      'background-position' : '0 0'
    });
  }).bind('mousedown', function() {
    $(this).css({
      'background-position' : '0 -30px'
    });
  });
};

