function onResize() {
  var flash = $('#flash');
  flash.width( $(window).width() < 900 ? 900 : '100%' )
  flash.height( $(window).height() < 800 ? 800 : '100%' );

  $("#unity3d").css({
    top: 61,
    left: Math.round($(window).width() - 900 ) / 2
  });

  if($.browser.msie) {
    if($(window).height() < 800)
      $("html, body").css('overflow','auto');
    else
      $("html, body").css('overflow','hidden');
  }
}

function _setHeight(height) {
  $(document.body).height(height);
  $('#flash').height(height);
}

function disableScroll() {
  document.body.__height = $(document.body).height();
  _setHeight('100%');
}

function enableScroll() {
  _setHeight($(window).height() < 800 ? 800 : '100%');
}

$(document).ready(function() {
  var flashvars = {
    config: "xml/application.xml",
    debug: "false",
    promo: 'encerrada'
  };

  if (document.domain.indexOf(".com.br") > -1)
    flashvars['country'] = 'BR';
              
  var params = {
    menu: "false",
    allowFullScreen: "true",
    allowScriptAccess: "always",
    allowNetworking: "all",
    bgcolor: "#000000"
  };

  if (navigator.userAgent.toLowerCase().indexOf('firefox') >= 0 && navigator.userAgent.indexOf("Windows") >= 0)
    params['wmode'] = 'transparent';

  swfobject.embedSWF( "swf/SiteLoader.swf", "content", "100%", "100%", "9.0.115", "swf/expressInstall.swf", flashvars, params, { id: "flash", name: "flash" });

  if (!swfobject.hasFlashPlayerVersion('9'))
    window.location.href = 'noflash.html';

});

$(window)
  .resize(onResize)
  .load(onResize);

function showUnity() {
  $("#unity3d")
    .width(900)
    .height(500);

  if($.browser.msie) {
    $("html, body").css('overflow','hidden');
    $("#unity3d").css({left: Math.round($(window).width() - 900 ) / 2});
  }

  disableScroll();
  $("#unity3d iframe").height(500);
  show('unity3d');
}

function hideUnity() {
  enableScroll();

  if($.browser.msie) {
    onResize();
    $("#unity3d").css({left:'-3000px', position: 'absolute'});    
  }

  $("#unity3d iframe").height(1);
  hide('unity3d');
}

function restart( ) {
  dispatchUnityEvent( "unity3d", "PlayAgain", "" );
}

function BTMaestro()
{
(new Image).src = "http://atmo.unilever.predicta.net/atmo/cap/$s=223$cke=1$cks=1$sw=1280$sh=1024$jvm=1$nl=pt-BR$un=btu$ru=http%3A%2F%2Fpredicta.net$zr="+Math.random()*1000;
}
