var ActivePageSet = 0;
var ActivePage = 0;
var PreviousPage=0;
var PageSet;
var imagesPerPage;  // requested from ajax.  only for photostream.
var LoadingImg;


function PagingControl( pageWidth, pageHeight, imagesPerPg,  enableDragDrop, ImageOnclick, OutputDebugInfo, PSPgsToFetchPerCall ){


	this.Debug = !!(OutputDebugInfo);
	
	if( this.Debug )
		this.DrawDebug();

    imagesPerPage = imagesPerPg;
	LoadingImg = document.createElement('img');
	LoadingImg.src = '/images/icons/loading_wide.gif';
    PageSet = new Array();
	
	
    this.PageWidth = pageWidth;
    this.PageHeight = pageHeight;
    this.EnableDragDrop = enableDragDrop;
    this.TotalPagesPerCall = PSPgsToFetchPerCall;
	
	this.imgOnClick = (ImageOnclick==""?null:ImageOnclick);

	this.LastPSPageLoaded = null;	
	this.CurrentLoadingType  = "photostream";
	
	
}

PagingControl.prototype.DrawDebug = function(){
	
	this.debugDiv = document.createElement('div');
	this.debugDiv.style.overflow = "scroll";
	this.debugDiv.style.height = "300px";
	this.debugDiv.style.border = "4px solid #DDDDDD";
	this.debugDiv.style.backgroundColor = "#EEEEEE";
	this.debugDiv.style.fontFamily = "Tahoma";
	
	this.AddDebugMsg( 'page loaded.' );
	document.body.insertBefore( this.debugDiv, document.body.firstChild);

}


PagingControl.prototype.AddDebugMsg = function(msgString){

	if(!this.Debug) return;
	
	var msgShell = document.createElement('div');
	var curtime = new Date();
	var curmin = curtime.getMinutes();
	var curhour = curtime.getHours();
	var cursec = curtime.getSeconds();
	var time = "";

  	if(curhour == 0) curhour = 12;
	time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
         (curmin < 10 ? "0" : "") + curmin + ":" +
         (cursec < 10 ? "0" : "") + cursec + " " +
         (curhour > 12 ? "PM" : "AM");
		
	msgShell.innerHTML =  " ** "+time+": \t\t"+ "" + msgString + "<br />";	
	

	if( this.debugDiv.hasChildNodes )
		this.debugDiv.insertBefore(msgShell, this.debugDiv.firstChild );
	else this.debugDiv.appendChild(msgShell)
	
}

// there could be 5000 or more images, break it up.
PagingControl.prototype.StartImageLoad = function(){
	
	// start with the photostream
	this.Init();
	this.GoToPageSet(0);
}



PagingControl.prototype.Init = function(){
	
	this.DataBind();
}

PagingControl.prototype.DataBind = function(){
	document.getElementById('currPage').innerHTML =ActivePage+1;
	document.getElementById('pgCount').innerHTML = PageSet[ActivePageSet].length;
}

PagingControl.prototype.GoToPageSet = function( pageSet ){

	this.AddDebugMsg('going to pageset ' + pageSet)

	if( pageSet < PageSet.length ){
		
		document.getElementById(PageSet[ActivePageSet][ActivePage]).parentNode.style.display='none';
		
        ActivePageSet = pageSet ;
		ActivePage=0;
		PreviousPage = 0;

		// fix - if photostream, recursively load.

		var page = document.getElementById('page'+pageSet);
		this.CurrentLoadingType = $(page).attr('type');

		if(!(this.ImagesAreLoaded())){
			this.AddDebugMsg('page'+pageSet + ' images loaded: ' + this.ImagesAreLoaded() + ' sending get images call to : ' + PageSet[ActivePageSet][PreviousPage])
			
			if( this.LastPSPageLoaded < 1 || this.CurrentLoadingType != "photostream")
				this.GetImagePage(pageSet, 1, $(page).attr('type'), PageSet[ActivePageSet][PreviousPage]);
			else 
				this.GetImagePage(pageSet, this.LastPSPageLoaded+1, $(page).attr('type'), null);
		}
		
	
		for( var i=0; i<PageSet[ActivePageSet].length; i++ ){
			document.getElementById(PageSet[ActivePageSet][i]).style.left= this.PageWidth + 'px';
		}
		
		document.getElementById(PageSet[ActivePageSet][ActivePage]).parentNode.style.display='block';
		document.getElementById(PageSet[ActivePageSet][ActivePage]).style.display='block';
		document.getElementById(PageSet[ActivePageSet][ActivePage]).style.position='absolute';
		document.getElementById(PageSet[ActivePageSet][ActivePage]).style.top='0px';
		document.getElementById(PageSet[ActivePageSet][ActivePage]).style.left='0px';
		
		this.DataBind();	
		
	}	
	
}

PagingControl.prototype.NextPageSet = function(){
    if( ActivePageSet < PageSet.length ){
        ActivePageSet++;
		ActivePage=0;
		PreviousPage=0;
		this.Init();
    }
}

PagingControl.prototype.BackPageSet = function(){
    if( ActivePageSet > 0 ){
        ActivePageSet--;
		ActivePage=0;
		PreviousPage=0;
		this.Init();
    }
}


PagingControl.prototype.Add = function(pageSet){
    PageSet[PageSet.length] = pageSet;
}

PagingControl.prototype.Next = function(){
    if( ActivePage < (PageSet[ActivePageSet].length -1 )){

        PreviousPage = ActivePage;
		ActivePage++;
		
		this.Slide();
    }
}



PagingControl.prototype.ImagesAreLoaded = function(){
	
	this.AddDebugMsg('checking if images are loaded for type: ' + this.CurrentLoadingType);
	
	if( this.CurrentLoadingType == "photostream" ) return false; 
	
	var imgs = document.getElementById(PageSet[ActivePageSet][ActivePage]).getElementsByTagName('img');
	this.AddDebugMsg(PageSet[ActivePageSet][ActivePage] + " has " + imgs.length + " images");
	if( imgs.length < 1 ) return false; // every page should have at least one image.
	return true;
}

PagingControl.prototype.Slide = function(){

	if( PreviousPage <= ActivePage ){
		slideEm(PageSet[ActivePageSet][ActivePage], this.PageWidth, 0 ,0,0 );
		slideEm(PageSet[ActivePageSet][PreviousPage], 0, 0, this.PageWidth-(this.PageWidth*2), 0 );
	}
	else 
	{
		slideEm(PageSet[ActivePageSet][ActivePage],this.PageWidth-(this.PageWidth*2),0,0,0 );
		slideEm(PageSet[ActivePageSet][PreviousPage], 0, 0, this.PageWidth, 0 );
	}
	this.DataBind();
}

PagingControl.prototype.Back = function(){
    if( ActivePage > 0 ){
		
		PreviousPage = ActivePage;
		ActivePage--;
		
		this.Slide();
    }
}

PagingControl.prototype.GoToPage = function(page){
	if( page <= PageSet[ActivePageSet].length ){
		
		PreviousPage = ActivePage;
		ActivePage=(page-1);
				
		this.Slide();
	}
}

PagingControl.prototype.LoadImages = function(){
	
	var imgs = document.getElementById(PageSet[ActivePageSet][ActivePage]).getElementsByTagName('img');
	xImgAsyncWait(null, onImagesLoaded, null, null, null, imgs); 
	
}

PagingControl.prototype.LoadFirstPageImages = function(){
	var imgs = document.getElementById(PageSet[0][0]).getElementsByTagName('img');

	for( var i=0; i<imgs.length; i++ ){
	    $(imgs[i]).attr('src', $(imgs[i]).attr('_src'));
		
	}
	
	xImgAsyncWait(null, onFirstImagesLoaded, null, null, null, imgs); 
	
}

PagingControl.prototype.LoadImagesNoSlide = function(){
	var imgs = document.getElementById(PageSet[ActivePageSet][ActivePage]).getElementsByTagName('img');

	for( var i=0; i<imgs.length; i++ ){
	    $(imgs[i]).attr('src', $(imgs[i]).attr('_src'));
		
	}
	
	xImgAsyncWait(null, onPageSetLoaded, null, null, null, imgs); 
	
}

onPageSetLoaded = function(){
	
	paging.HideLoading();
	paging.Init();
	
}

onImagesLoaded = function(LoadingPage){
	paging.HideLoading(LoadingPage);
	paging.Slide();
	paging.Init();
	
}

onFirstImagesLoaded = function(LoadingPage){
	
//	paging.AddDebugMsg('image loading for ' + LoadingPage)
	paging.HideLoading(LoadingPage);
	
}

PagingControl.prototype.ShowLoadingNoSlide = function( pgId, nextPageid ){
	
//	var imgs = document.getElementById(pgId).getElementsByTagName('img');

	if(!document.getElementById(pgId)) return;

	this.AddDebugMsg( 'showing load for ' + nextPageid + " images, adding loading image to " + pgId );
	
	var d = document.createElement('div');
	d.id = 'LoadingPage';
	d.style.width = this.PageWidth + 'px';
	d.style.height = this.PageHeight + 'px';
	d.style.backgroundColor = "#FFFFFF";
	d.style.textAlign= "center";
	d.style.backgroundImage = 'url('+LoadingImg.src+')';
	d.style.backgroundPosition = "center";
	d.style.backgroundRepeat = "no-repeat";
	
	
//	$(d).append(LoadingImg);
	
	
	if(document.getElementById(pgId).hasChildNodes)
		document.getElementById(pgId).insertBefore(d, document.getElementById(pgId).firstChild);
	else
		document.getElementById(pgId).appendChild(d);
		
	setTimeout( 'paging.HideLoading("'+pgId+'");', 5000 );
		
//	var imgs = document.getElementById(nextPageid).getElementsByTagName('img');
	
}

PagingControl.prototype.ShowLoading = function( pgId, nextPageid ){
	var imgs = document.getElementById(pgId).getElementsByTagName('img');
	
	var d = document.createElement('div');
	d.style.width = "100%";
	d.style.height = "100%";
	d.style.backgroundColor = "#FFFFFF";
	d.style.textAlign = "center";
	d.style.verticalAlign = "middle";
	
	d.appendChild(LoadingImg);
	
	document.getElementById(pgId).insertBefore(d, document.getElementById(pgId).firstChild);
	xImgAsyncWait(null, onImagesLoaded, null, null, null, imgs, pgId); 
	
}

PagingControl.prototype.LoadFirstPage = function(){
	
	var d = document.createElement('div');
	d.style.width = "100%";
	d.style.height = "100%";
	d.style.backgroundColor = "#FFFFFF";
	d.style.backgroundImage = LoadingImg;
	d.style.backgroundPosition = "center";
	d.style.backgroundRepeat = "no-repeat";
	
	var pg = document.getElementById(PageSet[0][0]);
	pg.style.display = "block";
	pg.style.top = "0px";
	pg.style.left = "0px";
	pg.insertBefore(d, pg.firstChild);
	
	
		
}

PagingControl.prototype.FillInImagesForPage = function( pg, pageText, loadingPageID){

	
	var page = document.getElementById('page'+pg); // this is the outer page, we need to populate the inner pagesets.

	// pageChunk = 1 == 0
	// pageChunk = 2 == 4
	// pageChunk = 3 == 8
	// pageChunk = 4 == 12 etc. 
	 
	
	var images= pageText.split('][');
	
	var PageChunk = images[0];
	startPage = (PageChunk == 1)?0:(PageChunk-1) * this.TotalPagesPerCall;

	this.AddDebugMsg( 'Getting images chunk ' +PageChunk+ ' for page: ' + page.id + 'starting with page: ' + startPage  );


	var child = startPage;
	var perPage = 0;
	var pgSet = document.getElementById('page' + pg + 'set' + child);
	if( !pgSet ) return false;
//	this.AddDebugMsg('loading first page: startpage: ' + startPage + ' pgset id: ' + pgSet.id );
	if( !!( $(pgSet).attr('loaded') ) ){
		this.AddDebugMsg( pgSet.id + ' has been loaded it appears.  ' );
		return;
	}
	
	var allImgs = new Array();
	this.AddDebugMsg( 'we have ' + images.length + " images to load for " + pgSet.id + ". the max images to load is " + imagesPerPage + " on one page." );
	for( var i=1; i<images.length; i++){
//		this.AddDebugMsg('&nbsp;&nbsp;&nbsp;&nbsp;adding image:at pos ' + i   );
		var imgstr = images[i];
		var img = document.createElement('img');
		img.className = 'flickr_image';
		img.style.width = "75px"; 
		img.style.height = "75px" ; 
		img.style.margin = "3px 0 0 3px" ; 
		var name = imgstr.split('|')[0];
		var tags = imgstr.split('|')[1];
		var alt = imgstr.split('|')[2];
		var src = imgstr.split('|')[3];
		var bigSrc = imgstr.split('|')[4];
		var schoolID = imgstr.split('|')[5];
		
		
		$(img).attr('name', name);
		$(img).attr('id', name);
		$(img).attr('tags', tags);
		$(img).attr('alt', alt);
		$(img).attr('src', src);
		$(img).attr('bigSrc', bigSrc);
		$(img).attr('schoolID', schoolID);
		
		
		
		if( this.imgOnClick != null )
			$(img).bind( 'mousedown', function(){ProcessPhoto(this)} );
		    
//		this.AddDebugMsg( 'image added: onclick=' + img.onclick)

		if( this.EnableDragDrop ){
		
    		$(img).Draggable({
    	    
                revert:			true,
        		ghosting:		true,
        		fx:				200,
        		onStart:		function ()
        		{
        			$(this).addClass('dragging_original');
        		},
        		onStop:			function ()
        		{
        		    $(this).removeClass('dragging_original');
        		}
        	});
		}
		
		if(i <= imagesPerPage){
			allImgs[i-1] = img;
		}
		$(pgSet).append(img);
		
		perPage ++;
		$(pgSet).attr('loaded', true);
		
		if( perPage == imagesPerPage || perPage == (images.length - 1)){
			
			child++;

			if( child == 1 ){
				this.AddDebugMsg('sending watch for : ' + allImgs.length + " images.  loading page id: "+ loadingPageID);
				xImgAsyncWait(null, onFirstImagesLoaded, null, null, null, allImgs, loadingPageID);
			}


			pgSet = document.getElementById('page' + pg + 'set' + child);
			if( !!pgSet ){
				this.AddDebugMsg('now filling <b>'+pgSet.id+'</b> which contains: <b>' +  pgSet.getElementsByTagName('img').length + '</b> images.' );
			}
			perPage = 0;
		}
	}
	return true;
}

PagingControl.prototype.GetImagePage = function(page, pageChunk, type, loadingPageId){

    if( !(loadingPageId) )loadingPageId = null;
	this.AddDebugMsg('getting image page '+ page +' chunk ' + pageChunk + ' for ' + loadingPageId + ' last page loaded was ' + paging.LastPSPageLoaded)
	
	var pgSet = document.getElementById( 'page' + page );
	var totalImages = $(pgSet).attr('totalImages');
	var maxImagesToFetchPerCall = (this.TotalPagesPerCall*imagesPerPage);
	var totalCalls=  Math.ceil((totalImages) / maxImagesToFetchPerCall);
	
    this.ShowLoadingNoSlide(loadingPageId , loadingPageId );
	this.AddDebugMsg('calling ajax: pagechunk: ' + pageChunk + ' page: ' + page + ' loadingpageid ' + loadingPageId + ' - total Images: ' + totalImages  + ' total calls: ' + totalCalls);

	AjaxRequest.post({
	    'url':          '/services/Paging.ashx',
	    'page':         pageChunk,
	    'perpage':      imagesPerPage * this.TotalPagesPerCall,
	    'set':          type,
        
		'onSuccess':    function(req) {
	
			paging.FillInImagesForPage(page, req.responseText, loadingPageId);
	
	    },
		'onError':      function(req) {
	        alert("Ajax error in GetImagePage: \n" + req.responseText ); 	
	    }
	});
    return;

}

PagingControl.prototype.HideFirstLoading = function(){
	document.getElementById(PageSet[0][0]).removeChild(document.getElementById(PageSet[0][0]).firstChild);
}

PagingControl.prototype.HideLoading = function(loadingPage){
    this.AddDebugMsg('removing loading image for ' + loadingPage );
	if(document.getElementById(loadingPage).firstChild.id == 'LoadingPage'){
    	
		document.getElementById(loadingPage).removeChild(document.getElementById(loadingPage).firstChild);

		slideEm(PageSet[ActivePageSet][ActivePage], this.PageWidth, 0, 0, 0 );
		
		this.DataBind();
	}
	else 
	    this.AddDebugMsg(loadingPage + ' does not contain a loading image.');
//    }
//    else ( setTimeout( "paging.HideLoading('"+loadingPage+"')", 2000 ) )
}


function xImgAsyncWait(fnStatus,fnInit,fnError,sErrorImg,sAbortImg,imgArray, pgId){

	var i,imgs=imgArray||document.images;

	for(i=0;i<imgs.length;++i){
		imgs[i].onload=imgOnLoad;
		imgs[i].onerror=imgOnError;
		imgs[i].onabort=imgOnAbort;
	}

	xIAW.fnStatus=fnStatus;
	xIAW.fnInit=fnInit;
	xIAW.fnError=fnError;
	xIAW.imgArray=imgArray;
	xIAW.LoadingPage = pgId;
	
	xIAW();

	function imgOnLoad(){
		this.wasLoaded=true;
	}

	function imgOnError(){
		if(sErrorImg&&!this.wasError){
			this.src=sErrorImg;
		}
		this.wasError=true;

	}
	function imgOnAbort(){
		if(sAbortImg&&!this.wasAborted){
			this.src=sAbortImg;
		}
		this.wasAborted=true;
	}

}

function xIAW(){
	var me=arguments.callee;
	if(!me){
		return;
	}
	var i,imgs=me.imgArray?me.imgArray:document.images;
	var c=0,e=0,a=0,n=imgs.length;
	for(i=0;i<n;++i){
		if(imgs[i].wasError){
			++e;
		}else if(imgs[i].wasAborted){
			++a;
		}else if(imgs[i].complete||imgs[i].wasLoaded){
			++c;
		}
	}
	if(me.fnStatus){
		me.fnStatus(n,c,e,a);
	}
		
	if(c+e+a==n){
		if((e||a)&&me.fnError){
			me.fnError(n,c,e,a);
		}else if(me.fnInit){
			paging.AddDebugMsg('all loaded ' + me.LoadingPage); 
			me.fnInit( me.LoadingPage );
		}
	}
	else setTimeout('xIAW()',250);
}

function xImgRollSetup(p,s,x){
	var ele,id;
	for(var i=3;i<arguments.length;++i){
		id=arguments[i];
		if(ele=xGetElementById(id)){
			ele.xIOU=p+id+x;
			ele.xIOO=new Image();
			ele.xIOO.src=p+id+s+x;
			ele.onmouseout=imgOnMouseout;
			ele.onmouseover=imgOnMouseover;
		}
	}

	function imgOnMouseout(e){
		if(this.xIOU){
			this.src=this.xIOU;
		}
	}

	function imgOnMouseover(e){
		if(this.xIOO&&this.xIOO.complete){
			this.src=this.xIOO.src;
		}
	}
}

function xTriStateImage(idOut,urlOver,urlDown,fnUp){
	var img;
	if(typeof Image!='undefined'&&document.getElementById){
		img=document.getElementById(idOut);
		if(img){
			var urlOut=img.src;
			var i=new Image();
			i.src=urlOver;
			
			i=new Image();
			i.src=urlDown;
			img.onmouseover=function(){
				this.src=urlOver;
			};
			img.onmouseout=function(){
				this.src=urlOut;
			};
			img.onmousedown=function(){
				this.src=urlDown;
			};
			img.onmouseup=function(){
				this.src=urlOver;
				if(fnUp){
					fnUp();
				}
			};
		}
	}

	this.onunload=function(){
		if(!window.opera&&img){
			img.onmouseover=img.onmouseout=img.onmousedown=null;
			img=null;
		}
	};
}






Slider.holder = {}; 
// constructor
function Slider(id,x,y,w,h) {
  var el = Slider.GetElement(id);
  if (!el) return;  this.id = id; 
  Slider.holder[this.id] = this; this.animString = "Slider.holder." + this.id;
  var px = window.opera? 0: "px";
	this.x = x || 0;	if (x) el.style.left = this.x + px;
	this.y = y || 0;	if (y) el.style.top = this.y + px;
	this.w = w || el.offsetWidth || 0;	this.h = h || el.offsetHeight || 0;
	// if w/h passed, set style width/height
	if (w) el.style.width = w + px; if (h) el.style.height = h + px;
}

Slider.GetElement = function(id) { 
  var el = document.getElementById? document.getElementById(id): null;
  return el;
} 

Slider.getInstance = function(id) {
  var obj = Slider.holder[id];
  if (!obj) obj = new Slider(id);
  else if (!obj.el) obj.el = Slider.GetElement(id);
  return obj;
}

Slider.prototype.shiftTo = function(x,y) {
  var el = this.el? this.el: Slider.GetElement(this.id)? Slider.GetElement(this.id): null;
  if (el) {
    if (x != null) el.style.left = (this.x = x) + "px";
    if (y != null) el.style.top = (this.y = y) + "px";
  }
}

Slider.prototype.shiftBy = function(x,y) { this.shiftTo(this.x+x, this.y+y); }

Slider.prototype.show = function() { 
  var el = this.el? this.el: Slider.GetElement(this.id)? Slider.GetElement(this.id): null;
  if (el) el.style.visibility = "visible"; 
}
Slider.prototype.hide = function() { 
  var el = this.el? this.el: Slider.GetElement(this.id)? Slider.GetElement(this.id): null;
  if (el) el.style.visibility = "hidden"; 
}

  
// for time-based animations
// resources: www.13thparallel.org and www.youngpup.net (accelimation)
var dw_Bezier = {
  B1: function (t) { return t*t*t },
  B2: function (t) { return 3*t*t*(1-t) },
  B3: function (t) { return 3*t*(1-t)*(1-t) },
  B4: function (t) { return (1-t)*(1-t)*(1-t) },
  // returns current value based on percentage of time passed
  getValue: function (percent,startVal,endVal,c1,c2) {
    return endVal * this.B1(percent) + c2 * this.B2(percent) + c1 * this.B3(percent) + startVal * this.B4(percent);
  }
}

// adapted from accelimation.js by Aaron Boodman of www.youngpup.net
dw_Animation = {
  instances: [],
  add: function(fp) {
    this.instances[this.instances.length] = fp;
  	if (this.instances.length == 1) this.timerID = window.setInterval("dw_Animation.control()", 10);
  },
  
  remove: function(fp) {
    for (var i = 0; this.instances[i]; i++) {
  		if (fp == this.instances[i]) {
  			this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) );
  			break;
  		}
  	}
  	if (this.instances.length == 0) {
  		window.clearInterval(this.timerID);	this.timerID = null;
  	}
  },
  
  control: function() {
    for (var i = 0; this.instances[i]; i++) {
  		if (typeof this.instances[i] == "function" ) this.instances[i]();
      else eval(this.instances[i]);
    }
  }
}

Slider.prototype.slideTo = function (destX,destY,slideDur,acc,endFn) {
	if (!document.getElementById) return;

	this.slideDur = slideDur || .0001; var acc = -acc || 0;

	if (endFn) this.onSlideEnd = endFn;
	// hold destination values (check for movement on 1 axis only)
	if (destX == null) this.destX = this.x;	else this.destX = destX;
	if (destY == null) this.destY = this.y; else this.destY = destY;
	
	this.startX = this.x; this.startY = this.y;
	this.st = new Date().getTime();
	// control points for bezier-controlled slide (see www.youngpup.net accelimation)
	this.xc1 = this.x + ( (1+acc) * (this.destX-this.x)/3 );
	this.xc2 = this.x + ( (2+acc) * (this.destX-this.x)/3 );
	this.yc1 = this.y + ( (1+acc) * (this.destY-this.y)/3 );
	this.yc2 = this.y + ( (2+acc) * (this.destY-this.y)/3 );
	this.sliding = true;
	this.onSlideStart();
	
	dw_Animation.add(this.animString + ".doSlide()");
}

Slider.prototype.doSlide = function() {
	if (!this.sliding) return;	
	var elapsed = new Date().getTime() - this.st;
	if (elapsed < this.slideDur) {
    var x = dw_Bezier.getValue(elapsed/this.slideDur, this.startX, this.destX, this.xc1, this.xc2);
    var y = dw_Bezier.getValue(elapsed/this.slideDur, this.startY, this.destY, this.yc1, this.yc2);
		this.shiftTo( Math.round(x) ,Math.round(y) );
		this.onSlide();
	} else {	// if time's up
	    dw_Animation.remove(this.animString + ".doSlide()");
		this.shiftTo(this.destX,this.destY);
		this.onSlide();
		this.sliding = false;
		this.onSlideEnd();
	}
}

Slider.prototype.slideBy = function(dx,dy,slideDur,acc,endFn) {
	var destX=this.x+dx; var destY=this.y+dy;
	this.slideTo(destX,destY,slideDur,acc,endFn);
}

Slider.prototype.onSlideStart = function () {}
Slider.prototype.onSlide = function () {}
Slider.prototype.onSlideEnd = function () { if (this.el) this.el = null; }
