/**
Copyright (C) 2003-2008 AJLSM, Anaphore
Voir le fichier LICENCE
**/
var PivSeries=Class.create();PivSeries.prototype={initialize:function(c,h,g,i,e,b,d,a){this.serverUrl=c;this.path=h;this.size=g;this.first=((e>=0)?e:-1);this.last=((b>=0&&b>=e)?b:-1);this.nameFirst=((d)?d:null);this.nameLast=((a)?a:null);this.setCurrentImage(i);this.sets=new Array();this.stepSize=10},fetchImageSet:function(c,b){if(c>0&&c<=this.getSize()){var a=this._fetchImageHandler(c,b);new Ajax.Request(this.getBaseUrl()+"/dir.json?"+((Object.isUndefined(this.getBaseParams())?"":this.getBaseParams())),{method:"GET",parameters:{n:c},onSuccess:a})}},fetchNamedImageSet:function(c,b){var a=this._fetchImageHandler(c,b);new Ajax.Request(this.getBaseUrl()+"/dir.json?"+this.getBaseParams(),{method:"GET",parameters:{iname:c},onSuccess:a})},_fetchImageHandler:function(b,a){return function(d){var c=d.responseText.evalJSON();var e=new PivImageSet(_pivSeries.serverUrl,c[0]);_pivSeries.addImageSet(e);_pivSeries.setCurrentImage(c[0].no);if(a){a(e,e.defaultVersion)}_pivViewer._updateAfterChange()}},addImageSet:function(a){if(a){this.sets[a.no]=a}},getBaseUrl:function(){if(this.baseUrl){return this.baseUrl}this.baseUrl=this.serverUrl+"/"+this.path;return this.baseUrl},getBaseParams:function(){if(this.baseParams){return this.baseParams}if(this.first!=-1||this.last!=-1||this.nameFirst||this.nameLast){this.baseParams=(this.first!=-1)?"&p="+this.first:"";this.baseParams+=(this.last!=-1)?"&d="+this.last:"";this.baseParams+=(this.nameFirst)?"&np="+this.nameFirst:"";this.baseParams+=(this.nameLast!=-1)?"&nd="+this.nameLast:""}else{this.baseParams==null}return this.baseParams},setCurrentImage:function(a){this.currentImageNo=a},getCurrentImage:function(){return this.currentImageNo},getCurrentImageSet:function(){return this.sets[this.currentImageNo]},init:function(){},getSize:function(){return this.size},getStepSize:function(){return this.stepSize},getFirst:function(){return this.first},getLast:function(){return this.last},getSummary:function(){return this.path},identify:function(){return"Classe PivSeries"}};
