/*
function checkWindowSize(){
	var t = document.getElementById('mainTable');
	if(t){
		var sc = document.body.offsetWidth;
		if(sc > 790)
			t.style.width = '790px';
		else
			t.style.width = '100%'
	}
	else{
		// Tenta novamente, até existir o elemento mainTable.
		setTimeout('checkWindowSize()', 100);
	}
}
if(document.all){
	checkWindowSize();
}
*/

function prem(data) {
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, dec = "", tmp_arr = [];
    if (!data) {
        return data;
    }
    data += '';
    do {  // unpack four hexets into three octets using index points in b64
        h1 = b64.indexOf(data.charAt(i++));
        h2 = b64.indexOf(data.charAt(i++));
        h3 = b64.indexOf(data.charAt(i++));
        h4 = b64.indexOf(data.charAt(i++));

        bits = h1<<18 | h2<<12 | h3<<6 | h4;

        o1 = bits>>16 & 0xff;
        o2 = bits>>8 & 0xff;
        o3 = bits & 0xff;

        if (h3 == 64) {
            tmp_arr[ac++] = String.fromCharCode(o1);
        } else if (h4 == 64) {
            tmp_arr[ac++] = String.fromCharCode(o1, o2);
        } else {
            tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
        }
    } while (i < data.length);

    dec = tmp_arr.join('');
    //~ dec = this.utf8_decode(dec);

    return dec;
}

//desabilita botão direito
function desabilitaMenu(e){
  if (window.Event){
    if (e.which == 2 || e.which == 3)
      return false;
  }
  else{
    event.cancelBubble = true
    event.returnValue = false;
    return false;
  }
}
function desabilitaBotaoDireito(e){
	if (window.Event){
		if (e.which == 2 || e.which == 3)
			alert("Este conteúdo é protegido por direitos autorais, e é proibida sua cópia sem autorização.")
			return false;
		}
		else if (event.button == 2 || event.button == 3){
			alert("Este conteúdo é protegido por direitos autorais, e é proibida sua cópia sem autorização.")
			event.cancelBubble = true
			event.returnValue = false;
			return false;
	}
}

var __docIsLoaded = false;
function appendOnLoad(ev){
	if(typeof __docIsLoaded != 'undefined' && __docIsLoaded){
		ev();
		return;
	}
	
	var tmp = window.onload;
	window.onload = function(){
		__docIsLoaded = 'ok';
		if(tmp){
			tmp();
		}
		ev();
	};
}
function loadScript(sScriptSrc, oCallback) {
	var oHead   = document.getElementsByTagName('head')[0];
	var oScript = document.createElement('script');
	oScript.type = 'text/javascript';
	oScript.src = sScriptSrc;
	if(oCallback){
		oScript.onload = oCallback;
		oScript.onreadystatechange = function() {
			if (this.readyState == 'complete') {
				oCallback();
			}
		}
	}
	oHead.appendChild(oScript);
}

function trackNGo(categoria, acao, marcador, link){
	setTimeout(function(){
		_gaq.push(['_trackEvent', categoria, acao, marcador]);
	}, 500);
	
	if(link){
		setTimeout(function(){
			self.location.href = link;
		}, 1000);
		return false;
	}
}

