jQuery().ready(function(){

	$(".mesesFiltro li:first").attr("class", "bugAba");
	
	$('area').tooltip({
	    showURL: false
	});
	
	$('#btLimpar').attr('value', '');
	
	if($('#tabsCursosVisitas,#tabsResultadoBusca,#tabsIndiceAZ,#tabsAtualidadesEventos').html() != null) {
		$('#tabsCursosVisitas').tabs({ fxSlide: false, fxFade: false, fxSpeed: 'normal' });
		$('#tabsResultadoBusca').tabs({ containerClass:'tabs-container-conteudo', fxSlide: false, fxFade: false, fxSpeed: 'normal' });
		$('#tabsIndiceAZ').tabs({ containerClass:'tabs-container-conteudo', fxSlide: false, fxFade: false, fxSpeed: 'normal' });
		$('#tabsAtualidadesEventos').tabs({
			containerClass:'tabs-container-conteudo',
			fxSlide: false, 
			fxFade: false, 
			fxSpeed: 'normal',
			onShow: function() {
				actTab = $('#tabsAtualidadesEventos').activeTab();
				if (actTab == 1) {
					$('#nmTab').text("notícias");
				} else {
					$('#nmTab').text("eventos");
				}
			}
		});
	}
	
	
	
	
	
	$('#btVoce,#btVoceH').click(function() {
		$('#sessaoEmpresa').slideUp(500,function(){
			$('#sessaoTudoSenai').slideUp(500,function(){
				$('#sessaoVoce').slideDown(500)
			});
		});
	});
	
	$('#btSuaEmpresa,#btSuaEmpresaH').click(function() {
		$('#sessaoVoce').slideUp(500,function(){
			$('#sessaoTudoSenai').slideUp(500,function(){
				$('#sessaoEmpresa').slideDown(500);
			});
		});
	});
	
	$('#lkTudoSenai').click(function() {
		$('#sessaoVoce').slideUp(500,function(){
			$('#sessaoEmpresa').slideUp(500,function(){
				$('#sessaoTudoSenai').slideDown(500);
			});
		});
	});

	
	$('#btFecharTudoSenai').click(function() {
		$('#sessaoTudoSenai').slideUp();
	});
	
	$('#btFecharEmpresa').click(function() {
		$('#sessaoEmpresa').slideUp();
	});

	$('#btFecharVoce').click(function() {
		$('#sessaoVoce').slideUp();
	});
	
	$('#rbCursosAbertos,#rbCursosTodos').click(function() {
		if (this.value == "Abertos") {
			$("#lbModalidadePeriodo").slideDown();
		} else {
			$("#lbModalidadePeriodo").slideUp();
		}
	});
	
	$('#mapaSC').click(function(){
		alert('abrir mapa SC');
	});

	
//	$('.btLupaBuscar, .btBuscarPainelBusca').click(function(){
//		alert(this.id);
//	});
	
	
	
	if (jQuery.fn.tagCloud) {
		var tags = [
			{tag: "Educação", count: 18}, 
			{tag: "qualificação", count: 30}, 
			{tag: "Serviços", count: 18}, 
			{tag: "Alimentos", count: 12}, 
			{tag: "Biblioteca", count: 24}, 
			{tag: "Cursos Técnicos", count: 34}, 
			{tag: "Eventos", count: 24}, 
			{tag: "área", count: 36}, 
			{tag: "faixa etária", count: 14}, 
			{tag: "Formação Profissional", count: 34}, 
			{tag: "Notícias", count: 24}, 
			{tag: "Eletrometalmecânica", count: 14}, 
			{tag: "Fale Conosco", count: 30}, 
			{tag: "Serviço", count: 24}, 
			{tag: "Consultoria", count: 14}, 
			{tag: "Pós-Graduação", count: 30}, 
			{tag: "Bolsas e Financiamentos", count: 30}, 
			{tag: "Informática", count: 24}
		];
		// Default settings:
		var defaults = {
		  sort: "", //function (a, b) {return a.tag < b.tag ? -1 : (a.tag == b.tag ? 0 : 1)},
		  click: function(tag) {alert(tag);},
		  maxFontSizeEm: 2.3
		}
		$("#tagcloud").tagCloud(tags,defaults);
	}
	
	



	if($("#videoPlayerHome")) {
		
		$("#verGaleria").click(function(){
			alert(this.href);
		});
	
		$("#btFotos,#btVideos").click(function(){
			if(this.id == "btVideos") {
				$('#setaVideo').show();
				$('#btVideos').css('background','url(img/colunaDireita/btFotosVideos.gif) top right no-repeat');
				$('#btFotos').css('background','url(img/colunaDireita/btFotosVideos.gif) bottom left no-repeat');
				$("#nmFotoVideo").text("Nome do vídeo");
				$('#verGaleria').attr("href","#verGaleriaVideos");
				$('#btVideos').css('background','url(img/colunaDireita/btFotosVideos.gif) top right no-repeat');
				$('#bgFotoVideoPlayer').css("background","url(img/colunaDireita/fotoVideoPlayer2.jpg) top left no-repeat");
			} else {
				$('#setaVideo').hide();
				$('#btVideos').css('background','url(img/colunaDireita/btFotosVideos.gif) bottom right no-repeat');
				$('#btFotos').css('background','url(img/colunaDireita/btFotosVideos.gif) top left no-repeat');
				$("#nmFotoVideo").text("Nome da foto");
				$('#verGaleria').attr("href","#verGaleriaFotos");
				$('#bgFotoVideoPlayer').css("background","url(img/colunaDireita/fotoVideoPlayer1.jpg) top left no-repeat");
			}
		});
	
	
		$("#videoPlayerHome").mouseover(function() {
			$('#bgNomeFoto').show();
		}).mouseout(function(){
			$('#bgNomeFoto').hide();
		});
	}
	
	
	
	
	

			
	// Create pagination element
	if(jQuery.fn.pagination){
		function pageselectCallback(page_id, jq){
			alert(page_id+1);
		}
		
		$("#Pagination").pagination(300, {
			num_edge_entries: 1,
			items_per_page:20,
			num_display_entries: 5,
			link_to:'#',
			callback: pageselectCallback
		});
	}
	

	$("#boxUniCidades a").mousedown(function(){
		$('.nmUnidade').css('color','#F00');
	}).mouseup(function(){
		$('.nmUnidade').css('color','#000');	
	});
	

	/*
	$.getJSON("data/cidades.js", function(json) {
		$.each(json.cidades.items, function(i,item){
			alert(json.cidades.items[0].nm);
		});
	});
	*/


	 
	if($.googleMap) {
		$("#mapaPertoVoce").googleMap(null, null, 11, {
			controls: ["GSmallMapControl", "GMapTypeControl"],
			markers: $(".geo")
		});
		// Example to access the map object is below:
		// $.googleMap.maps["map1"].setMapType(G_SATELLITE_TYPE);
		$("div.gmnoprint").eq(1).css('display',"none");
	}
	
	
	
	

	

	
	
	$(".btEnviarPorEmail").click(function(){
		$("#frmEnviarGalVideo").slideToggle("slow");
	});		

	/* correção para o menu funcionar corretamente com Internet Explorer 6 */
	if(jQuery.browser.msie && jQuery.browser.version == 6){
		$("#nav li ul").parent().mouseout(function(){
			$(this).hide();
		}).mouseout(function(){
			$(this).show();
		});
	}
	
	
	$('.prox').mouseover(function(){
		$('.submenu').hide();
	});
	
		
	
});

function escondeMenu(id){
	var idObjeto = id.id;
	idObjeto = '#'+ idObjeto + ' ul';
	
	$(idObjeto).hide();
}

function topoMenu(id){
	var idObjeto = id.id;
	idObjeto = '#'+ idObjeto + ' ul';
	
	$(idObjeto).show();
}

$(document).ready(function() {
    $("#descricaoServico a").toggle(function() {
	    	$("#produtos"+$(this).attr('id')).show('fast');
	    	$(this).text('(-) Ver produtos');
        }, function() {
	        $("#produtos"+$(this).attr('id')).hide('fast');
	        $(this).text('(+) Ver produtos');
    });
});

$(document).ready(function() {
    $("#servicos h3").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
});

$(document).ready(function() {
	$('input#telComercial').mask('(99) 9999-9999');
	$('input#telResidencial').mask('(99) 9999-9999');
	$('input#telCelular').mask('(99) 9999-9999');
	$('input#dtNasc').mask('99/99/9999');
	$('input#cpf').mask('999.999.999-99');
	$('input#cpfLogin').mask('999.999.999-99');
	$('input#cep').mask('99.999-999');
	$('input#data_nascimento').mask('99/99/9999');
	
	var v = "0123456789";
    $("#modulo").keyup(function (event) {
        var t = $("input#modulo").val();
        var w = "";
        for (i=0; i < t.length; i++) {
        	x = t.charAt(i);
        	if (v.indexOf(x,0) != -1) w += x;
        }
        
        $("input#modulo").val(w);
   });
    $("#6").keyup(function (event) {
        var t = $("input#6").val();
        var w = "";
        for (i=0; i < t.length; i++) {
        	x = t.charAt(i);
        	if (v.indexOf(x,0) != -1) w += x;
        }
        
        $("input#6").val(w);
   });
    var v2 = "0123456789.";
    $("#9").keyup(function (event) {
        var t = $("input#9").val();
        var w = "";
        for (i=0; i < t.length; i++) {
        	x = t.charAt(i);
        	if (v2.indexOf(x,0) != -1) w += x;
        }
        
        $("input#9").val(w);
   });
    
    $("#10").keyup(function (event) {
        var t = $("input#10").val();
        var w = "";
        for (i=0; i < t.length; i++) {
        	x = t.charAt(i);
        	if (v.indexOf(x,0) != -1) w += x;
        }
        
        $("input#10").val(w);
   });
        
    $("#14").keyup(function (event) {
        var t = $("input#14").val();
        var w = "";
        for (i=0; i < t.length; i++) {
        	x = t.charAt(i);
        	if (v2.indexOf(x,0) != -1) w += x;
        }
        
        $("input#14").val(w);
   });
        
	
});

function enderecoByCep(){

	cepvalue = $("#cep").attr('value');

	if (cepvalue.length == 10) {
		$.post(baseUrl +'/servicos/curso/enderecoporcep',
				{ cep : cepvalue },
				function(resposta){
					$('#cidade').html(resposta);
				}
		);
	}
}

function carregaCidadesPorEstado(selecionada){
	if ($("#id_uf_naturalidade").attr("value") != '') {
		$('#id_municipio').html('<option value="">Procurando...</option>');
		$.post(baseUrl +'/servicos/curso/cidadesporestado',
				{ uf : $("#id_uf_naturalidade").attr("value"),
				  cidade : selecionada
				},
				function(resposta){
					$('#id_municipio').html(resposta);
				}
		);
	} else {
		$('#id_municipio').html('<option value="">-- Selecione um estado --</option>');
	}
}

$(document).ready(function() {
    $("#exibeLista").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
    $("#exibeListaConsultorias").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
});
$(document).ready(function() {
    $("#exibeListaCliente").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
    $("#exibeListaConsultoriasCliente").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
});
$(document).ready(function() {
    $("#exibeListaColaborador").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
    $("#exibeListaConsultoriasColaborador").toggle(function() {
	    	$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
});
$(document).ready(function() {
    $("#educacaoDistancia h3").toggle(function() {
	    	$($(this).next()).show('fast');
	    	$(this).attr('class', 'destaque_seta_baixo');
        }, function() {
	        $($(this).next()).hide('fast');
	    	$(this).attr('class', 'destaque');
    });
});
$(document).ready(function() {
    $(".fotos360 h3").toggle(function() {
    		$($(this).next()).show('fast');
        }, function() {
	        $($(this).next()).hide('fast');
    });
});
$(document).ready(function() {
    $("#close").click(function() {
        $("#hiddenForm").hide(); 
    });
});
$(document).ready(function() {
    $("#objMsgInfo-1").click(function() {
    	$("#nome").parent().children(":first-child").html('Nome*');
    	$("#dsEmail").parent().children(":first-child").html('E-mail*');
    });
    $("#objMsgInfo-2").click(function() {
    	$("#nome").parent().children(":first-child").html('Nome');
    	$("#dsEmail").parent().children(":first-child").html('E-mail <span style="color:red;">(Reclamações ou Sugestões sem e-mail de contato são tratadas, mas não recebem resposta e/ou acompanhamento)</span>');
    });
    $("#objMsgInfo-3").click(function() {
    	$("#nome").parent().children(":first-child").html('Nome');
    	$("#dsEmail").parent().children(":first-child").html('E-mail <span style="color:red;">(Reclamações ou Sugestões sem e-mail de contato são tratadas, mas não recebem resposta e/ou acompanhamento)</span>');
    });
});

$(document).ready(function() {
	if ($("#objMsgInfo-1").is(':checked')) {
		$("#nome").parent().children(":first-child").html('Nome*');
    	$("#dsEmail").parent().children(":first-child").html('E-mail*');
	}
	if ($("#objMsgInfo-2").is(':checked')) {
		$("#nome").parent().children(":first-child").html('Nome');
    	$("#dsEmail").parent().children(":first-child").html('E-mail <span style="color:red;">(Reclamações ou Sugestões sem e-mail de contato são tratadas, mas não recebem resposta e/ou acompanhamento)</span>');
	}
	if ($("#objMsgInfo-3").is(':checked')) {
		$("#nome").parent().children(":first-child").html('Nome');
    	$("#dsEmail").parent().children(":first-child").html('E-mail <span style="color:red;">(Reclamações ou Sugestões sem e-mail de contato são tratadas, mas não recebem resposta e/ou acompanhamento)</span>');
	}
});

$(document).ready(function() {
    $(".consultorias ul li").toggle(function() {
    	$(".consultorias ul li div").slideUp();
        $(this).children(":first-child").slideDown(); 
        }, function() {
        	$(this).children(":first-child").slideUp();
    });
});

$(document).ready(function() {
    $(".abrirPolitica").click(function() {
    	if ($('.abrirPolitica').next().value == $(this).next().value && $(this).next().css('display') == 'block') {
    		$('.abrirPolitica').next().slideUp();
    	} else {
    		$('.abrirPolitica').next().slideUp();   
        	$(this).next().slideToggle();
    	}
    });
});
$(document).ready(function() {

    $("#buscaCursos").click(function() {
    	if ($('#nivel option').length == 0) {
	    	$.post(baseUrl +'/index/preencheniveis',
					{},
					function(resposta){
						$('#nivel').html(resposta);
					}
			);
    	}
    	if ($('#area option').length == 0) {
	    	$.post(baseUrl +'/index/preencheareas',
					{},
					function(resposta){
						$('#area').html(resposta);
					}
			);
    	}
    });
});
$(window).load(function() {
    if ($("#buscaCursos").next().css('display') == 'block') {
    	if ($('#nivel option').length == 0) {
	    	$.post(baseUrl +'/index/preencheniveis',
					{},
					function(resposta){
						$('#nivel').html(resposta);
					}
			);
    	}
    	if ($('#area option').length == 0) {
	    	$.post(baseUrl +'/index/preencheareas',
					{},
					function(resposta){
						$('#area').html(resposta);
					}
			);
    	}
    }
});

function cursosPorFaculdade(idFaculdade, curso) {
	
	
	if (idFaculdade) {
		$.post(baseUrl+'/sobre/tudosobre/faculdadecurso',
				{ faculdade : idFaculdade,
				  curso     : curso
				},
				function(resposta){
					$('#curso').html(resposta);
				}
		);
	} else {
		$('#curso').html('<option value="">Selecione uma faculdade</option>');
	}
	
	
}

/* textos expansiveis biblioteca */
$(document).ready(function() {
    $('a.expansivel').click(function() {
        id = $(this).attr('href');
        $(id).slideToggle();
    });

});
$(document).ready(function() {
	if (screen.width == 1024) {
		$('#enviaremail').css('left', '300px');
	}
	$('#abrirEmail').click(function() {
		$('#enviaremail').slideToggle();
	});
});
