var min_left = 235; 
var min_top = 15;
var banner_change = 1;
var animateOnePerTime = false;
var imagesup = new Array();


	function resizer(){
		$('#medias').hide();
		//se necessário
	}

	function pre_carrega_imagens(){
		for(var val_aux_img = 1; val_aux_img <= qtd_image; val_aux_img = val_aux_img+1){
			$("#banner"+val_aux_img).attr('src',banners[val_aux_img]);	
		}
		prepara_banner();
	}



	$(document).ready(function(){
		resizer();
		
		$('#formularioIncCv').submit(function() {
			var error = 'OK';
			var texto = $('#conteudo_curriculo').val();
			if($('#Nome_curriculo').val() == ''){
				alert('Preencha o Nome.');
				error = $('#Nome_curriculo');	
			}else if($('#mail_curriculo').val() == ''){
				alert('Preencha o E-mail.');
				error = $('#mail_curriculo');	
			}else if($('#datanascimento_curriculo').val() == ''){
				alert('Preencha a Data de Nascimento.');
				error = $('#datanascimento_curriculo');	
			}else if($('#sexo_curriculo option:selected').val() == '-1'){
				alert('Escolha seu Sexo.');
				error = $('#sexo_curriculo');	
			}else if($('#estado_civil_curriculo option:selected').val() == '-1'){
				alert('Escolha seu Estado Civil.');
				error = $('#estado_civil_curriculo');	
			}else if($('#estado_curriculo option:selected').val() == '-1'){
				alert('Escolha um Estado.');
				error = $('#estado_curriculo');
			}else if($('#cidade_curriculo').val() == ''){
				alert('Preencha a Cidade.');
				error = $('#cidade_curriculo');	
			}else if($('#bairro_curriculo').val() == ''){
				alert('Preencha o Bairro.');
				error = $('#bairro_curriculo');
			}else if($('#cep_curriculo').val() == ''){
				alert('Preencha o CEP.');
				error = $('#cep_curriculo');	
			}else if($('#endereco_curriculo').val() == ''){
				alert('Preencha o Endereço.');
				error = $('#endereco_curriculo');
			}else if($('#telefone_curriculo').val() == ''){
				alert('Preencha o Telefone.');
				error = $('#telefone_curriculo');
			}else if($('#cargo_curriculo').val() == ''){
				alert('Preencha o Cargo pretendido.');
				error = $('#cargo_curriculo');
			}else if($('#faixasal_curriculo option:selected').val() == '0'){
				alert('Escolha uma Faixa Salarial.');
				error = $('#faixasal_curriculo');
			}else if( texto < 30 ){
				alert('Preencha o Conteúdo de seu Currículo.');
				error = $('#conteudo_curriculo');
			}
			if(error == 'OK'){
				return true;	
			}else{
				error.focus();
				return false;
			}
			return false;
		});
		
		
		
		$('#busca_buttom_mvc').click(function (){
			var string = $('#busca_campo').val();
			var busca = '';
			string = string.toLowerCase();
			for(var x = 0;x<string.length;x++){
					string = string.replace(/[âáàãä]/,"a");
					string = string.replace(/[éèêë]/,"e");
					string = string.replace(/[íìîï]/,"i");
					string = string.replace(/[ôõóòö]/,"o");
					string = string.replace(/[úùûü]/,"u");
					string = string.replace("\"","\"");
					string = string.replace("ç","c");
					string = string.replace("ñ","n");
					string = string.replace("/","+");  
					string = string.replace("#","+");  
					string = string.replace("$","$");  
					string = string.replace("%","+"); 
					string = string.replace("&&","AND");  
					string = string.replace("&","%26");  
					string = string.replace("*","*");  
					string = string.replace("(","(");  
					string = string.replace(")",")");  
					string = string.replace("=","%3D");  
					string = string.replace("]","(");  
					string = string.replace("[",")");  
					string = string.replace("{","(");  
					string = string.replace("}",")");  
					string = string.replace("º","+");  
					string = string.replace("°","+");  
					string = string.replace("?","%3F");  
					string = string.replace("ª","+"); 
					string = string.replace("||","OR"); 
					string = string.replace("|","OR");  
					string = string.replace("@","%40");  
					string = string.replace("¨","+");  
					string = string.replace("\"","+");  
					string = string.replace("'","\"");  
					string = string.replace("^","+");  
					string = string.replace("~","+"); 
					string = string.replace("\\","+");  
					string = string.replace(".","+");  
					string = string.replace(",","+");  
					string = string.replace("<","<");  
					string = string.replace(">",">");  
					string = string.replace("§","+");  
					string = string.replace("!","+");  
					string = string.replace("¢","+");  
					//string = string.replace("¬","(NOT)");  
					string = string.replace("-","+");  
					string = string.replace("_","+");  
					string = string.replace("¹","1");  
					string = string.replace("²","2");  
					string = string.replace("³","3");  
					string = string.replace(":","+");  
					string = string.replace(";","+");  
					string = string.replace("´","+");  
					string = string.replace("`","+"); 
					//string = string.replace(" ","+");  
			}
			execute_busca(string,0,true);
		});
		
		function execute_busca(value, start, paginar){
			$.ajax({
			  type: "POST",
			  url: "lib/busca.php",
			  data: "dados="  	+ value 	+ "&" +
			  		"paginar="  + paginar 	+ "&" +
			  		"pagina=" 	+ start 	+ "&" 
			  ,
			  cache: true,
			  success: function(html){
				$("#conteudo").html(html);
			  }
			});
		};

		$("[id$=op]").mouseover( function() {
		  var id = $(this).attr("id");
		  $('#'+id+'c').fadeIn(300);
		});
				
		$("[id$=op]").mouseover( function() {
		  var id = $(this).attr("id");
		  $(this).parent().find('div').fadeIn(300);
		});				
		
		$("[id^=menu_]").mouseleave( function() {
		  var id = $(this).attr("id");
		  $('#sub'+id).fadeOut(500);
		  $('#'+id+'_opc').fadeOut(1000);
		});

		$("[id$=mv]").mouseover( function() {
		  var id = $(this).attr("id");
		  $('#'+id+'c').fadeIn(500);
		});
		
		$("[id$=mv]").mouseleave( function() {
		  var id = $(this).attr("id");
		  $('#'+id+'c').fadeOut(1000);
		});


		$("#busca_campo").focus(function () {
			if($("#busca_campo").val() == 'Busca')
				$("#busca_campo").val('');
		});
		
		$("#busca_campo").focusout(function () {
			if($("#busca_campo").val() == '')
				$("#busca_campo").val('Busca');
		});
		setTimeout(pre_carrega_imagens,1500);

	});
	
	$(window).load(function(){
		$('#pre_load').fadeOut(200);
	});
	
	$(window).bind('resize', function() {
		resizer();
	});
	
	function prepara_banner(){
		$("#banner1").show();
		for(var counter = 1; counter <= qtd_image;  counter = counter+1){
			$('#banner' + counter).hide();
		}
	}
	
	function fade_banner(){
		$("#banner1").hide();
		var prox = banner_change+1;
		if( banner_change == qtd_image )	
			prox = 1;		
		$('#banner'+banner_change).fadeOut(2000);	
		$('#banner'+prox).fadeIn(2000);	
		banner_change = prox;
	}	
	setInterval(function(){
		fade_banner();	
	},6000);
	
	
	function mediar(acao, video, prod ){
		if(video == '')
			video = 'F_qzfnidALo';
		if(acao == 'close'){
			$('#medias2').hide();
			$('#medias2').html(" ");
		}else if(acao == 'open'){
			$.ajax({
			  url: "lib/youtube.php?video="+video+'&produto='+prod,
			  cache: false,
			  success: function(html){
				$('#medias2').show();
				$('#medias2').html(html);
			  }
			});
			
		}
	}
	

