
function slideshowStart(nid)
{
	// calcuate time
	t=rand(5000, 8000);
	setTimeout("slideshow(" + nid + ")",t);
}

function slideshow(nid)
{
	/*
	$.ajax({
		url: 'ajax_slideshow.php',
		type: "POST",
		data: ({'nid': nid}),
		dataType: "html",
		async:false,
		success: function(data) {
			updateImageHtml(data,nid)
		}
	});
	//*/
	new Ajax.Request('ajax_slideshow.php',
	{
		parameters: {nid: nid},
		method:'POST',
		onSuccess: function(transport){
			//var response = transport.responseText || "no response text";
			var response = transport.responseText || false;
			//alert(response);
			//alert("Success! \n\n" + response);
			updateImageHtml(response,nid);
				
				//$(pbid + "-box").innerHTML=response;
				//$(pbid + "-box").style.display = 'block';
				//var number= Math.floor(Math.random()*5)*2200+2000;
			//}
			//setTimeout("picupdate(" + nid + ",'" + pbid + "')",number);
		},
		onFailure: function(){ /*alert('Something went wrong...')*/ }
	}); 

	
	// calcuate time
	t=rand(5000, 8000);
	setTimeout("slideshow(" + nid + ")",t);
}
	
 
 function updateImageHtml(data,nid){
	setTimeout("appearPicture(\'" + data + "\'," + nid + ");",1000);
	Effect.Fade('slideshow-' + nid, { duration: 1.0});  
 }
 
 function appearPicture(data,nid){
	$('slideshow-' + nid).innerHTML=data;
	$('slideshow-' + nid).style.display='none';
	Effect.Appear('slideshow-' + nid, { duration: 1.0 });
 }
 
 
function rand(l,u) // lower bound and upper bound
{
	return Math.floor((Math.random() * (u-l+1))+l);
}

