function mostra_alerta(texto){
document.getElementById('alertas').innerHTML = '<div align="center" id="alerta"><div id="alerta_caixa"><div id="alerta_caixa_c" align="left">Alerta!</div><div id="alerta_caixa_txt">'+texto+'<br></div><div id="alerta_caixa_btn" align="center"><a onClick="javascript: oculta_alerta();" style="cursor:pointer;">OK</a></div></div></div>';

document.getElementById('alertas').style.display = 'inline';
}

function oculta_alerta(){
document.getElementById('alertas').innerHTML = '';
document.getElementById('alertas').style.display = 'none';
}

function apps_inicia(intervalo) {
apps_uta();
apps_novre();
apps_novcert();
apps_onde_estarei();
/*apps_talk_chamadas();*/
setTimeout("apps_inicia('"+intervalo+"')", intervalo);
}

function apps_uta() {
if(document.getElementById) {
var ajax = openAjax();
ajax.open("GET", "http://www.swingcentral.com.br/sc/a/apps.uta.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
return true;
} else {
return false;
}
}
}
ajax.send(null);
}
}

function apps_novre() {
if(document.getElementById) {
var ajax = openAjax();
ajax.open("GET", "http://www.swingcentral.com.br/sc/a/apps.novre.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
var resultado = ajax.responseText;
resultado = resultado.replace(/\+/g," ");
resultado = unescape(resultado); 
if(resultado == "novre"){
var data = new Date();
var tempo = data.getTime();
document.getElementById('avisos').innerHTML = '<div id="recado_n_alerta" align="center"><b>AVISO:</b><br>Você recebeu novos recados.<br><a href="http://www.swingcentral.com.br/sc/meus_recados.php">Minha página de recados.</a><br><br><b style="cursor:pointer;" onClick="javascript: apps_nenre();">[fechar aviso]</b></div>';
document.getElementById('avisos').style.display = 'inline';
}else{
document.getElementById('avisos').innerHTML = '';
document.getElementById('avisos').style.display = 'none';
}
} else {
return false;
}
}
}
ajax.send(null);
}
}

function apps_nenre() {
if(document.getElementById) {
document.getElementById('avisos').innerHTML = '';
document.getElementById('avisos').style.display = 'none';
var ajax = openAjax();
ajax.open("GET", "http://www.swingcentral.com.br/sc/a/apps.nenre.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
return true;
} else {
return false;
}
}
}
ajax.send(null);
}
}

function apps_onde_estarei() {
if(document.getElementById) {
var ajax = openAjax();
ajax.open("GET", "http://www.swingcentral.com.br/sc/a/apps.onde.estarei.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
var resultado = ajax.responseText;
resultado = resultado.replace(/\+/g," ");
resultado = unescape(resultado); 
if(resultado == "mostrar"){
if(window.location == "http://www.swingcentral.com.br/sc/add_evento.php"){
document.getElementById('alertas').innerHTML = '';
document.getElementById('alertas').style.display = 'none';
}else if(window.location == "http://www.swingcentral.com.br/sc/onde_estarei.php"){
document.getElementById('alertas').innerHTML = '';
document.getElementById('alertas').style.display = 'none';
}else{
var data = new Date();
var tempo = data.getTime();
document.getElementById('alertas').innerHTML = '<div id="onde_estarei_alerta" align="center"><b>ATENÇÃO:</b><br>Avise seus amigos onde você estará no fim de semana<br><a href="http://www.swingcentral.com.br/sc/add_evento.php"><b>Clique aqui.</b></a><br><br><b style="cursor:pointer;" onClick="javascript: apps_onde_estarei_f();">[X]</b></div>';
document.getElementById('alertas').style.display = 'inline';
}
}else{
document.getElementById('alertas').innerHTML = '';
document.getElementById('alertas').style.display = 'none';
}
} else {
return false;
}
}
}
ajax.send(null);
}
}

function apps_onde_estarei_f() {
if(document.getElementById) {
document.getElementById('alertas').innerHTML = '';
document.getElementById('alertas').style.display = 'none';
var ajax = openAjax();
ajax.open("GET", "http://www.swingcentral.com.br/sc/a/apps.onde.estarei.f.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
return true;
} else {
return false;
}
}
}
ajax.send(null);
}
}

function apps_novcert() {
if(document.getElementById) {
var ajax = openAjax();
ajax.open("GET", "http://www.swingcentral.com.br/sc/a/apps.novcert.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
var resultado = ajax.responseText;
resultado = resultado.replace(/\+/g," ");
resultado = unescape(resultado); 
if(resultado == "novcert"){
if(window.location != "http://www.swingcentral.com.br/sc/certificacao.php"){
window.location.href = "http://www.swingcentral.com.br/sc/certificacao.php";
}
}else if(resultado == "novaviso"){
if(window.location != "http://www.swingcentral.com.br/sc/aviso.php"){
window.location.href = "http://www.swingcentral.com.br/sc/aviso.php";
}
}else{
return false;
}
} else {
return false;
}
}
}
ajax.send(null);
}
}


/*
function apps_talk_chamadas() {
if(document.getElementById) {
var ajax = openAjax();
ajax.open("GET", "/a/apps.talk.php", true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
var resultado = ajax.responseText;
resultado = resultado.replace(/\+/g," ");
resultado = unescape(resultado); 
if(resultado == "nada"){
document.getElementById('chamadas').innerHTML = '';
document.getElementById('chamadas').style.display = 'none';
}else if(resultado == "erro"){
window.location.reload();
}else{
document.getElementById('chamadas').innerHTML = resultado;
document.getElementById('chamadas').style.display = 'inline';
}
} else {
return false;
}
}
}
ajax.send(null);
}
}

function apps_talk_chamada(u, k, t) {
if(t == "aceitar"){
if(navigator.appName != "Microsoft Internet Explorer"){
window.open("http://talk.swingcentral.com.br/app_aceitar.php?uid="+u+"&key="+k, u, 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=460,height=375');
}else{
window.open("http://talk.swingcentral.com.br/app_aceitar.php?uid="+u+"&key="+k, u, 'toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=0,width=460,height=350');
}
document.getElementById('chamadas').innerHTML = '';
document.getElementById('chamadas').style.display = 'none';
}else{
if(document.getElementById) {
document.getElementById('chamadas').innerHTML = '';
document.getElementById('chamadas').style.display = 'none';
var ajax = openAjax();
ajax.open("GET", "/a/apps.talk.cancela.php?uid="+u+"&key="+k, true);
ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4) { 
if(ajax.status == 200) {
return true;
} else {
return false;
}
}
}
ajax.send(null);
}
}
}


function apps_talk_chamar(u) {
if(navigator.appName != "Microsoft Internet Explorer"){
window.open("http://talk.swingcentral.com.br/app_chamar.php?uid="+u, u, 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=460,height=375');
}else{
window.open("http://talk.swingcentral.com.br/app_chamar.php?uid="+u, u, 'toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=0,width=460,height=350');
}
}
*/