function flash(file, width, height){
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + width + "' height='" + height + "'> \n");
    document.write("<param name='movie' value='" + file + "'>\n");
    document.write("<param name='quality' value='high'> \n");
    document.write("<param name='wmode' value='transparent'> \n");
    document.write("<embed src='" + file + "' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'></embed> ");
    document.write("</object>");
}

function abre_admin()
{
   b = document.body.scrollHeight;
   document.getElementById("fundo").style.height = b;
   document.getElementById("fundo").style.backgroundColor="#628f5c";
   ajax('admin/janela_admin.php', '', 'janela');
}

function fecha_admin()
{
   document.getElementById("fundo").style.height = 1;
   document.getElementById("fundo").style.backgroundColor="";
   document.getElementById("janela").innerHTML = "";
}

function login_admin() {
	var usuario = document.getElementById("usuario").value;
	var senha = document.getElementById("senha").value;
	
	if (usuario == '' || senha == '') {
		alert('Dados em branco, porfavor preencha com seu usuário e senha !');
	}
	else {
		var poststr = "usuario=" + encodeURI(usuario) + "&senha=" + encodeURI(senha);
   		ajax('admin/valida_admin.php', poststr, 'janela');
	}
}
function volta_login() {
	ajax('admin/janela_admin.php', '', 'janela');		
}

function abre_noticias(codigo)
{
   b = document.body.scrollHeight;
   document.getElementById("fundo").style.height = b;
   document.getElementById("fundo").style.backgroundColor="#000000";
   var poststr = "codigo=" + encodeURI(codigo);
   ajax('admin/janela_noticias.php', poststr, 'janela');
}

function fecha_janela()
{
   document.getElementById("fundo").style.height = 1;
   document.getElementById("fundo").style.backgroundColor="";
   document.getElementById("janela").innerHTML = "";
}

function abre_evento(codigo)
{
   var poststr = "codigo=" + encodeURI(codigo);
   b = document.body.scrollHeight;
   document.getElementById("fundo").style.height = b;
   document.getElementById("fundo").style.backgroundColor="#628f5c";
   ajax('admin/janela_evento.php', poststr, 'janela');
}

function abre_recado(codigo)
{
   b = document.body.scrollHeight;
   document.getElementById("fundo2").style.height = b;
   document.getElementById("fundo2").style.backgroundColor="#628f5c";
   var poststr = "codigo=" + encodeURI(codigo);
   ajax('admin/ver_recado.php', poststr, 'janela2');
}
function abre_foto(codigo)
{
   b = document.body.scrollHeight;
   document.getElementById("fundo2").style.height = b;
   document.getElementById("fundo2").style.backgroundColor="#628f5c";
   var poststr = "codigo=" + encodeURI(codigo);
   ajax('admin/ver_foto.php', poststr, 'janela2');
}
function fecha_admin2()
{
   document.getElementById("fundo2").style.height = 1;
   document.getElementById("fundo2").style.backgroundColor="";
   document.getElementById("janela2").innerHTML = "";
}
function abre_balanco()
{
	window.open('http://200.99.40.25/portal/balanco/alunos.html','Administração','width=630,height=700,toolbar=no,menubar=no,location=no,status=no,fullscreen=no,directories=no,dependent=yes,left=0,top=0,scrollbars=yes');	
}

function data_vazia(campo , opcao)
{
	switch(opcao)
	{
		case '1':
		{
			if(campo.value=="      /       /    ")
			{
				campo.value="";
				return false;
			}
		}break;
		case '2':
		{
			if(campo.value=="")
			{
				var str="      /       /    ";
				campo.maxLength=str.length;
				campo.value = "      /       /    ";
				return false;
			}
		}break;
		default:
		{
			return true;
		}
	}
}

function envia_dados()
{
	var caminho			="./cadastraUsuario.php";
	var campoObrigatorio	="";
	var confirmacaoSenha	="";
	
	if(document.getElementById("senha_ok").value == "false")
	{
		confirmacaoSenha += "- Senha incompativel (padronizar esta mensagem)";
	}
	
	var nome			=document.getElementById("nome").value;			if(nome==""){campoObrigatorio += "- Nome <br>";}	
	var login			=document.getElementById("login").value;		if(login==""){campoObrigatorio += "- Login <br>";}	
	var senha			=document.getElementById("senha").value;		if(senha==""){campoObrigatorio += "- Senha <br>";}
	var email			=document.getElementById("email").value;		if(email==""){campoObrigatorio += "- E-mail <br>";}
	var logadouro		=document.getElementById("logadouro").value;
	var numero			=document.getElementById("numero").value;
	var complemento		=document.getElementById("complemento").value;
	var bairro			=document.getElementById("bairro").value;
	var estado			=document.getElementById("estado").value;		if(estado=="-"){campoObrigatorio += "- Estado <br>";}
	var cidade			=document.getElementById("cidade").value;		if(cidade=="-"){campoObrigatorio += "- Cidade <br>";}
	var datanasc		=document.getElementById("datanasc").value;		if(datanasc=="      /       /    "){campoObrigatorio += "- Data de Nascimento <br>";}
	var escolaridade	=document.getElementById("escolaridade").value;	if(escolaridade=="-"){campoObrigatorio += "- Cidade <br>";}
	var codcartao		=document.getElementById("codcartao").value;	if(cidade=="-"){campoObrigatorio += "- Cidade <br>";}
	
	if((campoObrigatorio=="")&&(confirmacaoSenha==""))
	{
		var param = 'nome='+nome+'&login='+login+'&senha='+senha+'&email='+email+'&logadouro='+logadouro+'&numero='+numero;
		param+='&complemento='+complemento+'&bairro='+bairro+'&estado='+estado+'&cidade='+cidade+'&datanasc='+datanasc;
		param+='&escolaridade='+escolaridade+'&codcartao='+codcartao.toUpperCase()+'&tipo=cadastrar';
		
		ajax_post(caminho,param,'dados_cadastro','dados_cadastro');
	}
	else
	{
		var html = "";
		
		if(campoObrigatorio!="")
		{
			html+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='320' height='50'>";
			html+= "<param name='wmode' value='Transparent'>";
			html+= "<param name='movie' value='images/preencher_campos.swf'>";
			html+= "<param name='quality' value='high'><embed src='images/preencher_campos.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='320' vspace='10' wmode='Transparent' height='50'></embed>";
			html+= "</object></center>";
		}
		
		if(confirmacaoSenha!="")
		{
			html+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='320' height='50'>";
			html+= "<param name='wmode' value='Transparent'>";
			html+= "<param name='movie' value='images/confirmacao_senha_invalida.swf'>";
			html+= "<param name='quality' value='high'><embed src='images/confirmacao_senha_invalida.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='320' vspace='10' wmode='Transparent' height='50'></embed>";
			html+= "</object></center>";
			html+= confirmacaoSenha;
		}
		document.getElementById("respostaCadastro").innerHTML = html;
	}
}
function atualiza_dados()
{
	var caminho			="./atualizaUsuario.php";
	var campoObrigatorio	="";
	var confirmacaoSenha	="";
	
	if(document.getElementById("senha_ok").value == "false")
	{
		confirmacaoSenha += "- Senha incompativel (padronizar esta mensagem)";
	}
	
	var cd_usuario		=document.getElementById("cd_usuario").value;
	var nome			=document.getElementById("nome").value;			if(nome==""){campoObrigatorio += "- Nome <br>";}	
	var login			=document.getElementById("login").value;		if(login==""){campoObrigatorio += "- Login <br>";}	
	var senha			=document.getElementById("senha").value;		if(senha==""){campoObrigatorio += "- Senha <br>";}
	var email			=document.getElementById("email").value;		if(email==""){campoObrigatorio += "- E-mail <br>";}
	var logadouro		=document.getElementById("logadouro").value;
	var numero			=document.getElementById("numero").value;
	var complemento		=document.getElementById("complemento").value;
	var bairro			=document.getElementById("bairro").value;
	var estado			=document.getElementById("estado").value;		if(estado=="-"){campoObrigatorio += "- Estado <br>";}
	var cidade			=document.getElementById("cidade").value;		if(cidade=="-"){campoObrigatorio += "- Cidade <br>";}
	var datanasc		=document.getElementById("datanasc").value;		if(datanasc=="      /       /    "){campoObrigatorio += "- Data de Nascimento <br>";}
	var escolaridade	=document.getElementById("escolaridade").value;	if(escolaridade=="-"){campoObrigatorio += "- Cidade <br>";}
	
	if((campoObrigatorio=="")&&(confirmacaoSenha==""))
	{
		var param = 'cd_usuario='+cd_usuario+'&nome='+nome+'&login='+login+'&senha='+senha+'&email='+email+'&logadouro='+logadouro+'&numero='+numero;
		param+='&complemento='+complemento+'&bairro='+bairro+'&estado='+estado+'&cidade='+cidade+'&datanasc='+datanasc;
		param+='&escolaridade='+escolaridade+'&tipo=atualizar';
		
		ajax_post(caminho,param,'dados_cadastro','dados_cadastro');
	}
	else
	{
		var html = "";
		
		if(campoObrigatorio!="")
		{
			html+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='280' height='50'>";
			html+= "<param name='wmode' value='Transparent'>";
			html+= "<param name='movie' value='images/preencher_campos.swf'>";
			html+= "<param name='quality' value='high'><embed src='images/preencher_campos.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='280' vspace='10' wmode='Transparent' height='50'></embed>";
			html+= "</object></center>";
		}
		
		if(confirmacaoSenha!="")
		{
			html+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='320' height='50'>";
			html+= "<param name='wmode' value='Transparent'>";
			html+= "<param name='movie' value='images/confirmacao_senha_invalida.swf'>";
			html+= "<param name='quality' value='high'><embed src='images/confirmacao_senha_invalida.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='320' vspace='10' wmode='Transparent' height='50'></embed>";
			html+= "</object></center>";
			html+= confirmacaoSenha;
		}
		document.getElementById("respostaCadastro").innerHTML = html;
	}
}
function limpa_dados()
{
	document.getElementById("nome").value = '';
	document.getElementById("login").value = '';
	document.getElementById("senha").value = '';
	document.getElementById("confirma_senha").value = '';	
	document.getElementById("email").value = '';
	document.getElementById("logadouro").value='';
	document.getElementById("numero").value='';
	document.getElementById("complemento").value='';
	document.getElementById("bairro").value='';
	document.getElementById("estado").selectedIndex=0;
	document.getElementById("cidade").selectedIndex=0;
	document.getElementById("datanasc").value = '';
	document.getElementById("escolaridade").selectedIndex=0;
	document.getElementById("codcartao").value = '';
	
	var nomes = Array("nome", "login", "senha", "confirma_senha", "email", "logadouro",
					  "numero", "complemento", "bairro", "estado", "cidade", "datanasc",
					  "escolaridade", "codcartao");
	for (var i=0;i<nomes.length;i++)
	{ 
		document.getElementById(nomes[i]).style.borderColor = "#FFFFFF";
		document.getElementById(nomes[i]).style.borderStyle = "solid";
		document.getElementById(nomes[i]).style.borderWidth = "0px";
		document.getElementById(nomes[i]).style.backgroundColor = "#FFFFFF";
	}
}
function atualiza_limpa_dados()
{
	document.getElementById("nome").value = '';
	document.getElementById("login").value = '';
	document.getElementById("senha").value = '';
	document.getElementById("confirma_senha").value = '';	
	document.getElementById("email").value = '';
	document.getElementById("logadouro").value='';
	                    document.getElementById("numero").value='';                                                                                             
	document.getElementById("complemento").value='';
	document.getElementById("bairro").value='';
	document.getElementById("estado").selectedIndex=0;
	document.getElementById("cidade").selectedIndex=0;
	document.getElementById("datanasc").value = '';
	document.getElementById("escolaridade").selectedIndex=0;
	document.getElementById("codcartao").value = '';
	
	var nomes = Array("nome", "login", "senha", "confirma_senha", "email", "logadouro",
					  "numero", "complemento", "bairro", "estado", "cidade", "datanasc",
					  "escolaridade", "codcartao");
	for (var i=0;i<nomes.length;i++)
	{ 
		document.getElementById(nomes[i]).style.borderColor = "#FFFFFF";
		document.getElementById(nomes[i]).style.borderStyle = "solid";
		document.getElementById(nomes[i]).style.borderWidth = "0px";
		document.getElementById(nomes[i]).style.backgroundColor = "#FFFFFF";
	}
}


function confirmaCampo(campo1,campo2,campoResposta)
{
	var campo1	=document.getElementById(campo1).value;
	var campo2	=document.getElementById(campo2).value;
	
	if((campo1 == campo2)&&(campo1.value != ""))
	{
		document.getElementById(campoResposta).value='true';
	}
	else
	{
		document.getElementById(campoResposta).value='false';
	}
}
function montaCidade(elementoEstado,divCidade)
{
	var caminho='./combos.php';
	var cd_estado=document.getElementById(elementoEstado).value;
	var nome='cidade';
	var onfocus='muda_borda(this.id);';
	var onchange='return false;';
	var onblur='muda_borda2(this.id);';
	var style='width: 300px; height: 20px;';
	var param='funcao=montaCidade&nome='+nome+'&id='+nome+'&onfocus='+onfocus+'&onchange='+onchange+'&onblur='+onblur+'&style='+style+'&cd_estado='+cd_estado+'&cd_cidade=';
	
	ajax_post(caminho,param,divCidade,divCidade);
}
function valida_login(evento)
{
	if(document.all)
	{ // Internet Explorer
		keyPress = evento.keyCode; 
	}
	else if(document.layers)
	{ // Nestcape
		keyPress = evento.which;
	}
	else
	{
		keyPress = evento.which;
		if(keyPress == 8)
		{
			return true;
		}
	}
	if (!((keyPress >= 48 && keyPress <= 57) || (keyPress >= 97 && keyPress <= 122) || (keyPress >= 65 && keyPress <= 90)||(keyPress == 95)||(keyPress == 0)))
	{
		return false;
	}
	return true;
}
function valida_acento(evento)
{
	if(document.all)
	{ // Internet Explorer
		keyPress = evento.keyCode;
	}
	else if(document.layers)
	{ // Nestcape
		keyPress = evento.which;
	}
	else
	{
		keyPress = evento.which;
		if(keyPress == 8)
		{
			return true;
		}
	}
	
	if ((keyPress == 0)||(keyPress == 32))
	{
		return true;
	}
	
	if(!((keyPress >= 48 && keyPress <= 57) || (keyPress >= 97 && keyPress <= 122) || (keyPress >= 65 && keyPress <= 90)||(keyPress == 95)))
	{
		return false;
	}
	return true;
}
function valida_cartao()
{
	var cartao=document.getElementById("codcartao");
	
	if(cartao.maxLength==cartao.value.length)
	{
		var caminho="./valida_cartao.php";
		var param="codcartao="+cartao.value.toUpperCase();
		var div='respostaCadastro';
		
		ajax_post(caminho,param,div,div);
	}
}

function data_vazia(campo , opcao)
{
	switch(opcao)
	{
		case '1':
		{
			if(campo.value=="      /       /    ")
			{
				campo.value="";
				return false;
			}
		}break;
		case '2':
		{
			if(campo.value=="")
			{
				var str="      /       /    ";
				campo.maxLength=str.length;
				campo.value = "      /       /    ";
				return false;
			}
		}break;
		default:
		{
			return true;
		}
	}
}

function enviaDadosEsqueceuSenha()
{
	var caminho = "./enviar_senha.php";
	var tipos = document.getElementsByName("tipo");
	var div="resposta";
	var funcao="";
    var login="";
	var param="";
	var erro="";
	var html="";
	
    for(var i=0; i<tipos.length; i++)
	{
        if(tipos[i].checked)
		{
            funcao=tipos[i].value;
        }
    }
    
    if(funcao=="email")
	{
		login=document.getElementById("login_email");
		
		if((login.value=="")||(login.disabled==true))
		{
			erro+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='320' height='50'>";
			erro+= "<param name='wmode' value='Transparent'>";
			erro+= "<param name='movie' value='images/preencher_campos.swf'>";
			erro+= "<param name='quality' value='high'><embed src='images/preencher_campos.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='320' vspace='10' wmode='Transparent' height='50'></embed>";
			erro+= "</object></center>";
		}
		if(erro=="")
		{
			param="funcao="+funcao+"&login="+login.value;
			ajax_post(caminho, param, div, div);
		}
		else
		{
			document.getElementById(div).innerHTML=erro;
		}
	}
	else if(funcao=="nova_senha")
	{
		login=document.getElementById("login_nova_senha").value;
		var cod_cartao=document.getElementById("cod_cartao_nova_senha").value;
		var nova_senha=document.getElementById("nova_senha").value;
		
		if(login==""&&cod_cartao==""&&nova_senha=="")
		{
			erro+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='320' height='50'>";
			erro+= "<param name='wmode' value='Transparent'>";
			erro+= "<param name='movie' value='images/preencher_campos.swf'>";
			erro+= "<param name='quality' value='high'><embed src='images/preencher_campos.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='320' vspace='10' wmode='Transparent' height='50'></embed>";
			erro+= "</object></center>";
		}
		else if(document.getElementById("valida_nova_senha").value!='true')
		{
			erro+= "<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='320' height='50'>";
			erro+= "<param name='wmode' value='Transparent'>";
			erro+= "<param name='movie' value='images/confirmacao_senha_invalida.swf'>";
			erro+= "<param name='quality' value='high'><embed src='images/confirmacao_senha_invalida.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='320' vspace='10' wmode='Transparent' height='50'></embed>";
			erro+= "</object></center>";
		}
		
		if(erro=="")
		{
			param="funcao="+funcao+"&login="+login+"&cod_cartao="+cod_cartao+"&nova_senha="+nova_senha;
			ajax_post(caminho, param, div, div);
		}
		else
		{
			document.getElementById(div).innerHTML=erro;
		}
	}
}

function limparCamposEsqueceuSenha()
{
	var tipo=document.getElementsByName("tipo");
	for(var i=0; i<tipo.length; i++)
	{
		tipo[i].checked=false;
	}
    document.getElementById("loginEmail").value = "";
    document.getElementById("loginNovaSenha").value = "";
    document.getElementById("codCartao").value = "";
    document.getElementById("novaSenha").value = "";
    document.getElementById("confSenha").value = "";
	
	desabilitar("");
}

function desabilitar(tipo)
{
	var email=true;
	var nova_senha=true;
	var class_email=Array("#CCCCCC","#666666");
	var class_nova_senha=Array("#CCCCCC","#666666");
	
    if(tipo=="email")
	{
		email=false;
		nova_senha=true;
		class_email=Array("#FFFFFF","#000000");
		class_nova_senha=Array("#CCCCCC","#666666");
	}
	else if(tipo=="nova_senha")
	{
		email=true;
		nova_senha=false;
		class_email=Array("#CCCCCC","#666666");
		class_nova_senha=Array("#FFFFFF","#000000");
	}
	
	document.getElementById("login_email").readOnly=email;
	document.getElementById("login_email").disabled=email;
	document.getElementById("login_email").style.backgroundColor=class_email[0];
	document.getElementById("login_email").style.color=class_email[1];
	
	document.getElementById("login_nova_senha").readOnly=nova_senha;
	document.getElementById("login_nova_senha").disabled=nova_senha;
	document.getElementById("login_nova_senha").style.backgroundColor=class_nova_senha[0];
	document.getElementById("login_nova_senha").style.color=class_nova_senha[1];
	
	document.getElementById("cod_cartao_nova_senha").readOnly=nova_senha;
	document.getElementById("cod_cartao_nova_senha").disabled=nova_senha;
	document.getElementById("cod_cartao_nova_senha").style.backgroundColor=class_nova_senha[0];
	document.getElementById("cod_cartao_nova_senha").style.color=class_nova_senha[1];
	
	document.getElementById("nova_senha").readOnly=nova_senha;
	document.getElementById("nova_senha").disabled=nova_senha;
	document.getElementById("nova_senha").style.backgroundColor=class_nova_senha[0];
	document.getElementById("nova_senha").style.color=class_nova_senha[1];
	
	document.getElementById("confirma_nova_senha").readOnly=nova_senha;
	document.getElementById("confirma_nova_senha").disabled=nova_senha;
	document.getElementById("confirma_nova_senha").style.backgroundColor=class_nova_senha[0];
	document.getElementById("confirma_nova_senha").style.color=class_nova_senha[1];
}


