/*Carrega as cidades por estados no topo da pagina*/
function carregaCidadesPorEstado(){
	clearIt(document.getElementById("cidades"));
	makeRequest(document.getElementById("estado").value, "listaCidadesSql", exibeCidadesPorEstado, carregando("cidades"), concluido("cidades"), "text");
}

function exibeCidadesPorEstado(txt){
	clearIt(document.getElementById("cidades"));
	document.getElementById("cidades").innerHTML = txt;
}
/*FIM*/

/*Carrega as cidades por estado no editar do perfil*/
function carregaCidadesPorEstadoPerfil(){
	clearIt(document.getElementById("cidadesPerfil"));
	makeRequest(document.getElementById("estadoPerfil").value, "listaCidadesSqlPerfil", exibeCidadesPorEstadoPerfil, carregando("cidadesPerfil"), concluido("cidadesPerfil"), "text");
}

function exibeCidadesPorEstadoPerfil(txt){
	clearIt(document.getElementById("cidadesPerfil"));
	document.getElementById("cidadesPerfil").innerHTML = txt;
}
/*FIM*/

/*Carrega Setor no topo da pagina*/
function carregaSubSetorPorSetor(){
	clearIt(document.getElementById("subSetores"));
	makeRequest(document.getElementById("setores").value, "listaSubSetoresSql", exibeSubSetorPorSetor, carregando("subSetores"), concluido("subSetores"), "text");
}

function exibeSubSetorPorSetor(txt){	
	clearIt(document.getElementById("subSetores"));
	document.getElementById("subSetores").innerHTML = txt;
}

function carregaSubSetorPorSetorBuscaAnuncio(){
	clearIt(document.getElementById("sub_categoria_anuncio_busca"));
	makeRequest(document.getElementById("categoria_anuncio_busca").value, "listaSubSetorPorSetorBuscaAnuncioSql", exibeSubSetorPorSetorBuscaAnuncio, carregando("sub_categoria_anuncio_busca"), concluido("sub_categoria_anuncio_busca"), "text");
}

function exibeSubSetorPorSetorBuscaAnuncio(txt){	
	clearIt(document.getElementById("sub_categoria_anuncio_busca"));
	document.getElementById("sub_categoria_anuncio_busca").innerHTML = txt;
}

function carregaSubSetorPorSetorEmpregoBusca(){
	clearIt(document.getElementById("sub_categoria_emprego_busca"));
	makeRequest(document.getElementById("categoriaEmpregoBusca").value, "listaSubSetorPorSetorBuscaEmpregoSql", exibeSubSetorPorSetorBuscaEmprego, carregando("sub_categoria_emprego_busca"), concluido("sub_categoria_emprego_busca"), "text");
}

function exibeSubSetorPorSetorBuscaEmprego(txt){	
	clearIt(document.getElementById("sub_categoria_emprego_busca"));
	document.getElementById("sub_categoria_emprego_busca").innerHTML = txt;
}

/* FIM */

/*Carrega subcategorias no editar do perfil*/
function carregaSubSetorPorSetorPerfil(){
	clearIt(document.getElementById("subCategoria"));
	makeRequest(document.getElementById("categoria").value, "listaSubSetoresSqlPerfil", exibeSubCategoriaPorCategoria, carregando("subCategoria"), concluido("subCategoria"), "text");
}

function exibeSubCategoriaPorCategoria(txt){
	clearIt(document.getElementById("subCategoria"));
	document.getElementById("subCategoria").innerHTML = txt;
}
/*FIM*/

/*Carrega subcategorias de empregos*/
function carregaSubSetorPorSetorEmprego(){
	clearIt(document.getElementById("sub_categoria_emprego"));
	makeRequest(document.getElementById("categoriaEmprego").value, "listaSubSetoresSqlEmprego", exibeSubSetorPorSetorEmprego, carregando("sub_categoria_emprego"), concluido("sub_categoria_emprego"), "text");
}

function exibeSubSetorPorSetorEmprego(txt){	
	clearIt(document.getElementById("sub_categoria_emprego"));
	document.getElementById("sub_categoria_emprego").innerHTML = txt;
}
/*FIM */

/*Carrega subcategorias de anuncios*/
function carregaSubSetorPorSetorAnuncio(){
	clearIt(document.getElementById("sub_categoria_anuncio"));
	makeRequest(document.getElementById("categoria_anuncio").value, "listaSubSetoresSqlAnuncio", exibeSubSetorPorSetorAnuncio, carregando("sub_categoria_anuncio"), concluido("sub_categoria_anuncio"), "text");
}

function exibeSubSetorPorSetorAnuncio(txt){	
	clearIt(document.getElementById("sub_categoria_anuncio"));
	document.getElementById("sub_categoria_anuncio").innerHTML = txt;
}
/*FIM */


function carregando(destino){
	destino = document.getElementById(destino);
	var divs = destino.getElementsByTagName("div");
	if(divs.length == 0){
		var div = document.createElement("div");
		div.className = "carregando";
		div.innerHTML = "Carregando...";
		destino.appendChild(div);
	}
}

function concluido(destino){
	destino = document.getElementById(destino);
	var div = destino.getElementsByTagName("div")[0];
	div.innerHTML = "Recebendo dados...";
}



/*CarregaAnuncios Pagina inicial*/
function pegaNumeroDaPaginaCapaAnuncio(){	

	var paginacaoCapa = document.getElementById('paginacaoCapa');
	
	var pegalinks =  document.getElementById('paginacaoCapa').getElementsByTagName('a');	
		
	//paginacaoCapa.style.background = 'red';		
  for(var i = 0; i < pegalinks.length; i++){
    pegalinks[i].onclick =  carregaDivAnuncioCapa;
  }

}

function carregaDivAnuncioCapa(){
	
	//var paginaTodosAnuncio = 'http://red/koneg/anuncios/';
	var paginaTodosAnuncio = 'http://www.koneg.com/anuncios/';
	
	if (this.href == paginaTodosAnuncio ){
		   return true;
	}else{	
		clearIt(document.getElementById("anuncios"));
		var pg = this.href.split("/");
		pg = pg[pg.length-1];
		makeRequest(pg, "listaPaginacaoAnuncio", exibePaginaAnuncio, carregando("anuncios"), concluido("anuncios"), "text");
	
		return false;
	}
}

function exibePaginaAnuncio(txt){	
	clearIt(document.getElementById("anuncios"));
	document.getElementById("anuncios").innerHTML = txt;
	pegaNumeroDaPaginaCapaAnuncio();
}



/*CarregaAnuncios Pagina inicial*/
function pegaNumeroDaPaginaEmpresa(){	

	var paginacaoCapa = document.getElementById('paginaEmpresa');
	
	var pegalinks =  document.getElementById('paginaEmpresa').getElementsByTagName('a');	
		
	//paginacaoCapa.style.background = 'red';		
	  for(var i = 0; i < pegalinks.length; i++){
		 pegalinks[i].onclick =  carregaDivEmpresa;
	  }

}

function carregaDivEmpresa(){

	//var paginaTodasEmpresa = 'http://red/koneg/empresas/'; 
	var paginaTodasEmpresa = 'http://www.koneg.com/empresas/'; 

	if (this.href == paginaTodasEmpresa ){
		   return true;
	}else{	
		clearIt(document.getElementById("patrocinadores"));
		var pg = this.href.split("/");
		pg = pg[pg.length-1];
		makeRequest(pg, "listaPaginacaoEmpresa", exibePaginaEmpresa, carregando("patrocinadores"), concluido("patrocinadores"), "text");	
		return false;
	}
}

function exibePaginaEmpresa(txt){	
	clearIt(document.getElementById("patrocinadores"));
	document.getElementById("patrocinadores").innerHTML = txt;
	pegaNumeroDaPaginaEmpresa();
}



function pegaNumeroDaPaginaEmprego(){	

	//var paginacaoEmprego = document.getElementById('paginacaoEmprego');
	
	var pegalinks =  document.getElementById('paginacaoEmprego').getElementsByTagName('a');	

	//paginacaoCapa.style.background = 'red';		
	  for(var i = 0; i < pegalinks.length; i++){
		 pegalinks[i].onclick =  carregaDivEmprego;
	  }

}

function carregaDivEmprego(){
	
	//var paginaTodasVagasEmpregos='http://red/koneg/vagas-de-emprego/';		
	var paginaTodasVagasEmpregos='http://www.koneg.com/vagas-de-emprego/';		

	if (this.href == paginaTodasVagasEmpregos){
		   return true;
	}else{	
		clearIt(document.getElementById("vagasEmprego"));
		var pg = this.href.split("/");
		pg = pg[pg.length-1];
		makeRequest(pg, "listaPaginacaoEmprego", exibePaginaEmprego, carregando("vagasEmprego"), concluido("vagasEmprego"), "text");	
		return false;
	}
}

function exibePaginaEmprego(txt){	
	clearIt(document.getElementById("vagasEmprego"));
	document.getElementById("vagasEmprego").innerHTML = txt;
	pegaNumeroDaPaginaEmprego();
}

function carregaImagem(imagem){
	
	imgG = document.getElementById("img1").src;
	
	imagemSel = imagem.src;	
	
	ImagemNormal = imagemSel.split("_");	
	document.getElementById("img1").src = ImagemNormal[0]+'_normal.jpg';
	
	ImagemMini = imgG.split("_");	
	imagem.src = ImagemMini[0]+'_mini.jpg';
	
}

function confirma(texto) {
var confirma = confirm(texto)
	if ( confirma ){
		return true
	} else {
		return false
	}
}

