	
	/*
	JavaScript Document
	*/
	
	function BuscaEmail(formulario){
		
		$form		= $("#"+formulario);
		$yes		= $("#yes-email");
		$no			= $("#no-email");
		$already	= $("#already");
		$loader		= $("#loader");
		$email		= $(".email-buscado");
		$inscrito	= $("email_hidden");
		
		var val_email	= $("input[name='email-para-buscar']").val();
		var val_actio	= $form.attr('action');
		var curso		= $("input[name='curso']").val();
		
		$inscrito.attr('value', val_email);
		
			$.ajax({
	
    			// Usando metodo Post
		        type: 'GET',
		
    			// this.action pega o script para onde vai ser enviado os dados
	    	    url: val_actio+"?interessado="+val_email+"&curso="+curso,
			
	    		// os dados que pegamos com a função serialize()
	        	data: val_email,
			
    			// Antes de enviar
		        beforeSend: function(){
	    	        // mostro a div loading
					$loader.show();
					$yes.slideUp();
					$no.slideUp();
					$already.slideUp();
			    },
						
	        	success: function(txt){
		    	    if(txt == "RICIERI"){
    	    	        $loader.delay(1200, function(){
							$email.text(val_email);
							$yes.slideDown(350);
							$loader.fadeOut(350);
						});
					}
					else if(txt == "HENDRIX"){
    	    	        $loader.delay(1200, function(){
							//$email.text(val_email);
							$already.slideDown(350);
							$loader.fadeOut(350);
						});
					}
					else {
						$email.text(val_email);
						$yes.slideUp(350);
						$no.slideDown(350);
						$loader.fadeOut(350);
					}
	    	    },
			
	    		// Se acontecer algum erro é executada essa função
        		error: function(txt){
    		   		alert("Ocorreu um erro de sistema. Por favor, tente novamente mais tarde."+" "+txt );
			    }
		    })
			//return false;
	}
	
	//reescreve em cima do parametro
	function RewriteParam(host){
		$email = $("input[name='email']").val();
		$("#rewrite").attr("href", host+"index.php/dados-da-inscricao/"+$email);
	}
	
	//submit form
	function gotoSubmit(form) {
		
		var f = document.getElementById(form);
		f.submit();
	}
	
	//excluindo atividade ...
	function ExcluirAtividade(elemento, host){

    	if(confirm("Tem certeza que deseja excluir esta atividade?") == true){
			
			var e = elemento;
			var h = host;
			var action = h + "site/agenda/excluir-atividade.php?atividade=" + e;
        	
			$elemento 	= $("#a"+e);
			$msgm		= $("#msgm");
    	    
        	var params = e;

    	    $.ajax({
	
    			// Usando metodo Post
		        type: 'GET',
		
    			// this.action pega o script para onde vai ser enviado os dados
	    	    url: action,
			
	    		// os dados que pegamos com a função serialize()
	        	data: e,
			
    			// Antes de enviar
		        beforeSend: function(){
	    	        // mostro a div loading
			    },
						
	        	success: function(txt){
		    	    if(txt == "RICIERI"){
    	    	        $elemento.fadeOut(350);
						//$msgm.show();
						//$msgm.text("sucesso: "+txt);
					}
					else {
						alert("Ocorreu um erro de sistema. Por favor, tente novamente mais tarde.");
						//$msgm.show();
						//$msgm.text("sucesso + erro: "+txt);
					}
	    	    },
			
	    		// Se acontecer algum erro é executada essa função
        		error: function(txt){
    		   		$msgm.show();
					$msgm.text("erro: "+txt);
			    }
		    })
			//return false;
		}
		else {
			return false;
		}
	}