$(document).ready(function(){
	
	var a_url= $('#guetsbookForm').attr('action');
	a_url= a_url.replace(/add/, 'list');
	
	$.ajax({
			type: 'post',
			url: a_url,
		    dataType: 'html',
		    error: function(m)
		    {	
		    },
		    success: function(t)
		    {		    	
		        $('.guestbook').prepend(t);
		    }
	});
	
	$('#guetsbookForm').livequery(function(){
		$(this).submit(function(){
			
			var obj= this;
			$('.entries_list').html('<div class="ui-tabs-loading"><em></em></div>');
			
			
			var options = { 
				error: function()
				{
					$('.guestbook').html('');
				},
			    success: function(responseText) 
			    {
			    	$('.guestbook').html(responseText);	
				}
			};
				 
			$(this).ajaxSubmit(options);
			
			return false;
		});
	});
	
	/* PAGINING */
  	$(".entries_pages a.pages").livequery(function (){
	  	$(this).click(function(e)
	    {
	    	$(".entries_list").html('<div class="ui-tabs-loading"><em></em>loading</div>');
	    	
	    	var act= $(this).attr("href");			
	    	$.ajax({
				type: 'post',
				url: act,
			    dataType: 'html',
			    error: function(){
			    },
			    success: function(t){			    	
			        $("#guestbook_list").html(t);
			    }
			});
            	
            return false;
        });          	
    });
});
