UTF8 = {
	encode: function(s){
		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
		);
		return s.join("");
	},
	decode: function(s){
		for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
			((a = s[i][c](0)) & 0x80) &&
			(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
			o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
		);
		return s.join("");
	}
};
function openView(tipoConteudo){
	/*
	if(tipoConteudo != null){
		if(tipoConteudo == 'noticia'){
			ed = tinyMCE.getContent('noticia.texto');
			ed = escape(ed);
			parametros = $('noticiaForm').serialize();
			parametros = parametros.replace("method=save&","");
			parametros = parametros.replace("&save=Salvar","");
			parametros = parametros.replace("&save=Salvar","");
			parametros = parametros.replace("&noticia.texto=","&noticia.texto="+ed);
			url = "index.html?method=mostrarNoticia&preview=1&"+parametros;
		} else{
			ed = tinyMCE.getContent('institucional.texto');
			ed = escape(ed);
			parametros = $('institucionalForm').serialize();
			parametros = parametros.replace("method=save&","");
			parametros = parametros.replace("&save=Salvar","");
			parametros = parametros.replace("&institucional.texto=","&institucional.texto="+ed);
			url = "index.html?method=mostrarInstitucional&preview=1&"+parametros;
		}
	}
	*/
	window.open("index.html?method=preview&tipo="+tipoConteudo, "_blank", 'toolbar=no,scrollbars=yes');
	return false;
}

function showThrobber(){
	document.getElementById('throbber').style.display = '';
	document.getElementById('fundo').style.display = '';
	document.getElementById('fundo').style.position = "fixed";
	document.getElementById('fundo').style.opacity= 0.55;
	// document.getElementById('body').filters.alpha.opacity=55;
}

function hideThrobber(){
	document.getElementById('throbber').style.display = 'none';
	document.getElementById('throbber').style.display = 'none';
	document.getElementById('fundo').style.position = "relative";
	document.getElementById('fundo').style.opacity= 0;
	//document.getElementById('body').filters.alpha.opacity=100;
}

function highlightTableRows(tableId) {
    var previousClass = null;
    var table = document.getElementById(tableId); 
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=0; i < rows.length; i++) {
        rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
        rows[i].onmouseout = function() { this.className=previousClass };
        rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[0];
            if (cell.getElementsByTagName("a").length > 0) {
                var link = cell.getElementsByTagName("a")[0];
                if (link.onclick) {
                    call = link.getAttributeValue("onclick");
                    // this will not work for links with onclick handlers that return false
                    eval(call);
                } else {
                  location.href = link.getAttribute("href");
                }
                this.style.cursor="wait";
            }
        }
    }
}

function highlightTableRowsCol(tableId) {
	var previousClass = null;
    var table = document.getElementById(tableId); 
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=0; i < rows.length; i++) {
        rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
        rows[i].onmouseout = function() { this.className=previousClass };
        rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[0];
            if (cell.getElementsByTagName("a").length > 0) {
                var link = cell.getElementsByTagName("a")[0];
                if (link.onclick) {
                    call = link.getAttributeValue("onclick");
                    // this will not work for links with onclick handlers that return false
                    eval(call);
                } else {
                  location.href = link.getAttribute("href")+'&nomeTabelaQuest='+document.getElementById('tabela').value;
                }
                this.style.cursor="wait";
            }
        }
    }
}

function highlightTableRowsSet(tableId,colunaLink,colInicial,colFinal) {
    var previousClass = null;
    var table = document.getElementById(tableId); 
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=0; i < rows.length; i++) {
		
		var corFundo;
		
        rows[i].onmouseover = function() {
			
			corFundo = this.style.backgroundColor;
			
			this.style.cursor = "pointer";
				
				for(j=colInicial; j <= colFinal; j++){
					cells = this.getElementsByTagName("td");
					if(!cells || cells.length==0)return;
					celLink = cells[colunaLink];
					alink = celLink.getElementsByTagName("a")[0];
						
					cells[j].onclick = function(){
						//var cell = celLink;
						if (celLink.getElementsByTagName("a").length > 0) {
							
							if (alink.onclick) {
								call = alink.getAttributeValue("onclick");
								// this will not work for links with onclick handlers that return false
								eval(call);
							} else {
							  location.href = alink.getAttribute("href");
							}
							this.style.cursor="wait";
						}
					}
				}
			};

		rows[i].onmouseout = function() { this.style.backgroundColor = corFundo; };
        /*
		rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[colunaLink];
            if (cell.getElementsByTagName("a").length > 0) {
                var link = cell.getElementsByTagName("a")[0];
                if (link.onclick) {
                    call = link.getAttributeValue("onclick");
                    // this will not work for links with onclick handlers that return false
                    eval(call);
                } else {
                  location.href = link.getAttribute("href");
                }
                this.style.cursor="wait";
            }
        }
		*/
    }
}

// Show the document's title on the status bar
window.defaultStatus=document.title;