//<script>
//(for syntax highlighting in an HTML editor)
function ThumbScroller(id,params){

		this.params = params
		this.inherits = Sprite;
		this.inherits(id,this.params.id);
		this.setXY(-this.params.offset*this.params.unitScroll,0);
		this.show();

		this.nextButton = new Sprite(this.id+".nextButton",params.nextID);
		this.nextButton.node.onclick=new Function(id+".next();this.blur();");
		this.nextButton.canvas.cursor="pointer";
		this.prevButton = new Sprite(this.id+".prevButton",params.prevID);
		this.prevButton.node.onclick=new Function(id+".prev();this.blur();");
		this.prevButton.canvas.cursor="pointer"
		this.nextButton.show();this.prevButton.show();
		this.perPage = params.thumbsPerPage;
		this.pageScroll = params.thumbsPerPage*params.unitScroll;
		this.offset=params.offset;
		this.loaded=new Array();
		this.loaded[this.offset]=true;



		this.next = function(){
		if(this.abusy)
			return;
			this.offset+=this.perPage;
			if(!this.loaded[this.offset+this.perPage]){
				this.getThumbs(this.offset+this.perPage);
			}
			this.Move(-this.pageScroll,0,1000);


		}
		this.prev = function(){
		if(this.abusy)
			return;
			this.offset-=this.perPage;
			if(!this.loaded[this.offset-this.perPage]){
				// getting the thumbs 1 grup before what we will see after the slinding
				this.getThumbs(this.offset-this.perPage);

			}
			this.Move(this.pageScroll,0,1000);

		}
		this.onXmlLoad = function(){
		//alert(this.HttpRequest.responseText);
			//this.newPage.innerHTML = this.HttpRequest.responseText;
			//document.getElementById('loading').style.visibility='hidden';
			td = document.createElement('div');
			td.innerHTML = this.HttpRequest.responseText;
			s = td.getElementsByTagName('span');
			//alert(s[1].innerHTML);
			this.createNewPage(s[1].innerHTML).innerHTML=s[0].innerHTML;
			this.loaded[s[1].innerHTML]=true;
			this.abusy=false;
		}
		this.getThumbs = function(offset)
			{

			this.abusy=true;
			serial = '';
			for(key in this.params){
				if(key !='q' && key != 'offset')
					serial +="&"+key+"="+escape(this.params[key]);
			}
			//alert('/postBack.php?q=w&w=ThumbScroller&offset='+offset+serial.replace(/&/,"&\n"));
			this.loadXml('/postBack.php?q=w&w=ThumbScroller&offset='+offset+serial);
			//document.getElementById('loading').style.visibility='visible';

		}
		this.createNewPage = function(offset)
		{
			d = makeChild(this.node,'div','l'+offset,'','',this.params.unitScroll*this.perPage,'auto');
			d.style.left=(offset*this.params.unitScroll)+"px";
			return d;
		}

//</script>
	}