// JavaScript Document

String.prototype.trim = function() {
    return this.replace(/^\s+/, "").replace(/\s+$/, "");
}

function openChild(pagina, parente, largura, altura, scrollb) {
	//centralizo a página no centro do screen
	px = (screen.width/2)-(largura/2);
	py = (screen.height/2)-(altura/2);
	//mensagem que será exibida se a página não for aberta
	msg = 'A janela com a pagina "'+pagina+'" não pode ser aberta!\nTalvez isto esteja acontecendo devido um programa bloqueador de pop-up ter bloqueado esta janela!\nPor favor desabilite o seu programa de pop-up ou configure-o para permitir as janelas deste site.\n\nEm caso de dúvida contate o Administrador da Rede e/ou o nosso Suporte Técnico.';
	//tento abrir
	janela = window.open(pagina, parente,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars='+scrollb+',resizable=no,menubar=no,width='+largura+',height='+altura+',left='+px+',top='+py);
	//se não abrir exibo a mensagem
	if(janela == null) { alert(msg); return; }
}

function escreveDivStatusAjax() {
	var retorno = '';
	retorno += '<div id="status_ajax" style="background-color:Maroon; color:White; font-family:Verdana; position:absolute; width:120px; display: none;">';
	retorno += '	Carregando...';
	retorno += '</div>';

	retorno += '<script language="javascript">';
	retorno += '	if (document.getElementById(\'status_ajax\')) {';
	retorno += '		document.getElementById(\'status_ajax\').style.left = document.body.clientWidth - 150;';
	retorno += '	}';
	retorno += '</script>';
	return retorno;
}


function traduz_acentos(texto) {
	texto = texto.replace( "à", "&agrave;");
	texto = texto.replace( "á", "&aacute;");
	texto = texto.replace( "â", "&acirc;");
	texto = texto.replace( "ã", "&atilde;");
	texto = texto.replace( "ä", "&auml;");
	
	texto = texto.replace( "è", "&egrave;");
	texto = texto.replace( "é", "&eacute;");
	texto = texto.replace( "ê", "&ecirc;");
	texto = texto.replace( "ë", "&euml;");
	
	texto = texto.replace( "ì", "&igrave;");
	texto = texto.replace( "í", "&iacute;");
	texto = texto.replace( "î", "&icirc;");
	texto = texto.replace( "ï", "&iuml;");
	
	texto = texto.replace( "ò", "&ograve;");
	texto = texto.replace( "ó", "&oacute;");
	texto = texto.replace( "ô", "&ocirc");
	texto = texto.replace( "õ", "&otilde;");
	texto = texto.replace( "ö", "&ouml;");
	
	texto = texto.replace( "ù", "&ugrave;");
	texto = texto.replace( "ú", "&ugrave;");
	texto = texto.replace( "û", "&ucirc;");
	texto = texto.replace( "ü", "&uuml;");
	
	texto = texto.replace( "À", "&Agrave;");
	texto = texto.replace( "Á", "&Aacute;");
	texto = texto.replace( "Â", "&Acirc;");
	texto = texto.replace( "Ã", "&Atilde;");
	texto = texto.replace( "Ä", "&Auml;");
	
	texto = texto.replace( "È", "&Egrave;");
	texto = texto.replace( "É", "&Eacute;");
	texto = texto.replace( "Ê", "&Ecirc;");
	texto = texto.replace( "Ë", "&Euml;");
	
	texto = texto.replace( "Ì", "&Igrave;");
	texto = texto.replace( "Í", "&Iacute;");
	texto = texto.replace( "Î", "&Icirc;");
	texto = texto.replace( "Ï", "&Iuml;");
	
	texto = texto.replace( "Ò", "&Ograve;");
	texto = texto.replace( "Ó", "&Oacute;");
	texto = texto.replace( "Ô", "&Ocirc;");
	texto = texto.replace( "Õ", "&Otilde;");
	texto = texto.replace( "Ö", "&Ouml;");
	
	texto = texto.replace( "Ù", "&Ugrave;");
	texto = texto.replace( "Ú", "&Uacute;");
	texto = texto.replace( "Û", "&Ucirc;");
	texto = texto.replace( "Ü", "&Uuml;");
	
	texto = texto.replace( "ç", "&ccedil;");
	texto = texto.replace( "Ç", "&Ccedil;");
	
	texto = texto.replace( "ñ", "&ntilde;");
	texto = texto.replace( "Ñ", "&Ntilde;");
	
	texto = texto.replace( "´", "&acute;");
	//texto.replace( "`", "`");
	texto = texto.replace( "¨", "&uml;");
	texto = texto.replace( "^", "&circ;");
	texto = texto.replace( "~", "&tilde;");
	return texto;
}
