﻿window.addEvent('domready', function() {
	// You can skip the following two lines of code. We need them to make sure demos
	// are runnable on MooTools demos web page.
	//if (!window.demo_path) window.demo_path = '';
	//var demo_path = window.demo_path;
	// --
	
	//Empty the log and show the spinning indicator.
	var log1 = $('divnews').empty().addClass('ajax-loading');	
	var demo_path1 = 'getdata.aspx?filter=newstop3';
	
	//We can use one Request object many times.
	var req1 = new Request({

		url: demo_path1,

		onSuccess: function(news){
		    log1.removeClass('ajax-loading');
			$('divnews').set('html', news); 
		},

		// Our request will most likely succeed, but just in case, we'll add an
		// onFailure method which will let the user know what happened.
		onFailure: function(){
		    log1.removeClass('ajax-loading');
			$('divnews').set('text', 'The request failed.');
		}

	});

	req1.send();
	
	//Empty the log and show the spinning indicator.
	var log2 = $('divevents').empty().addClass('ajax-loading');	
	var demo_path2 = 'getdata.aspx?filter=eventstop3';
	
	//We can use one Request object many times.
	var req2 = new Request({

		url: demo_path2,

		onSuccess: function(events){
		    log2.removeClass('ajax-loading');
			$('divevents').set('html', events); 
		},

		// Our request will most likely succeed, but just in case, we'll add an
		// onFailure method which will let the user know what happened.
		onFailure: function(){
		    log2.removeClass('ajax-loading');
			$('divevents').set('text', 'The request failed.');
		}

	});

	req2.send();
	
});
