$(document).ready(function(){

	$('.show_modal').click(function(){
	
		var url = './url/modulo.php';
		var data = 'id=' + $(this).find('span').text();
		
		$.ajax({
		
			type: 'post',
			url: url,
			data: data,
			cache: false,

			beforeSend: function(){
				$('#basicModalContent').html('<img alt="aguarde..." src="img/ajax-loader.gif" style="margin:170px 0px 0px 270px" />');
				$('#basicModalContent').modal();
			},

			success: function(txt){
				$('#basicModalContent').html(txt);
			},
			
			error: function(){
				$('#basicModalContent').html('<div class="definicoes"><h2>Falha de Carregamento</h2><p>A página não pôde ser exibida, houve uma falha em seu carregamento.<br />Talvez a página tenha sido removida do servidor ou ainda não exista.</p></div>');
			}

		});
	});
	
	$('#formcontato').bind('submit', function(){
	
		if(!$('#nome').val()){

			$('#nome').val('informe o nome').focus().select();

		}else if(!$('#email').val()){

			$('#email').val('informe o email').focus().select();

		}else if(!$('#assunto').val()){

			$('#assunto').val('informe o assunto').focus().select();

		}else if(!$('#mensagem').val()){

			$('#mensagem').val('informe a mensagem').focus().select();

		}else{
		
			var data = $(this).serialize();
			var url = 'url/' + $(this).attr('action') + '.php';
			var type = $(this).attr('method');

			$.ajax({
			
				type: type,
				url: url,
				data: data,
				cache: false,
			
				beforeSend: function(){

					$('#formcontato input').attr('disabled', 'disabled');
					//$('#basicModalContent').html('<img alt="aguarde..." src="img/ajax-loader.gif" style="margin:170px 0px 0px 270px" />');
					//$('#basicModalContent').modal();

				},

				success: function(txt){


					$('#formcontato input').attr('disabled', '');
					$('#resposta').html(txt);

				},
				
				error: function(){
					$('#basicModalContent').html('<div class="definicoes"><h2>Falha de Carregamento</h2><p>A página não pôde ser exibida, houve uma falha em seu carregamento.<br />Talvez a página tenha sido removida do servidor ou ainda não exista.</p></div>');
				}
			
			});
		
		}
		
		return false;

	});
	
	$('.show_next').click(function(){
		$(this).parent().parent('div').animate({height:'hide', opacity: 'hide'}, 'fast').next('div').animate({height:'show', opacity: 'show'}, 'slow');
	});

	$('.show_prev').click(function(){
		$(this).parent().parent('div').animate({height:'hide', opacity: 'hide'}, 'fast').prev('div').animate({height:'show', opacity: 'show'}, 'slow');
	});
	
	$('#ver_parada').click(function(){
		var content = $(this).parent('form').serialize();
		alert(content);
		/*
		$.ajax({
			url:'show.php',
			data:,
			type:'post',
			
		});
		$('#eita').html();*/
	});
	
});
