$.validator.setDefaults({
	submitHandler: function() { submit(); }
});
 
 
$().ready(function() {	
	
	// valida formulario de contato 
	$("#form_contato").validate({
		rules:{
			nome:{
				required:true,
				minlength:5
			},
			email:{
				required:true,
				email:true
			},
            unidade:{
				required:true
			},
			instituicao:{
				required:true
			},
            departamento:{
				required:true
			},
            ramal:{
				required:true
			},
			senha: {
				required: true,
				minlength: 5
			},
			conf_senha: {
				required: true,
				minlength: 5,
				equalTo: "#senha"
			}
		},messages:{
			nome:{
				required:"Informe seu nome",
				minlength:"Informe mais de 5 caracteres"
			},
			email:{
				required:"Digite um e-mail v&aacute;lido"
			},
            unidade:"Escolha a unidade"	,
			instituicao:"Escolha uma instituição"	,
            departamento:"Escolha o departamento",
			ramal:"Informe seu ramal",
			senha: {
				required: "Digite sua senha",
				minlength: "Sua senha precisa ter mais de 5 caracteres"
			},
			conf_senha: {
				required: "Confirme sua senha",
				minlength: "Sua senha precisa ter mais de 5 caracteres",
				equalTo: "Confirmação de senha inválida"
			}
			
		}
	});
});		

$().ready(function() {	
	
	// valida formulario de contato 
	$("#form_indica_pagina").validate({
		rules:{
			nome:{
				required:true,
				minlength:5
			},
			email:{
				required:true,
				email:true
			},
            nomea:{
				required:true,
				minlength:5
			},
			emaila:{
				required:true,
				email:true
			},
            mensagem:{
				required:true
			}
		},messages:{
			nome:{
				required:"Informe seu nome",
				minlength:"Informe mais de 5 caracteres"
			},
			nomea:{
				required:"Informe seu nome",
				minlength:"Informe mais de 5 caracteres"
			},
			email:{
				required:"Digite um e-mail v&aacute;lido"
			},
			emaila:{
				required:"Digite um e-mail v&aacute;lido"
			},
            mensagem:"Digite sua mensagem"			
		}
	});
});		




$(document).ready(function() {	

	$('a[name=modal]').click(function(e) {
		e.preventDefault();
		
		var id = $(this).attr('href');
	
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).fadeIn(2000); 
	
	});
	
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});	
	
	//mostra os videos da pagina de curso e pagina
	$(".mostra_video").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'			: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});	
	
	
	$(".abre_img").fancybox({
				'transitionIn'	: 800,
				'transitionOut'	: 600
			});
		
});


//seleção de todos os checklist
$(document).ready(function() {
	$('#selectAll').click(function() {
		if(this.checked == true){
			$("input[type=checkbox]").each(function() { 
				this.checked = true; 
			});
		} else {
			$("input[type=checkbox]").each(function() { 
				this.checked = false; 
			});
		}
	});	
	
	
$('#envia_recomendaA').click(function() { 

	var nome      = $("#nome").val();
	var email     = $("#email").val();
	var nomea     = $("#nomea").val();
	var emaila    = $("#emaila").val();
	var mensagem  = $("#mensagem").val();
	var url_atual  = $("#url_atual").val();
	
		jQuery.ajax(
			  {
			  // Especificamos o método que quermos utilizar
				type: 'POST',			
				method: "POST",
				// Especificamos o arquivo que vai processar a solicitação
				url: fullpath+'paginas/recomenda/',
				// A QUERY STRING contendo os dados necessários
				data: "nome=" + nome+"&email="+ email +"&email="+ emaila+"&nomea="+ nomea +"&mensagem="+ mensagem +"&url_atual="+ url_atual  ,		
				// O que deve acontecer antes de ser enviado
				beforeSend: function(){
				  // Mostra a mensagem de carregando
				  jQuery("#carregando").show("fast");
				},
				// O que deve acontecer quando o processo estiver completo
				complete: function(){
				  // Oculta a mensagem carregando
				  jQuery("#carregando").hide("slow");
				},
				// Se houve sucesso vamos carregar o resultado para o argumento
				// "conteudo" para utilizá-lo onde desejarmos
				success: function(conteudo){
					alert(conteudo);		
					//$('#mask').hide();
					//$('.window').hide();		   
				   return false;
				  
				}
			  }
			);		 
			return false;
	});	
	
	
	
$('#envia_querosaber').click(function() { 

	var nomes      = $("#nomes").val();
	var emails     = $("#emails").val();
	var telefone  = $("#telefone").val();
	
	if(emails == false) {
		alert('Digite seu email');
		
			return false;
	}
			 
		jQuery.ajax(
			  {
			  // Especificamos o método que quermos utilizar
				type: 'POST',			
				method: "POST",
				// Especificamos o arquivo que vai processar a solicitação
				url: fullpath+'paginas/quero_saber_mais/',
				// A QUERY STRING contendo os dados necessários
				data: "nome=" + nomes+"&email="+ emails+"&telefone="+ telefone,		
				// O que deve acontecer antes de ser enviado
				beforeSend: function(){
				  // Mostra a mensagem de carregando
				  jQuery("#carregando").show("fast");
				},
				// O que deve acontecer quando o processo estiver completo
				complete: function(){
				  // Oculta a mensagem carregando
				  jQuery("#carregando").hide("slow");
				},
				// Se houve sucesso vamos carregar o resultado para o argumento
				// "conteudo" para utilizá-lo onde desejarmos
				success: function(conteudo){
					alert(conteudo);		
					$('#mask').hide();
					$('.window').hide();		   
				   return false;
				  
				}
			  }
			);		 
			return false;
	});		
	
	
});


//REPASSA OS VALORES DAS MARCAS SELECIONADAS
function proximo(valor)
{   
   		
	jQuery.ajax(
		  {
		  // Especificamos o método que quermos utilizar
			type: 'POST',			
			method: "POST",
			// Especificamos o arquivo que vai processar a solicitação
			url: fullpath+'calendario_detalhe',
			// A QUERY STRING contendo os dados necessários
			data: "id=" + valor ,			
			// O que deve acontecer antes de ser enviado
			beforeSend: function(){
			  // Mostra a mensagem de carregando
			  jQuery("#carregando").show("fast");
			},
			// O que deve acontecer quando o processo estiver completo
			complete: function(){
			  // Oculta a mensagem carregando
			  jQuery("#carregando").hide("slow");
			},
			// Se houve sucesso vamos carregar o resultado para o argumento
			// "conteudo" para utilizá-lo onde desejarmos
			success: function(conteudo){			 
			  // jQuery("#sub_menu").html(conteudo);
			   //$('#add_not').removeAttr('style');
			    $("#calendario_tabela").html(conteudo);	
			  
			}
		  }
		);
}

//REPASSA OS VALORES DAS MARCAS SELECIONADAS
function anterior(valor)
{   
   		
	jQuery.ajax(
		  {
		  // Especificamos o método que quermos utilizar
			type: 'POST',			
			method: "POST",
			// Especificamos o arquivo que vai processar a solicitação
			url: fullpath+'calendario_detalhe',
			// A QUERY STRING contendo os dados necessários
			data: "id=" + valor ,			
			// O que deve acontecer antes de ser enviado
			beforeSend: function(){
			  // Mostra a mensagem de carregando
			  jQuery("#carregando").show("fast");
			},
			// O que deve acontecer quando o processo estiver completo
			complete: function(){
			  // Oculta a mensagem carregando
			  jQuery("#carregando").hide("slow");
			},
			// Se houve sucesso vamos carregar o resultado para o argumento
			// "conteudo" para utilizá-lo onde desejarmos
			success: function(conteudo){			 
			  // jQuery("#sub_menu").html(conteudo);
			   //$('#add_not').removeAttr('style');
			    $("#calendario_tabela").html(conteudo);	
			  
			}
		  }
		);
}

//Funcao para exibir uma div com os conteudos da data
$(function () {
	$('.date_has_event').each(function () {
		// options
		var distance = 10;
		var time = 250;
		var hideDelay = 500;

		var hideDelayTimer = null;

		// tracker
		var beingShown = false;
		var shown = false;

		var trigger = $(this);
		var popup = $('.events ul', this).css('opacity', 0);

		// set the mouseover and mouseout on both element
		$([trigger.get(0), popup.get(0)]).mouseover(function () {
			// stops the hide event if we move from the trigger to the popup element
			if (hideDelayTimer) clearTimeout(hideDelayTimer);

			// don't trigger the animation again if we're being shown, or already visible
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;

				// reset position of popup box
				popup.css({
					bottom: 20,
					left: -76,
					display: 'block' // brings the popup back in to view
				})

				// (we're using chaining on the popup) now animate it's opacity and position
				.animate({
					bottom: '+=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					// once the animation is complete, set the tracker variables
					beingShown = false;
					shown = true;
				});
			}
		}).mouseout(function () {
			// reset the timer if we get fired again - avoids double animations
			if (hideDelayTimer) clearTimeout(hideDelayTimer);

			// store the timer so that it can be cleared in the mouseover if required
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				popup.animate({
					bottom: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					// once the animate is complete, set the tracker variables
					shown = false;
					// hide the popup entirely after the effect (opacity alone doesn't do the job)
					popup.css('display', 'none');
				});
			}, hideDelay);
		});
	});
});

/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=0 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",70)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee

$(function()
			{	// this initialises the demo scollpanes on the page.				
				$('#pane2').jScrollPane({showArrows:true});				
			});		
			
		// initialise plugins
		jQuery(function(){
			jQuery('ul.sf-menu').superfish();
		});	
