if(!window.pictures)
window.pictures={};pictures.Page=function()
{}
var ctrl,root,states={},next;function togglePictures()
{var oXMLHttpRequest=new XMLHttpRequest;oXMLHttpRequest.open("GET","/layout/nextpic.php",true);oXMLHttpRequest.onreadystatechange=function()
{if(this.readyState==XMLHttpRequest.DONE&&this.status==200)
{var idx=next,url=this.responseText;var photoCtrl=root.findName("photo"+idx+(states[idx]?"a":"b")+"img");if(url!=photoCtrl.ImageSource)
{var downloader=ctrl.createObject("downloader");downloader.addEventListener("completed",function(sender,eventArgs){photoCtrl.ImageSource=url;root.findName("photo"+idx+(states[idx]?"ra":"rb")+"img").ImageSource=url;root.findName("toggle"+idx+(states[idx]?"ba":"ab")).begin();states[idx]=!states[idx];});downloader.open("GET",url);downloader.send();next=(next+1)%5;}}}
oXMLHttpRequest.send(null);}
pictures.Page.prototype={handleLoad:function(control,userContext,rootElement)
{this.control=control;ctrl=control;root=rootElement;next=0;states[0]=false;states[1]=false;states[2]=false;states[3]=false;states[4]=false;setInterval('togglePictures()',20000);}}
