var uid = 1;
var url = 'ajax-homepage.asp?rand=';

//function AjaxRequest(){

//    new Ajax('ajax-homepage.asp?&ID='+uid, {
//        method: 'get',
//        update: 'ajaxcontainer',
//	    evalScripts:true,
//	    initialize: function(){ this.fx1 = new Fx.Style('ajaxcontainer','opacity', {duration:500});  },
//	    onRequest:function(){ this.fx1.set(0); },
//	    onComplete:function(){ this.fx1.start(0.99); }
//    }).request();
//} 

Window.addEvent('domready', function() {

 
// refresh every 10 seconds
var timer = 3; 
// periodical and dummy variables for later use
var periodical, dummy; 
var log = $('log_res');
 
function AjaxRequest(uid,url){
var mySlide = new Fx.Slide('topright',{duration: 800, transition: Fx.Transitions.quadOut, wait: false});
/* our ajax istance */
var ajax = new Ajax(url + '&ID=' +uid, { 
	update: log,
    evalScripts:true,
	method: 'get',
    initialize: function(){   },
    onRequest:function(){ mySlide.hide(); },
	onComplete: function() {
		// when complete, we remove the spinner
		log.removeClass('ajax-loading'); 
		mySlide.slideIn();

	},
	onCancel: function() {
		// when we stop timed ajax while it's requesting
		// we forse to cancel the request, so here we
		// just remove the spinner
		log.removeClass('ajax-loading'); 
	}
}).request();
}

/* our refresh function: it sets a dummy to prevent 
   caching of php and add the loader class */
var refresh = (function() {
	// dummy to prevent caching of php
	dummy = $time() + $random(0, 100);
	// we add out fancy spinner
	log.empty().addClass('ajax-loading');
	// requests of our php plus dummy as query

	AjaxRequest(uid,url+dummy); 
}); 

// the periodical starts here, the * 1000 is because milliseconds required
periodical = refresh.periodical(timer * 2000, this); 
 
	// this is the first only request, later on will be only the periodical and refresh 
	// that do the request. If we don't do this way, we have to wait for 4 seconds before 
	// the first request.
	AjaxRequest(uid,url+$time()); 

});


