// Config variables
q = jQuery;
time = 2000; // Pics will change every 8 seconds
timefade = 5000; // Transition effect will last for 0.4 seconds
middleWare = "hinnang_inc_leht.php?type=json";

q(document).ready( function () {

	timeout = setTimeout('showLastApprisals()', time);
} );
// AJAX function that gets the random pics
function showLastApprisals () {
i= 0;
a_hinnang_id = new Array();
q.ajax({
	url: middleWare,
	dataType: 'json',
	contentType: "application/json; charset=iso-8859-1", 
	success: function(data){
	   q(data).each( function () {
			a_hinnang_id.push(this.hinnang_id);
			q(".rating").animate({opacity: 1}, timefade).animate({opacity: 0}, 'slow', function () {
				q(this).load("/hinnang_inc_leht.php?type=array&hinnang_id="+ a_hinnang_id.shift());
			} ).animate({opacity: 1}, 'slow');
		i++;
	   } );
	}
});
	timeout = setTimeout('showLastApprisals()', 50000);
}
