function getBrowserHeight(){
 if (window.innerHeight){
  return window.innerHeight;}	
 else if (document.documentElement && document.documentElement.clientHeight != 0){
  return document.documentElement.clientHeight;}
 else if (document.body){
  return document.body.clientHeight;}
 return 0;
}

function getBrowserWidth(){
 if (window.innerWidth){
  return window.innerWidth;}
 else if (document.documentElement && document.documentElement.clientWidth != 0){
  return document.documentElement.clientWidth;}
 else if (document.body){
  return document.body.clientWidth;}
 return 0;
}

function dynamicCenter(){
 var browserHeight = getBrowserHeight();
 var browserWidth = getBrowserWidth();
 var obj = document.getElementById('site-wrapper');
 if (!obj) {
  if (parent.frames['site']){
    obj = parent.frames['site'].document.getElementById('site-wrapper');
  }
 }
 if (obj) {
  if  (browserHeight > 0 && browserWidth > 0) {
    if ((browserHeight < 600) && (browserWidth < 790)) {
     obj.className = 'resolucao-safe';}
    else if (browserHeight < 600) {
     obj.className = 'resolucao-safe-ver';}
    else if (browserWidth < 790) {
     obj.className = 'resolucao-safe-hor';}
    else {
     obj.className = 'resolucao-ok';}
  }
 }
}

function addEvent(o,t,h){
 var s=window.execScript?"i":/safari/i.test(navigator.userAgent)?"s"
:document.clientWidth||window.opera&&!window.getSelection?"k":document.addEventListener?false:"o",
d="DOMContentLoaded";
 if (t.toLowerCase()=="load")o=initLoad(o,s);
 if (!o)return false;
 if (o.addEventListener&&!(s&&t==d))o.addEventListener(t,h,false);
 else{
  if (!h.$$guid)h.$$guid=addEvent.guid++;
  if (!o.evs)o.evs={};
  var hs=o.evs[t];
  if (!hs){hs=o.evs[t]={};if (o['on'+t])hs[0]=o['on'+t];}
  hs[h.$$guid]=h;o['on'+t]=handleEvent;
  if (t==d)initDOMLoad(o,h,s);
 }
 function initLoad(o,s){if (o&&(o==window||o==document||o==document.body)){
  if (s=="k")o=document;
  else element=window;
  if (!addEvent.waitLoad&&s&&s!="k"&&s!="s"){
   if (document.ids)document.tags.body.position="absolute";
   addEvent.waitLoad=true;
   addEvent(o,'load',function(){addEvent.waitLoad=false;});
   (function(){if (addEvent.waitLoad){var o=document.body;
     if(!testLoad(o)&&!testLoad((o=document))&!testLoad((o=window)))
      setTimeout(arguments.callee,10);else{addEvent(o,'load',o.onload);o.onload=handleEvent;}}
    })();
  }}return o;
 }
 function testLoad(o){return !o||typeof o.onload!="function"||o.onload==handleEvent?false:true;}
 function initDOMLoad(o,h,s){addEvent.waitDOM=true;
  if (s=="s"||s=="k")
   (function(){if (addEvent.waitDOM){if(/loaded|complete/i.test(document.readyState))
     doDOMLoad(); else setTimeout(arguments.callee,10);}})();
  else if (s=="i")
   (function(){if (addEvent.waitDOM){
    /*@cc_on @*/ /*@if (@_win32 || @_win64)
    var e=document.createElement('doc:rdy');
    try{e.doScroll('left');e=null;doDOMLoad();}catch(err){setTimeout(arguments.callee,10);}
    @end @*/
   }})();
  else addEvent(o,"load",h);
 }
 function doDOMLoad(){var t="DOMContentLoaded";addEvent.waitDOM=false;(window["on"+t])({"type":t});}
}
addEvent.guid=1;
function removeEvent(o,t,h){
 if (o.removeEventListener)o.removeEventListener(t,h,false);
 else if (o.evs&&o.evs[t]&&h.$$guid)delete o.evs[t][h.$$guid];
}
function handleEvent(ev){var r=true;
 ev = ev||fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
 var hs=this.evs[ev.type];
 for (var i in hs){this.$$h=hs[i];
  if (this.$$h(ev)===false)r=false;}
 if (this.$$h)this.$$h=null;
 return r;
}
function fixEvent(ev){
 if (ev){ev.preventDefault=fixEvent.preventDefault;ev.stopPropagation=fixEvent.stopPropagation;}
 return ev;}
fixEvent.preventDefault=function(){this.returnValue=false;}
fixEvent.stopPropagation=function(){this.cancelBubble=true;}

addEvent(window, 'DOMContentLoaded', dynamicCenter);
addEvent(window, 'resize', dynamicCenter);
