$().ready(function(){
	$('#changepass').submit(function(){
		data=$(this).serialize();
		ajax_post("information?exe=changepass",data,'#mensaje p');
		showmessage();
		return false;
	})
	$('#edit_information').submit(function(){
		data=$(this).serialize();
		ajax_post("information",data,'#mensaje p');
		showmessage();
		return false;
	})
	$('#guardar_information').click(function(){
		$('#edit_information').submit();
	});
	$('#typepublic').click(function(){
		$('#agency').show();
	});
	$('#typeuser').click(function(){
		$('#agency').hide();
	});
	$('#guardar_itinerary').click(function(){
		$('#edit_itinerary').submit();
	});
	//$('.form-seo, .form-include').hide();
	$('.title').toggle(
		function(){
			$(this).next().hide();
		},
		function(){
			$(this).next().show();
		}
	);
	$('.changestate').click(function(){
		id=$(this).attr('value');
		state=$(this).html();
		ajax_post("itinerary?exe=changestate&id="+id,"state="+state,this);
	});
	$('#itinerary').dataTable({
		"bStateSave": true,
		"oLanguage": {
				"sLengthMenu": "Mostrar _MENU_ registros por pagina",
				"sZeroRecords": "No se ha encontrado",
				"sInfo": "Del _START_ al _END_ de _TOTAL_ registros",
				"sInfoEmtpy": "Del 0 al 0 de 0 registros",
				"sInfoFiltered": "(Registros reales: _MAX_)"
			}
	});
})
function showmessage(){
	$('#mensaje').animate({top:'0px'}, 500);
	$('#mensaje').animate({top:'0px'}, 1000);
	$('#mensaje').animate({top:'-42px'}, 500);
}
function ajax_post(url,datos,cont){
	$.ajax({
			url: url,
			type: "POST",
			data:datos,
			beforeSend: function(objeto){
				$(cont).html('<img src="../images/loading.gif" style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; position: absolute; top: 50%; left: 50%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"/>'+$(cont).html());
			},
			error: function(objeto, quepaso, otroobj){
				$(cont).html("ERROR: "+quepaso);
			},
			success:function(data){
				$(cont).html(data);
			},
			timeout:3000
	});
}

