$(document).ready(function() {
	if($.browser.msie && ($.browser.version <= 7)){ $("body").addClass("ie"); } // Adiciona uma classe para o IE6.
	$("#menu").flash({ src: 'swf/menu.swf', width: 1000, height: 100, scale: 'noscale', salign: 'lt', wmode: 'opaque', bgcolor: '#000000', flashvars: {area: ['trabalheconosco'].join(' ')} }, {version: 7});
	
	$("#video").flash({ width: 640, height: 384, wmode: 'opaque' }, { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.src = 'http://www.youtube.com/v/Nr_k0iR12WA&hl';
            $this.html($.fn.flash.transform(htmlOptions));
        }
	);
	
	$("div#accordion h3").click(function(){
		$("div#accordion h3").removeClass("hover");
		$(this).parent().find(".accor").slideUp();
		if($(this).next().is(":visible")){
			$(this).removeClass("hover");
			$(this).next().slideUp();
		}
		else{
			$(this).addClass("hover");
			$(this).next().slideDown();
		}
	});

	$("#formIndique").validate({ errorContainer: $("#msgError"), errorLabelContainer: $(".msgError"),
		submitHandler: function() {
			$.ajax({  
				data: $("#formIndique").serialize(),  
				dataType: "json",
				url: 'Est2009EnviaEmailIndique.aspx',
				success: function(json) {
					if( json.success == "true" ) {
						$(".boxIndique .content").hide();
						$("#msgSucesso").fadeIn().animate({opacity: 1.0}, 3000, function(){ // mostra a mensagem de sucesso e depois novamente o formulario de envio
							$(this).hide();
							$(".boxIndique .content").fadeIn();
						});
						$("#formIndique input").val("");
					} else {
						$("#msgError").html("Ocorreu um erro [" + json.success + "]! Tente novamente.").fadeIn().animate({opacity: 1.0}, 4000).fadeOut('slow');
					}
				}  
			}); 
		}
	});

	$("#formInscricao").validate({ errorContainer: $("#msgError"), errorLabelContainer: $(".msgError"),
		submitHandler: function() {
			$.ajax({  
				data: $("#formInscricao").serialize(),  
				dataType: "json",
				url: '/Est2009Login.aspx',
				success: function(json) {
					if( json.success == "true" ) {
						window.parent.location = "/AreaInteresse.aspx?ParamEstagio=8";
					} else {
						alert(json.success);
					}
				}  
			});
		}
	});
	
	$("#formEsqueciSenha").validate({ errorContainer: $("#msgError"), errorLabelContainer: $(".msgError"),
		submitHandler: function() {
			$.ajax({  
				data: $("#formEsqueciSenha").serialize(),  
				dataType: "json",
				url: '/Est2009EsqueciSenha.aspx',
				success: function(json) {
					if( json.success == "true" ) {
						parent.tb_show('', '/tb/esqueciSenhaSucesso.aspx?keepThis=true&TB_iframe=true&width=335&height=233', false);
					} else {
						alert(json.success);
					}
				}  
			});
		}
	});

	$("a.downloadPassoPasso").click(function(){
		pageTracker._trackPageview("/estagio/download/pdfPassoAPasso");
	});
	
	$("a.tbWall").click(function(){
		$url = $(this).attr("href").split("#")[1];
		tb_show('', '/tb/wallpaper'+ $url +'.html?keepThis=true&TB_iframe=true&width=631&height=567', false);
		pageTracker._trackPageview("/estagio/download/wallpaper" + $url);
		return false;
	});
	
	$(".resolucao a").click(function(){
		$wallpaper = $(this).attr("rel");
		$resolucao = $(this).attr("class").split("n")[1];
		pageTracker._trackPageview("/estagio/download/" + $wallpaper + "/" + $resolucao);
	});

	$("a.btnInscreverSe").click(function(){
		tb_show('', '/tb/inscricao.aspx?keepThis=true&TB_iframe=true&width=335&height=372', false);
		pageTracker._trackPageview("/estagio/inscrever-se");
		return false;
	});

	$("a.btnEsqueciSenha").click(function(){
		parent.tb_show('', '/tb/esqueciSenha.aspx?keepThis=true&TB_iframe=true&width=335&height=314', false);
		return false;
	});
	
	$("#btnCancelar").click(function(){
		parent.tb_show('', '/tb/inscricao.aspx?keepThis=true&TB_iframe=true&width=335&height=372', false);
		return false;
	});
	
	$("a.tbMarcaPagina").click(function(){
		tb_show('', '/tb/marcaPaginas.html?keepThis=true&TB_iframe=true&width=255&height=641', false);
		pageTracker._trackPageview("/estagio/download/marcaPagina");
		return false;
	});

	$('#btnTwitter').click(function(){
		$url = encodeURI("http://twitter.com/home?status=Campanha 2009 - O Estágio não tem segredo. http://www.youtube.com/watch?v=Nr_k0iR12WA");
		window.open($url);
		return false;
	});

	$("input.tel").mask("99-99999999");
	$("input.cep").mask("99999-999");
	$("input.cpf").mask("999.999.999-99");
	$("input.cnpj").mask("99.999.999/9999-99");
	$(".fix, h1, .dest h3").ifixpng();
	
});