estados = new Array();

estados['ac']='Acre';
estados['al']='Alagoas';
estados['am']='Amazonas';
estados['ap']='Amapá';
estados['ba']='Bahia';
estados['ce']='Ceará';
estados['df']='Distrito Federal';
estados['es']='Espírito Santo';
estados['go']='Goiás';
estados['ma']='Maranhão';
estados['mg']='Minas Gerais';
estados['ms']='Mato Grosso do Sul';
estados['mt']='Mato Grosso';
estados['pa']='Pará';
estados['pb']='Paraíba';
estados['pe']='Pernambuco';
estados['pi']='Piauí';
estados['pr']='Paraná';
estados['rj']='Rio de Janeiro';
estados['rn']='Rio Grande do Norte';
estados['ro']='Rondônia';
estados['rr']='Roraima';
estados['rs']='Rio Grande do Sul';
estados['sc']='Santa Catarina';
estados['se']='Sergipe';
estados['sp']='São Paulo';
estados['to']='Tocantins';

function o(id)
{
	return document.getElementById(id);
}
function endereco(qual){
	var qual;
	location.href=qual;
}
function estado(uf){
	
	document.getElementById('subtitulo').innerHTML = estados[uf];
	getAjax('ajax/unidades.php?uf='+uf,'mostraUnidades','');
	
}
function mostraUnidades(dados)
{
	document.getElementById('listaU').innerHTML = unescape(dados);	
}
function pularcampo(wobj,alvo,maxleght){
 if (wobj.value.length==maxleght){
  alvo.focus();
 }
}
function cor(obj){
	obj.style.background="#f2f2f2";
	obj.style.cursor="pointer";
}
function sem_cor(obj){
	obj.style.background="#FFFFFF";
}

function abre(id) {

 var obj = document.getElementById(id);
 var conteudo = document.getElementById("div_conteudo");

switch (id) {
	case "cursos":		
		var obj0 = document.getElementById('cursos');
		var obj1 = document.getElementById('aluno');
		
		if(obj0)obj0.style.display = "block";
		if(obj1)obj1.style.display = "none";
	
		break
/*	case "aluno":		
		var obj0 = document.getElementById('aluno');
		var obj1 = document.getElementById('cursos');
		
		obj0.style.display = "block";
		obj1.style.display = "none";
	
		break */
	case "sem":		
		var obj0 = document.getElementById('cursos');
/*		var obj1 = document.getElementById('cursos'); */
		
		obj0.style.display = "none";
/*		obj1.style.display = "none"; */
	
		break
	default:
  conteudo.style.display="none";
  obj.style.display = "";
}
}

function box_cursos(id) {

		var obj0 = document.getElementById('tx_tec');
		var obj1 = document.getElementById('tx_qua');
		var obj2 = document.getElementById('tx_mer');

	switch (id) {
		case 1:		
			obj0.style.display = "block";		document.getElementById('tecnicos').className = "botoes_box_cursos box_cursos_marcado";
			obj1.style.display = "none"; 		document.getElementById('qualif').className = "botoes_box_cursos";
			obj2.style.display = "none";		document.getElementById('mercado').className = "botoes_box_cursos";
		
			break
		case 2:		
			obj0.style.display = "none"; 		document.getElementById('tecnicos').className = "botoes_box_cursos";
			obj1.style.display = "block";		document.getElementById('qualif').className = "botoes_box_cursos box_cursos_marcado";
			obj2.style.display = "none";		document.getElementById('mercado').className = "botoes_box_cursos";
		
			break
		case 3:		
			obj0.style.display = "none";		document.getElementById('tecnicos').className = "botoes_box_cursos";
			obj1.style.display = "none";		document.getElementById('qualif').className = "botoes_box_cursos";
			obj2.style.display = "block";		document.getElementById('mercado').className = "botoes_box_cursos box_cursos_marcado";
		
			break
		default:
	}

}


function ampliafoto_cor(obj){
	obj.style.background="#ccc";
	obj.style.cursor="pointer";
}
function ampliafoto_sem_cor(obj){
	obj.style.background="#e2e2e2";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//formulario padrao:::::::::::::::::::::::::::::
var campos = new Array();
var ultimofml = null;

function checaIndique(fml)
{
	campo='indique';
	var i = 0;
	var j = 'Campos obrigatórios não preenchidos:\n\n';
	
	if (fml[campo+'[de_nome]'].value.length == 0) {
		j += ++i + ') Nome\n';
	}
	if (fml[campo+'[de_email]'].value.length == 0) {
		j += ++i + ') Email\n';
	}
	
	if (fml[campo+'[para_nome]'].value.length == 0) {
		j += ++i + ') Nome do amigo(a)\n';
	}
	if (fml[campo+'[para_email]'].value.length == 0) {
		j += ++i + ') Email do amigo(a)\n';
	}
	if (i > 0) {
		alert(j);
		return false;
	} else {
		enviaFormPadrao(fml,campo);
		return false;
	}
}
function checaFormPadrao(fml,campo)
{
	var i = 0;
	var j = 'Campos obrigatórios não preenchidos:\n\n';
	
	
	if(campo=='parceiros')
	{
		if (fml[campo+'[empresa]'].value.length == 0) {
			j += ++i + ') Empresa\n';
		}	
		
		if (fml[campo+'[responsavel]'].value.length == 0) {
			j += ++i + ') Responsável\n';
		}	
	}
	
	
	if(campo!='parceiros')
	{
		if (fml[campo+'[nome]'].value.length == 0) {
			j += ++i + ') Nome\n';
		}
	}
	if (fml[campo+'[email]'].value.length == 0) {
		j += ++i + ') Email\n';
	}
	if (fml[campo+'[ddd]'].value.length == 0 || fml[campo+'[tel]'].value.length == 0) {
		j += ++i + ') Telefone\n';
	}
	
	if(campo=="cadastro")
	{
		if (fml[campo+'[uf]'].value.length == 0) {
		j += ++i + ') Estado\n';
		}	
		if (fml[campo+'[cidade]'].value.length == 0) {
		j += ++i + ') Cidade\n';
		}
		if (fml[campo+'[bairro]'].value.length == 0) {
		j += ++i + ') Bairro\n';
		}
		if(!fml[campo+'[curso_id]'].value>0)
		{
			if (fml[campo+'[area_id]'].value.length == 0) {
				j += ++i + ') Área de Interesse\n';
			}
		}
	}
	if(campo=="parceiros"){
		if (fml[campo+'[comentario]'].value.length == 0) {
		j += ++i + ') Mensagem\n';
		}
	}
	
	if(campo=="contato"){
		
		if (fml[campo+'[setor_id]'].value.length == 0) {
		j += ++i + ') Setor\n';
		}
		if (fml[campo+'[comentario]'].value.length == 0) {
		j += ++i + ') Mensagem\n';
		}
	}
	
	if (i > 0) {
		alert(j);
		return false;
	} else {
		enviaFormPadrao(fml,campo);
		return false;
	}
}
function enviaFormPadrao(fml,campo)
{
	//PEGO TODOS OS CAMPOS E ENVIO
	
	campos = new Array();
	ultimofml = fml;
	
	if(fml[campo+'[empresa]'])
	campos[campos.length]  = 'empresa='+fml[campo+'[empresa]'].value;
	
	if(fml[campo+'[responsavel]'])
	campos[campos.length]  = 'responsavel='+fml[campo+'[responsavel]'].value;
	
	if(fml[campo+'[curso_id]'])
	campos[campos.length]  = 'curso_id='+fml[campo+'[curso_id]'].value;
	
	if(fml[campo+'[setor_id]'])
	campos[campos.length]  = 'setor_id='+fml[campo+'[setor_id]'].value;
	
	if(fml[campo+'[area_id]'])
	campos[campos.length]  = 'area_id='+fml[campo+'[area_id]'].value;
	
	if(fml[campo+'[nome]'])
	campos[campos.length]  = 'nome='+fml[campo+'[nome]'].value;
	
	if(fml[campo+'[email]'])
	campos[campos.length]  = 'email='+fml[campo+'[email]'].value;
	
	if(fml[campo+'[ddd]'])
	campos[campos.length]  = 'ddd='+fml[campo+'[ddd]'].value
	
	if(fml[campo+'[tel]'])
	campos[campos.length]  = 'tel='+fml[campo+'[tel]'].value
	
	if(fml[campo+'[cidade]'])
	campos[campos.length]  = 'cidade='+fml[campo+'[cidade]'].value

	if(fml[campo+'[comentario]'])
	campos[campos.length]  = 'comentario='+fml[campo+'[comentario]'].value;
	
	if(fml[campo+'[mensagem]'])
	campos[campos.length]  = 'mensagem='+fml[campo+'[mensagem]'].value;
	
	if(fml[campo+'[receber_informacoes]'])
	{
			if(fml[campo+'[receber_informacoes]'].checked)
			campos[campos.length]  = "receber_informacoes=s";
	}
	
	//CAMPOS DO INDIQUE;;;;;;;;;;;;;;;;;;;;;
	if(fml[campo+'[de_nome]'])
	campos[campos.length]  = 'de_nome='+fml[campo+'[de_nome]'].value;
	if(fml[campo+'[de_email]'])
	campos[campos.length]  = 'de_email='+fml[campo+'[de_email]'].value;
	if(fml[campo+'[para_nome]'])
	campos[campos.length]  = 'para_nome='+fml[campo+'[para_nome]'].value;
	if(fml[campo+'[para_email]'])
	campos[campos.length]  = 'para_email='+fml[campo+'[para_email]'].value;
	
	campos[campos.length] = 'formulario='+campo;
	
	queryString = "?"+campos.join('&');
	getAjax('ajax/enviaFormPadrao.php'+queryString,'respostaFormPadrao','');

}
function respostaFormPadrao(dados,campo)
{
	dados = unescape(dados);
	dados = dados.split('|');
	
	alert(dados[1]);
	
	if(dados[0]=='ok')
	limpaFormPadrao();
}
function limpaFormPadrao()
{
		if(ultimofml)ultimofml.reset();
}

