
function implementsInterface(obj) {
	var prototypeObj={};
	for (var i=0; i<arguments.length; i++) {
		for (var method in arguments[i]) {
			prototypeObj[method]=arguments[i][method];
		}	
	}
	return prototypeObj;
}

function addObjectMethods(targetClass, methodObject) {
	for (var method in methodObject) {
		targetClass.prototype[method]=methodObject[method];
	}
}

DHTMLApi = {
	
	CSS : {
		getStyle: function (element, name) {
			var styleObj;
			if (element.style[name]) return element.style[name];
			if (element.currentStyle) {	
				name=name.replace(/-([a-z])/g, function (matched) {
					return matched.toUpperCase().slice(1, matched.length);
				});
				return element.currentStyle[name];
			}
			if (document.defaultView && document.defaultView.getComputedStyle) {
				name=name.replace(/([A-Z])/g,"-$1");
				name=name.toLowerCase();
				styleObj=document.defaultView.getComputedStyle(element,"");
				return styleObj && styleObj.getPropertyValue(name);
			} else {
				return null;
			}
		},
		
		setProperties: function (element, properties) {
			var oldProperties={};
			for (var i in properties) {
				oldProperties[i]=element.style[i];
				element.style[i]=properties[i];
			}
			return oldProperties;
		},
		
		setClass:function (element,addClassesArray,removeClassesArray) {
			var currentClasses=new Array();
			var newClasses=new Array();
			var removedClasses=new Array();
			findWordsExp=new RegExp("\\w+", "g");
			var result;
			while ((result= findWordsExp.exec(element.className))!= null) currentClasses.push(result[0]); 
			for (var i=0; i<addClassesArray.length; i++) {
				var classExists=false;
				for (var j=0; j<currentClasses.length; j++) {
					if (currentClasses[j]==addClassesArray[i]) {
						classExists=true;
						break;
					}					
				}
				if (!classExists) newClasses.push(addClassesArray[i]);
			}
			currentClasses=currentClasses.concat(newClasses);
			if (removeClassesArray==null) return removedClasses;
			for (var i=0; i<removeClassesArray.length; i++) {
				for (var j=0; j<currentClasses.length; j++) {
					if (currentClasses[j]==removeClassesArray[i]) {
						removedClasses=removedClasses.concat(currentClasses.splice(j,1));
						break;
					}					
				}
			}
			element.className=currentClasses.join(" ");
			return removedClasses;
		}
	},
	
	Position : {
		getXPosOnPage: function (element) {
			return element.offsetParent?element.offsetLeft+DHTMLApi.Position.getXPosOnPage(element.offsetParent):element.offsetLeft;
		},
		
		getYPosOnPage: function (element) {
			return element.offsetParent?element.offsetTop+DHTMLApi.Position.getYPosOnPage(element.offsetParent):element.offsetTop;
		},
		
		getXPosInElement: function (element,container) {
			return DHTMLApi.Position.getXPosOnPage(element)-DHTMLApi.Position.getXPosOnPage(container);
		},
		
		getYPosInElement: function (element,container) {
			return DHTMLApi.Position.getYPosOnPage(element)-DHTMLApi.Position.getYPosOnPage(container);
		},
		
		setXPosOnPage: function (element,posX) {
			var propertiesArray={};
			if (element.parentNode!=document.body) {
				element=element.parentNode.removeChild(element);
				document.body.appendChild(element);
			}
			if (DHTMLApi.CSS.getStyle(element,"position")!="absolute") {
				propertiesArray={position: "absolute"};
			}
			propertiesArray.left=posX+"px";
			DHTMLApi.CSS.setProperties(element,propertiesArray);
		},
		
		setYPosOnPage: function (element,posY) {
			var propertiesArray={};
			if (element.parentNode!=document.body) {
				element=element.parentNode.removeChild(element);
				document.body.appendChild(element);
			}
			if (DHTMLApi.CSS.getStyle(element,"position")!="absolute") {
				propertiesArray={position: "absolute"};
			}
			propertiesArray.top=posY+"px";
			DHTMLApi.CSS.setProperties(element,propertiesArray);
		},
		
		setXPos: function (element, posX, relativeToElement) {
			if (relativeToElement==undefined) {
				element.style.left=posX+"px";
			} else {
				if(DHTMLApi.CSS.getStyle(element.parentNode,"position")=="static"){
					element.parentNode.style.position="relative";
				}
				element.style.position="absolute";
				element.style.left=(posX-DHTMLApi.Position.getXPosInElement(element.parentNode,relativeToElement))+"px";
			}
		},
		
		setYPos: function (element, posY, relativeToElement) {
			if (relativeToElement==undefined) {
				element.style.top=posY+"px";
			} else {
				if(DHTMLApi.CSS.getStyle(element.parentNode,"position")=="static"){
					element.parentNode.style.position="relative";
				}
				element.style.position="absolute";
				element.style.top=(posY-DHTMLApi.Position.getYPosInElement(element.parentNode,relativeToElement))+"px";
			}
		}
		
	},
	
	Size : { 
		
		getElementWidth : function (element) {
			var tempProperties, width;
			if (DHTMLApi.CSS.getStyle(element, "display" ) != "none") {
				return element.offsetWidth || parseInt(DHTMLApi.CSS.getStyle(element, "width"));
			}
			tempProperties=DHTMLApi.CSS.setProperties(element, {display: "block", visibility: "hidden", position: "absolute"});
			width=element.clientWidth || parseInt(DHTMLApi.CSS.getStyle(element, "width"));
			DHTMLApi.CSS.setProperties(element, {display: "", visibility: "", position: ""});
			DHTMLApi.CSS.setProperties(element,tempProperties);
			return width;		
		},
		
		getElementHeight : function (element) {
			var tempProperties, height;
			if (DHTMLApi.CSS.getStyle(element, "display" ) != "none") {
				return element.offsetHeight || parseInt(DHTMLApi.CSS.getStyle(element, "height"));
			}
			tempProperties=DHTMLApi.CSS.setProperties(element, {display: "block", visibility: "hidden", position: "absolute"});
			height=element.clientHeight || parseInt(DHTMLApi.CSS.getStyle(element, "height"));
			DHTMLApi.CSS.setProperties(element, {display: "", visibility: "", position: ""});
			DHTMLApi.CSS.setProperties(element,tempProperties);
			return height;
		},
		
		getPageWidth: function () {
			//return Math.max(document.body.scrollWidth,document.body.offsetWidth);
			return (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth;
		},
		
		getPageHeight: function () {
			//var height=(typeof document.documentElement != "undefined" && typeof document.documentElement.offsetHeight != "undefined") ? document.documentElement.offsetHeight : 0;
			//return Math.max(document.body.scrollHeight,document.body.offsetHeight,height);
			return (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
		}
	
	},
	
	Visibility: {
		
		show: function (element) {
			element.style.display=element.__display__ || 'block';
		},
		
		hide: function (element) {
			var currentDisplay=DHTMLApi.CSS.getStyle(element,"display");
			if (currentDisplay != 'none') element.__display__=currentDisplay;
			element.style.display='none';
		},
		
		setOpacity: function (element,percent) {
			if (element.filters) {	
				element.style.filter='alpha(opacity='+percent+')';
			} else {
				element.style.opacity=percent/100;
			}
		}
		
	},
	
	Browser : {
		
		getViewportWidth: function () {
			return self.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth;
		},
		
		getViewportHeight: function () {
			return self.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight;
		},
		
		getScrollX: function () {
			return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft;
		},
		
		getScrollY: function () {
			return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
		}
		
	}
};

MousePositionOnPage = {
	getX: function (mouseEvent) {
		return mouseEvent.pageX || mouseEvent.clientX+DHTMLApi.Browser.getScrollX();
	},
	getY: function (mouseEvent) {
		return mouseEvent.pageY || mouseEvent.clientY+DHTMLApi.Browser.getScrollY();
	}
};


function DOMEventHandle(element, type, handler) {
	this.element=element;
	this.type=type;
	this.handler=handler;
}

DOMEvent = {	

	// public
	
	addDomListener: function (element, type, handler) {
		var handlers, newHandler;
		newHandler=this.modifyHandlerExceptions(element, type, handler);
		if (newHandler!==false) handler=newHandler;
		if (!handler.__id__) handler.__id__ = DOMEvent.currentId++;
		if (!element.events) element.events = {};
		handlers = element.events[type];
		if (!handlers) {
    		handlers = element.events[type] = {};
		    if (element["on" + type]) {
      			handlers[0] = element["on" + type];
    		}
  		}
		handlers[handler.__id__] = handler;
		element["on" + type] = DOMEvent.handleEvent;
		return new DOMEventHandle(element, type, handler);
	},
	
	modifyHandlerExceptions : function (element, type, handler) {
		var newHandler;
		if ((type == "mouseout" || type == "mouseover") && element.nodeName == 'DIV') {
			newHandler=function (eventObject) {
				var relatedTarget= (eventObject.relatedTarget) ? eventObject.relatedTarget : eventObject.toElement;
				while (relatedTarget !==null && relatedTarget !== element && relatedTarget.nodeName != 'BODY') {
					relatedTarget= relatedTarget.parentNode;
				}
				if (relatedTarget !== element) {
					handler(eventObject);
				}
			}
			return newHandler;
		}
		
		//if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        //window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
//window.onmousewheel = document.onmousewheel = wheel;
		return false;
	},
	
	removeListener: function (domEventHandleObj) {
		var element,type,handler;
		element=domEventHandleObj.element;
		type=domEventHandleObj.type;
		handler=domEventHandleObj.handler;
		if (element.events && element.events[type]) {
   			delete element.events[type][handler.__id__];
  		}
	},
	
	preventDefault: function (eventObj) {
		if (eventObj.preventDefault) {
			eventObj.preventDefault();
		} else {
			eventObj.returnValue=false;
		}
	},
	
	stopPropagation: function (eventObj) {
		if (eventObj.stopPropagation) {
			eventObj.stopPropagation();
		} else {
			eventObj.cancelBubble=true;
		}
	},
	
	// private
	
	currentId: 1,
	
	handleEvent: function (event) {
  		var handlers;
		event = event || window.event;
  		handlers = this.events[event.type];
  		for (var i in handlers) {
    		this.__handleEvent = handlers[i];
    		this.__handleEvent(event);
  		}
		this.__handleEvent=null;
	}
};


JSON={
	serialize: function (JSONObject) {
		var elementArray=new Array();
		var resultString;			
		var objectTypeIsArray=false;
		if (JSONObject.constructor==Array) {
			objectTypeIsArray=true;
			for (var i=0; i<JSONObject.length; i++) {
				if (typeof JSONObject[i] == "object") {
					elementArray.push(JSON.serialize(JSONObject[i]));
				} else if (typeof JSONObject[i] == "string") {
					elementArray.push('"'+encodeURIComponent(JSONObject[i])+'"');
				} else {
					elementArray.push(JSONObject[i]);
				}
			}
		} else if (JSONObject.constructor==Object) {
			for (var property in JSONObject) {
				if (typeof JSONObject[property] == "object") {
					elementArray.push(property+':'+JSON.serialize(JSONObject[property]));
				} else if (typeof JSONObject[property] == "string") {
					elementArray.push(property+':'+'"'+encodeURIComponent(JSONObject[property])+'"');
				} else {
					elementArray.push(property+':'+JSONObject[property]);
				}
			}
		} else 	{
			return encodeURIComponent(JSONObject);
		}
		resultString=elementArray.join(",");
		if (objectTypeIsArray) {
			return "["+resultString+"]";
		} else {
			return "{"+resultString+"}";
		}
	},
	
	unserialize: function (JSONString) {
		var JSONObject;
		try {
			eval("JSONObject="+JSONString);
		} catch (e) {
			JSONObject=new Object();
		};
		return JSON.urlDecodeJSONObject(JSONObject);
	},
	
	urlDecodeJSONObject: function (JSONObject) {
		var decodedObject;
		if (JSONObject===null) {
			decodedObject=null;
		} else 	if (JSONObject.constructor==Array) {
			decodedObject=new Array();
			for (var i=0; i<JSONObject.length; i++) {
				if (typeof JSONObject[i] == "object") {
					decodedObject.push(JSON.urlDecodeJSONObject(JSONObject[i]));
				} else if (typeof JSONObject[i] == "string") {
					decodedObject.push(decodeURIComponent(JSONObject[i]));
				} else {
					decodedObject.push(JSONObject[i]);
				}
			}
		} else if (JSONObject.constructor==Object) {
			decodedObject=new Object();
			for (var property in JSONObject) {
				if (typeof JSONObject[property] == "object") {
					decodedObject[property]=JSON.urlDecodeJSONObject(JSONObject[property]);
				} else if (typeof JSONObject[property] == "string") {
					decodedObject[property]=decodeURIComponent(JSONObject[property]);
				} else {
					decodedObject[property]=JSONObject[property];
				}
			}
		} else 	{
			decodedObject=decodeURIComponent(JSONObject);
		}
		return decodedObject;
	}
};


Ajax={ 
	getXMLHttpRequest : function () {
	
		if ((typeof XMLHttpRequest) == "undefined") {
			XMLHttpRequest=function() {
				return new ActiveXObject(navigator.userAgent.indexOf("MSIE 5") >= 0 ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
			}
		} 	
		return (new XMLHttpRequest());
	},
	
	isSuccess : function (xmlHttpRequestObj) {
		try {
			return (!xmlHttpRequestObj.status && location.protocol=="file:") || (xmlHttpRequestObj.status >=200 && xmlHttpRequestObj.status < 300) || xmlHttpRequestObj.status==304 || (navigator.userAgent.indexOf("Safari") >= 0 && typeof xmlHttpRequestObj.status == "undefined");
		} catch(e){};
		return false;		
	},
	
	/* dataType is string, values: xml, html, json */
	
	getResponseData : function (xmlHttpRequestObj,dataType) {
		var ct=xmlHttpRequestObj.getResponseHeader("content-type");
		var xmlData= !dataType && ct && ct.indexOf("xml")>=0;
		var data= (dataType == "xml" || xmlData)? xmlHttpRequestObj.responseXML: xmlHttpRequestObj.responseText;
		if (dataType=="json") {
			data=JSON.unserialize(data);
		}
		return data;
	}
}

//////////////////////////
// Interface Observable //
//////////////////////////

Observable = {
	addListener : function(listenerObj) {
		if (typeof this.listeners == 'undefined') {
			this.listeners=[];
		}
		for (var i=0; i<this.listeners.length; i++) {
			if (this.listeners[i]==listenerObj) return;
		}
		this.listeners[this.listeners.length]=listenerObj;
	},

	removeListener : function(listenerObj) {
		for (var i=0; i<this.listeners.length; i++) {
			if (this.listeners[i]==listenerObj) {
				this.listeners.splice(i,1);
				return;
			}
		}
	},
	
	notifyListeners : function (eventName,eventObj) {
		if (typeof this.listeners == 'undefined') return;
		for (var i=0; i< this.listeners.length; i++) {
			if (typeof this.listeners[i][eventName]!="undefined") {
				this.listeners[i][eventName](eventObj);
			}
		}
	}
};


/////////////////////
// Class SlideShow //
/////////////////////

function SlideShow(imagesUrlArray, containerElement, slideDurationInSec, numOfTransitionIterations, numOfTransitionMixIterations) {
	this.container=containerElement;
	this.imagesUrlArray=imagesUrlArray;
	this.numOfImagesPreloaded=1;
	this.preloader=new ImagePreloader(this.imagesUrlArray.slice(1));
	this.currentSlide=1;
	this.slideDuration=Math.round(slideDurationInSec*1000);
	this.numOfTransitionIterations=numOfTransitionIterations;
	this.playInterval=null;
	this.foregroundSlide=document.createElement("IMG");
	this.backgroundSlide=document.createElement("IMG");
	this.fadeOutAnimation=null;
	this.fadeInAnimation=null;
	this.slideShowIsPlaying=false;
	this.numOfStartFadeInIteration=numOfTransitionIterations-numOfTransitionMixIterations;
	if (this.numOfStartFadeInIteration<1) {
		this.numOfStartFadeInIteration=1;
	}
	if (this.numOfStartFadeInIteration>=this.numOfTransitionIterations) {
		this.numOfStartFadeInIteration=this.numOfTransitionIterations-1;
	}
	this.preloader.addListener(this);
	this.init();
}

SlideShow.prototype.init=function() {
	var obj=this;
	DHTMLApi.CSS.setProperties(this.container, {position:"relative", overflow:"hidden"});
	this.container.appendChild(this.foregroundSlide);
	this.container.appendChild(this.backgroundSlide);
	DHTMLApi.CSS.setProperties(this.foregroundSlide, {position:"absolute", zIndex:2});
	DHTMLApi.CSS.setProperties(this.backgroundSlide, {position:"absolute", zIndex:1});
	DHTMLApi.Visibility.hide(this.foregroundSlide);
	DHTMLApi.Visibility.hide(this.backgroundSlide);
	this.displaySlide(this.foregroundSlide,this.currentSlide, 100);
}

SlideShow.prototype.displaySlide=function(slide, slideNum, opacity) {
	var obj=this;
	var img=new Image();
	img.onload=function () {
		DHTMLApi.Visibility.show(slide);
		slide.setAttribute("src",obj.imagesUrlArray[slideNum-1]);
		obj.setOpacity(slide,1);
		obj.centerSlide(slide,this.width,this.height);
		obj.setOpacity(slide,opacity);
	}
	img.src=this.imagesUrlArray[slideNum-1];
}

SlideShow.prototype.centerSlide=function (slide,slideWidth,slideHeight) {
	var posX,posY;
	posX=Math.round((DHTMLApi.Size.getElementWidth(this.container)-slideWidth)/2);
	posY=Math.round((DHTMLApi.Size.getElementHeight(this.container)-slideHeight)/2);
	DHTMLApi.CSS.setProperties(slide, {position:"absolute", left: posX+"px", top: posY+"px"});
}

SlideShow.prototype.setOpacity=function(slide,opacity) {
	DHTMLApi.Visibility.setOpacity(slide,opacity);
}

SlideShow.prototype.display=function(slideNum) {
	this.stop();
	this.currentSlide=slideNum;
	this.displaySlide(this.foregroundSlide, this.currentSlide,100);
}

SlideShow.prototype.displayNextSlide=function() {
	this.stop();
	this.currentSlide=this.getNextSlide();
	this.displaySlide(this.foregroundSlide, this.currentSlide,100);
}

SlideShow.prototype.displayPreviousSlide=function() {
	this.stop();
	this.currentSlide=this.getPreviousSlide();
	this.displaySlide(this.foregroundSlide, this.currentSlide,100);
}

SlideShow.prototype.getNextSlide=function() {
	if (this.currentSlide==this.imagesUrlArray.length) {
		return 1;
	} else {
		return this.currentSlide+1;
	}
}

SlideShow.prototype.getPreviousSlide=function() {
	if (this.currentSlide==1) {
		return this.imagesUrlArray.length;
	} else {
		return this.currentSlide-1;
	}
}

SlideShow.prototype.play=function () {
	var obj=this;
	if (this.slideShowIsPlaying) return;
	this.preloader.start();
	this.slideShowIsPlaying=true;
	this.playInterval=window.setInterval(function () {obj.playTransition();}, this.slideDuration);
}

SlideShow.prototype.playTransition=function() {
	var fadeOutListener, fadeInListener, fadeOutChannel, fadeInChannel;
	if (this.currentSlide>=this.numOfImagesPreloaded && this.numOfImagesPreloaded!=this.imagesUrlArray.length) return;
	var obj=this;
	this.fadeInAnimation=null;
	fadeOutListener=new Object();
	fadeOutListener.onAnimationEnd=function () {
		obj.fadeOutAnimation.removeListener(this);
	}
	fadeOutListener.onAnimationStart=function() {
	}
	
	fadeOutListener.onAnimationStep=function (eventObj) {
		if (eventObj==obj.numOfStartFadeInIteration) {
			obj.currentSlide=obj.getNextSlide();
			obj.displaySlide(obj.foregroundSlide, obj.currentSlide, 1);
			obj.fadeInAnimation=new Animation.Fade(obj.foregroundSlide, 1);
			obj.fadeInAnimation.setFade(100,obj.numOfTransitionIterations);
		}
	}
	
	this.displaySlide(this.backgroundSlide,this.currentSlide,100);
	this.fadeOutAnimation=new Animation.Fade(this.backgroundSlide, 100);
	this.fadeOutAnimation.addListener(fadeOutListener);
	this.fadeOutAnimation.setFade(0,this.numOfTransitionIterations);
}

SlideShow.prototype.stop=function() {
	this.preloader.stop();
	if (this.fadeOutAnimation!=null) this.fadeOutAnimation.stop();
	if (this.fadeInAnimation!=null) this.fadeInAnimation.stop();
	this.slideShowIsPlaying=false;
	DHTMLApi.Visibility.hide(this.backgroundSlide);
	this.displaySlide(this.foregroundSlide, this.currentSlide, 100);
	
	window.clearInterval(this.playInterval);
}

SlideShow.prototype.onImageLoad=function (eventObject) {
	this.numOfImagesPreloaded++;
}

//////////////////////////
// Class ImagePreloader //
//////////////////////////

/* broadcasts
	onImageLoad - event Object - img url string
	onAllImagesLoad + event Object - array of imgs url string
*/

function ImagePreloader(imgUrlArray) {
	this.imgUrlArray=imgUrlArray;
	this.imgPreloadingIndex=0;
	this.isPreloading=false;
	this.preloadInterval=null;
	this.imageIsPreloaded=false;
}

ImagePreloader.prototype=implementsInterface(Observable);

ImagePreloader.prototype.preload=function() {
	
	var obj=this;
	if (this.imgPreloadingIndex>=this.imgUrlArray.length) return; 
	this.preloadInterval=window.setInterval(function () {
		if (obj.imageIsPreloaded===false && obj.isPreloading==false) {
			obj.preloadImage(obj.imgPreloadingIndex);
			return;
		}
		if (obj.imgPreloadingIndex==(obj.imgUrlArray.length-1)) {
			window.clearInterval(obj.preloadInterval);
		} else {
			if (obj.imageIsPreloaded===true) {
				obj.imgPreloadingIndex++;
				obj.preloadImage(obj.imgPreloadingIndex);
			}
		}
													  
	}, 150);	
}

ImagePreloader.prototype.preloadImage=function (imageNum) {
	var obj=this;
	this.isPreloading=true;
	var img=new Image();
	this.imageIsPreloaded=false;
	img.onload=img.onerror=function () {
		obj.notifyListeners("onImageLoad",obj.imgUrlArray[obj.imgPreloadingIndex]);
		obj.imageIsPreloaded=true;
		if ((obj.imgUrlArray.length-1)==obj.imgPreloadingIndex) {
			obj.notifyListeners("onAllImagesLoad",obj.imgUrlArray);
		}
	}
	img.src=this.imgUrlArray[imageNum];
}

ImagePreloader.prototype.start=function () {
	this.preload();
}

ImagePreloader.prototype.stop=function () {
	this.isPreloading=false;
	this.imageIsPreloaded=false;
	if (this.preloadInterval!==null) {
		window.clearInterval(this.preloadInterval);
		this.preloadInterval=null;
	}
	return this.imgUrlArray.slice(this.imgPreloadingIndex+1);
}

///////////////////////
// Package Animation //
///////////////////////

Animation= new Object();

Animation.FRAME_RATE=50; // miliseconds

//////////////////////////
// Class Animation.Fade //
//////////////////////////

Animation.Fade=function (fadeObject, currentOpacityPercentage) {
	this.fadeObject=fadeObject;
	this.currentOpacityPercentage=currentOpacityPercentage;
	this.interval=null;
	this.targetOpacityPercentage=null;
	this.currentAnimationStep=null;
	this.numOfAnimationSteps=null;
	DHTMLApi.Visibility.setOpacity(this.fadeObject,Math.round(this.currentOpacityPercentage));
}

Animation.Fade.prototype=implementsInterface(Observable);

Animation.Fade.prototype.setFade=function (targetOpacityPercentage, numOfSteps) {
	this.stop();
	var animationObject=this;
	this.targetOpacityPercentage=targetOpacityPercentage;
	this.opacityStep=1.0*(targetOpacityPercentage-this.currentOpacityPercentage)/numOfSteps;
	this.numOfAnimationSteps=numOfSteps;
	this.currentAnimationStep=0;
	this.notifyListeners("onAnimationStart",null);
	this.animate();
	this.interval=window.setInterval(function() {animationObject.animate()},Animation.FRAME_RATE);
}

Animation.Fade.prototype.animate=function () {
	if (this.currentAnimationStep<this.numOfAnimationSteps) {
		this.currentOpacityPercentage+=this.opacityStep;
		DHTMLApi.Visibility.setOpacity(this.fadeObject,Math.round(this.currentOpacityPercentage));
		this.notifyListeners("onAnimationStep",this.currentAnimationStep);
		++this.currentAnimationStep;
		return this.numOfAnimationStep;
	} else {
		this.currentOpacityPercentage=this.targetOpacityPercentage;
		DHTMLApi.Visibility.setOpacity(this.fadeObject,Math.round(this.currentOpacityPercentage));
		this.notifyListeners("onAnimationStep",this.currentAnimationStep);
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
		this.numOfAnimationStep=null;
		return false;
	}
}

Animation.Fade.prototype.stop=function() {
	if (this.interval!==null) {
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
	}
}

/////////////////////////////////
// Class Animation.SmoothHMove //
/////////////////////////////////

Animation.SmoothHMove=function(movingObject, relativeToObject) {
	this.movingObject=movingObject;
	this.relativeToObject=relativeToObject;
	this.currentXPos=DHTMLApi.Position.getXPosInElement(movingObject,relativeToObject);
	this.targetXPos=null;
	this.interval=null;
	this.numOfAnimationStep=null;
}

Animation.SmoothHMove.prototype=implementsInterface(Observable);

Animation.SmoothHMove.prototype.setPosition=function (targetPosition) {
	if (this.interval!==null) {
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
	}
	var animationObject=this;
	this.targetXPos=targetPosition;
	this.numOfAnimationStep=0;
	this.notifyListeners("onAnimationStart",null);
	this.animate();
	this.interval=window.setInterval(function() {animationObject.animate()},Animation.FRAME_RATE);
}

Animation.SmoothHMove.prototype.animate=function () {
	var stepDistance=(this.targetXPos-this.currentXPos)/3;
	if (Math.abs(stepDistance)>0.3) {
		this.currentXPos+=stepDistance;
		DHTMLApi.Position.setXPos(this.movingObject, this.currentXPos, this.relativeToObject);
		++this.numOfAnimationStep;
		this.notifyListeners("onAnimationStep",this.numOfAnimationSteps);
		return this.numOfAnimationStep;
	} else {
		this.currentXPos=this.targetXPos;
		DHTMLApi.Position.setXPos(this.movingObject, this.currentXPos, this.relativeToObject);
		this.notifyListeners("onAnimationStep",++this.numOfAnimationSteps);
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
		this.numOfAnimationStep=null;
		return false;
	}
}

Animation.SmoothHMove.prototype.getAnimationStep=function () {
	return this.numOfAnimationStep;
}


///////////////////////////
// class SlidesPreloader //
///////////////////////////

/* 
data= [{slides : [string,string]},]
*/

// broadcasts onImageLoad(fileName)

function SlidesPreloader(data) {
	this.firstSlidesCue=[];
	this.slideSetsCue=[];
	this.preloader=null;
	this.init(data);
	this.startPreloadFirstSlides();
}

SlidesPreloader.prototype=implementsInterface(Observable);

SlidesPreloader.prototype.init=function(data) {
	for (var i=0; i<data.length; i++) {
		this.firstSlidesCue.push(data[i].slides[0]);
		this.slideSetsCue.push(data[i].slides);
	}
}

SlidesPreloader.prototype.startPreloadFirstSlides=function () {
	if (this.firstSlidesCue.length==0) return;
	if (this.preloader != null && this.preloader.isPreloading) this.preloader.stop();
	this.preloader=new ImagePreloader(this.firstSlidesCue);
	this.preloader.addListener(this);
	this.preloader.start();
}

SlidesPreloader.prototype.startPreloadSlideSet=function (slideSetNum) {
	if (this.slideSetsCue[slideSetNum].length==0) return;
	if (this.preloader != null && this.preloader.isPreloading) this.preloader.stop();
	this.preloader=new ImagePreloader(this.slideSetsCue[slideSetNum]);
	this.preloader.addListener(this);
	this.preloader.start();
}

SlidesPreloader.prototype.startPreloadSlide=function (slideSetNum,slideNum) {
	var preloadsLeft;
	var slideCue=[];
	if (slideNum==0) {
		if (this.isInArray(this.firstSlidesCue,this.slideSetsCue[slideSetNum][slideNum])===false) return;
	} else {
		if (this.isInArray(this.slideSetsCue[slideSetNum],this.slideSetsCue[slideSetNum][slideNum])===false) return;
	}
	if (this.preloader != null && this.preloader.isPreloading) this.preloader.stop();
	
	slideCue.push(this.slideSetsCue[slideSetNum][slideNum]);
	this.preloader.removeListener(this);
	this.preloader=new ImagePreloader(slideCue);
	this.preloader.addListener(this);
	this.preloader.start();
}

SlidesPreloader.prototype.isLoaded=function (imageFile) {
	if (this.isInArray(this.firstSlidesCue,imageFile)) return false;
	for (var i=0; i<this.slideSetsCue.length; i++) {
		if (this.isInArray(this.slideSetsCue[i],imageFile)) return false;
	}
	return true;
}

SlidesPreloader.prototype.onImageLoad=function (imageFile) {
	this.firstSlidesCue=this.removeFromArray(this.firstSlidesCue,imageFile);
	for (var i=0; i<this.slideSetsCue.length; i++) {
		this.slideSetsCue[i]=this.removeFromArray(this.slideSetsCue[i],imageFile);
	}
	this.notifyListeners("onImageLoad",imageFile);
}

SlidesPreloader.prototype.onAllImagesLoad=function () {
	if (this.firstSlidesCue.length!=0) {
		this.startPreloadFirstSlides();
	}
}

SlidesPreloader.prototype.removeFromArray=function (array,element) {
	var index=null;
	var newArray=[];
	for (var i=0; i<array.length; i++) {
		if (array[i]==element) {
			index=i;
			break;
		}
	}
	if (index!==null) {
		newArray=array.slice(0,index);
		newArray=newArray.concat(array.slice(index+1));
		return newArray;
	} else {
		return array;
	}
}

SlidesPreloader.prototype.isInArray=function (array,element) {
	for (var i=0; i<array.length; i++) {
		if (array[i]==element) return true;
	}
	return false;
}

//////////////////////////
// class SlideDisplayer //
//////////////////////////

/* 
elements= {imageContainer: element, prevButton: element, nextButton: element}
data= [{slides : [string,string], infoDivElement: element},]
parameters= {numOfTransitionSteps: int}
*/

/*
function SlideDisplayer(elements, data, parameters) {
	this.imageContainer=elements.imageContainer;
	this.prevButton=elements.prevButton;
	this.nextButton=elements.nextButton;
	this.data=data;
	this.numOfTransitionSteps=parameters.numOfTransitionSteps;
	this.numOfSets=data.length;
	this.currentSlide=null;
	this.fadeAnimation=null;
	this.preloader=new SlidesPreloader(data);
	this.status=SlideDisplayer.STATUS_IDLE;
	this.preloadingOnDemandFileName=null;
	this.currentSlideSet=0;
	this.init();
	this.displaySlideSet(this.currentSlideSet);
}

SlideDisplayer.prototype=implementsInterface(Observable);

SlideDisplayer.STATUS_IDLE=1;
SlideDisplayer.STATUS_PRELOADING=2;
SlideDisplayer.STATUS_FADE_OUT=3;
SlideDisplayer.STATUS_FADE_IN=4;

SlideDisplayer.prototype.displaySlide=function(slideFile,opacity) {
	var obj=this;
	var img=new Image();
	img.onload=function () {
		obj.imageContainer.innerHTML="";
		obj.currentSlide=document.createElement("IMG");
		DHTMLApi.Visibility.show(obj.currentSlide);
		obj.currentSlide.setAttribute("src",slideFile);
		obj.imageContainer.appendChild(obj.currentSlide);
		DHTMLApi.Visibility.setOpacity(obj.currentSlide,opacity);
		DHTMLApi.CSS.setProperties(obj.currentSlide, {position:"absolute", left: "0px", top: "0px"});
	}
	img.src=slideFile;
}

SlideDisplayer.prototype.displaySlideSet=function (slideSetNum) {
	this.displaySlide(this.data[slideSetNum].slides[0],100);
	this.displayInfoText(slideSetNum);
	this.currentSlideSet=slideSetNum;
	this.setPrevNextButtonsDisplay();
}

SlideDisplayer.prototype.init=function () {
	var obj=this;
	DOMEvent.addDomListener(this.nextButton,"click",function () {
		if (obj.currentSlideSet<(obj.numOfSets-1)) {
			//obj.displaySlideSet(obj.currentSlideSet+1);
			obj.notifyListeners("onSlideSetChange",(obj.currentSlideSet+1));
			obj.onSlideSetChange(obj.currentSlideSet+1);
		}
	});
	DOMEvent.addDomListener(this.prevButton,"click",function () {
		if (obj.currentSlideSet!=0) {
			//obj.displaySlideSet(obj.currentSlideSet-1);
			obj.notifyListeners("onSlideSetChange",(obj.currentSlideSet-1));
			obj.onSlideSetChange(obj.currentSlideSet-1);
		}
	});
}

SlideDisplayer.prototype.setPrevNextButtonsDisplay=function () {
	if (this.currentSlideSet==0) {
		DHTMLApi.Visibility.hide(this.prevButton);
	} else {
		DHTMLApi.Visibility.show(this.prevButton);
	}
	if (this.currentSlideSet==(this.numOfSets-1)) {
		DHTMLApi.Visibility.hide(this.nextButton);
	} else {
		DHTMLApi.Visibility.show(this.nextButton);
	}
}

SlideDisplayer.prototype.displayInfoText=function (slideSetNum) {
	//DHTMLApi.Visibility.hide(this.data[this.currentSlideSet].infoDivElement);
	DHTMLApi.Visibility.show(this.data[slideSetNum].infoDivElement);
}

SlideDisplayer.prototype.hideInfoText=function (slideSetNum) {
	DHTMLApi.Visibility.hide(this.data[this.currentSlideSet].infoDivElement);
}

SlideDisplayer.prototype.onSlideSetChange=function (slideSetNum) {
	var obj=this;
	var fadeOutListenerObj={};
	var fadeInListenerObject={};
	function __local__fadeIn() {
		obj.currentSlide=null
			obj.displaySlide(obj.data[obj.currentSlideSet].slides[0],1);
			var generateImgInt=setInterval(function () {
				if (obj.currentSlide!==null) {
					obj.fadeAnimation=new Animation.Fade(obj.currentSlide, 1);
					obj.fadeAnimation.setFade(100,obj.numOfTransitionSteps);
					obj.fadeAnimation.addListener(fadeInListenerObject);
					obj.status=SlideDisplayer.STATUS_FADE_IN;
					clearInterval(generateImgInt);
				}
			},50);
	}
	fadeOutListenerObj.onAnimationEnd=function () {
		if (obj.preloader.isLoaded(obj.data[obj.currentSlideSet].slides[0])) {
			__local__fadeIn();
		} else {
			obj.status=SlideDisplayer.STATUS_PRELOADING;
			obj.preloadingOnDemandFileName=obj.data[obj.currentSlideSet].slides[0];
			obj.preloader.startPreloadSlide(obj.currentSlideSet,0);
			var onLoadFileObject={};
			onLoadFileObject.onImageLoad=function (fileName) {
				if (fileName==obj.preloadingOnDemandFileName) {
					__local__fadeIn();
					obj.preloadingOnDemandFileName=null;
					obj.preloader.removeListener(onLoadFileObject);
				} else {
					obj.preloader.startPreloadSlide(obj.currentSlideSet,0);
				}
			};
			obj.preloader.addListener(onLoadFileObject);
		}
	}
	fadeInListenerObject.onAnimationEnd=function () {
		obj.displayInfoText(obj.currentSlideSet);
		obj.status=SlideDisplayer.STATUS_IDLE;
	}
	
	if (this.status==SlideDisplayer.STATUS_IDLE || this.status==SlideDisplayer.STATUS_FADE_IN) {
		obj.hideInfoText();
		if (this.status==SlideDisplayer.STATUS_IDLE) {
			this.fadeAnimation=new Animation.Fade(this.currentSlide, 100);
			this.fadeAnimation.setFade(0, this.numOfTransitionSteps);
		} else {
			var currentStep=this.fadeAnimation.currentAnimationStep;
			var currentOpacity=this.fadeAnimation.currentOpacityPercentage;
			this.fadeAnimation.stop();
			this.fadeAnimation=new Animation.Fade(this.currentSlide, currentOpacity);
			this.fadeAnimation.setFade(0,this.numOfTransitionSteps-currentStep);
		}
		this.fadeAnimation.addListener(fadeOutListenerObj);
		this.status=SlideDisplayer.STATUS_FADE_OUT;
		if (!this.preloader.isLoaded(this.data[slideSetNum].slides[0])) {
			this.preloader.startPreloadSlide(slideSetNum,0);
			this.preloadingOnDemandFileName=this.data[slideSetNum].slides[0];
		}
	}	
	if (this.status==SlideDisplayer.STATUS_FADE_OUT || this.status==SlideDisplayer.STATUS_PRELOADING) {
		obj.hideInfoText();
		if (!this.preloader.isLoaded(this.data[slideSetNum].slides[0])) {
			this.preloadingOnDemandFileName=this.data[slideSetNum].slides[0];
		}
	}
	this.currentSlideSet=slideSetNum;
	this.setPrevNextButtonsDisplay();
}

*/

function SlideDisplayer(elements, data, parameters) {
	this.imageContainer=elements.imageContainer;
	this.prevButton=elements.prevButton;
	this.nextButton=elements.nextButton;
	this.data=data;
	this.numOfTransitionSteps=parameters.numOfTransitionSteps;
	this.numOfSets=data.length;
	this.currentSlide=null;
	this.fadeAnimation=null;
	this.preloader=new SlidesPreloader(data);
	this.status=SlideDisplayer.STATUS_IDLE;
	this.preloadingOnDemandFileName=null;
	this.currentSlideSet=0;
	this.initialized=false;
	this.init();
	this.displaySlideSet(this.currentSlideSet);
}

SlideDisplayer.prototype=implementsInterface(Observable);

SlideDisplayer.STATUS_IDLE=1;
SlideDisplayer.STATUS_PRELOADING=2;
SlideDisplayer.STATUS_FADE_OUT=3;
SlideDisplayer.STATUS_FADE_IN=4;

SlideDisplayer.prototype.displaySlide=function(slideFile,opacity) {
	var obj=this;
	var img=new Image();
	img.onload=function () {
		obj.imageContainer.innerHTML="";
		obj.currentSlide=document.createElement("IMG");
		DHTMLApi.Visibility.show(obj.currentSlide);
		obj.currentSlide.setAttribute("src",slideFile);
		obj.imageContainer.appendChild(obj.currentSlide);
		DHTMLApi.Visibility.setOpacity(obj.currentSlide,opacity);
		DHTMLApi.CSS.setProperties(obj.currentSlide, {position:"absolute", left: "0px", top: "0px"});
	}
	img.src=slideFile;
}

SlideDisplayer.prototype.displaySlideSet=function (slideSetNum) {
	var obj=this;
	var fadeInListenerObject={};
	this.displaySlide(obj.data[obj.currentSlideSet].slides[0],1);
	this.setPrevNextButtonsDisplay();
	var generateImgInt=setInterval(function () {
		if (obj.currentSlide!==null) {
			obj.fadeAnimation=new Animation.Fade(obj.currentSlide, 1);
			obj.fadeAnimation.setFade(100,obj.numOfTransitionSteps);
			obj.fadeAnimation.addListener(fadeInListenerObject);
			obj.status=SlideDisplayer.STATUS_FADE_IN;
			obj.initialized=true;
			clearInterval(generateImgInt);
		}
	},50);
	
	fadeInListenerObject.onAnimationEnd=function () {
		obj.displayInfoText(obj.currentSlideSet);
		obj.status=SlideDisplayer.STATUS_IDLE;
	}
}

SlideDisplayer.prototype.init=function () {
	var obj=this;
	DOMEvent.addDomListener(this.nextButton,"click",function () {
		if (obj.currentSlideSet<(obj.numOfSets-1)) {
			//obj.displaySlideSet(obj.currentSlideSet+1);
			obj.notifyListeners("onSlideSetChange",(obj.currentSlideSet+1));
			obj.onSlideSetChange(obj.currentSlideSet+1);
		}
	});
	DOMEvent.addDomListener(this.prevButton,"click",function () {
		if (obj.currentSlideSet!=0) {
			//obj.displaySlideSet(obj.currentSlideSet-1);
			obj.notifyListeners("onSlideSetChange",(obj.currentSlideSet-1));
			obj.onSlideSetChange(obj.currentSlideSet-1);
		}
	});
}

SlideDisplayer.prototype.setPrevNextButtonsDisplay=function () {
	if (this.currentSlideSet==0) {
		DHTMLApi.Visibility.hide(this.prevButton);
	} else {
		DHTMLApi.Visibility.show(this.prevButton);
	}
	if (this.currentSlideSet==(this.numOfSets-1)) {
		DHTMLApi.Visibility.hide(this.nextButton);
	} else {
		DHTMLApi.Visibility.show(this.nextButton);
	}
}

SlideDisplayer.prototype.displayInfoText=function (slideSetNum) {
	//DHTMLApi.Visibility.hide(this.data[this.currentSlideSet].infoDivElement);
	DHTMLApi.Visibility.show(this.data[slideSetNum].infoDivElement);
}

SlideDisplayer.prototype.hideInfoText=function (slideSetNum) {
	DHTMLApi.Visibility.hide(this.data[this.currentSlideSet].infoDivElement);
}

SlideDisplayer.prototype.onSlideSetChange=function (slideSetNum) {
	var obj=this;
	var fadeOutListenerObj={};
	var fadeInListenerObject={};
	function __local__fadeIn() {
		obj.currentSlide=null
			obj.displaySlide(obj.data[obj.currentSlideSet].slides[0],1);
			var generateImgInt=setInterval(function () {
				if (obj.currentSlide!==null) {
					obj.fadeAnimation=new Animation.Fade(obj.currentSlide, 1);
					obj.fadeAnimation.setFade(100,obj.numOfTransitionSteps);
					obj.fadeAnimation.addListener(fadeInListenerObject);
					obj.status=SlideDisplayer.STATUS_FADE_IN;
					clearInterval(generateImgInt);
				}
			},50);
	}
	fadeOutListenerObj.onAnimationEnd=function () {
		if (obj.preloader.isLoaded(obj.data[obj.currentSlideSet].slides[0])) {
			__local__fadeIn();
		} else {
			obj.status=SlideDisplayer.STATUS_PRELOADING;
			obj.preloadingOnDemandFileName=obj.data[obj.currentSlideSet].slides[0];
			obj.preloader.startPreloadSlide(obj.currentSlideSet,0);
			var onLoadFileObject={};
			onLoadFileObject.onImageLoad=function (fileName) {
				if (fileName==obj.preloadingOnDemandFileName) {
					__local__fadeIn();
					obj.preloadingOnDemandFileName=null;
					obj.preloader.removeListener(onLoadFileObject);
				} else {
					obj.preloader.startPreloadSlide(obj.currentSlideSet,0);
				}
			};
			obj.preloader.addListener(onLoadFileObject);
		}
	}
	fadeInListenerObject.onAnimationEnd=function () {
		obj.displayInfoText(obj.currentSlideSet);
		obj.status=SlideDisplayer.STATUS_IDLE;
	}
	
	if (this.initialized) {
		if (this.status==SlideDisplayer.STATUS_IDLE || this.status==SlideDisplayer.STATUS_FADE_IN) {
			obj.hideInfoText();
			if (this.status==SlideDisplayer.STATUS_IDLE) {
				this.fadeAnimation=new Animation.Fade(this.currentSlide, 100);
				this.fadeAnimation.setFade(0, this.numOfTransitionSteps);
			} else {
				var currentStep=this.fadeAnimation.currentAnimationStep;
				var currentOpacity=this.fadeAnimation.currentOpacityPercentage;
				this.fadeAnimation.stop();
				this.fadeAnimation=new Animation.Fade(this.currentSlide, currentOpacity);
				this.fadeAnimation.setFade(0,this.numOfTransitionSteps-currentStep);
			}
			this.fadeAnimation.addListener(fadeOutListenerObj);
			this.status=SlideDisplayer.STATUS_FADE_OUT;
			if (!this.preloader.isLoaded(this.data[slideSetNum].slides[0])) {
				this.preloader.startPreloadSlide(slideSetNum,0);
				this.preloadingOnDemandFileName=this.data[slideSetNum].slides[0];
			}
		}	
		if (this.status==SlideDisplayer.STATUS_FADE_OUT || this.status==SlideDisplayer.STATUS_PRELOADING) {
			obj.hideInfoText();
			if (!this.preloader.isLoaded(this.data[slideSetNum].slides[0])) {
				this.preloadingOnDemandFileName=this.data[slideSetNum].slides[0];
			}
		}
	}
	this.currentSlideSet=slideSetNum;
	this.setPrevNextButtonsDisplay();
}


/////////////////////////////////
// class SlideSetSelectorSmall //
/////////////////////////////////

/* elements= {content: element, prevButton: element, nextButton: element}
	parameters= {buttonWidth: int, buttonHeight: int, numOfSetsPerScreen: int} */

function SlideSetSelectorSmall(elements, numOfSets, parameters) {
	this.contentElement=elements.content;
	this.prevButton=elements.prevButton;
	this.nextButton=elements.nextButton;
	this.numOfSets=numOfSets;
	this.parameters=parameters;
	this.currentScreen=0;
	this.numOfScreens=Math.ceil(this.numOfSets/this.parameters.numOfSetsPerScreen);
	this.buttons=[];
	this.animation=new Animation.SmoothHMove(this.contentElement, this.contentElement.parentNode);
	this.setPrevNextButtonsDisplay();
	this.build();
	this.init();
}

SlideSetSelectorSmall.prototype=implementsInterface(Observable);

SlideSetSelectorSmall.prototype.build=function () {
	var button;
	for (var i=0; i<this.numOfSets; i++) {
		button=document.createElement("DIV");
		this.contentElement.appendChild(button);
		DHTMLApi.CSS.setProperties(button, {position: "absolute", width: this.parameters.buttonWidth+"px", height: this.parameters.buttonHeight+"px", top: "0px", left: i*this.parameters.buttonWidth+"px", cursor: "pointer"});
		this.buttons.push(button);
	}
	DHTMLApi.CSS.setProperties(this.contentElement, {width: this.parameters.buttonWidth*this.numOfSets+"px"});
}

SlideSetSelectorSmall.prototype.init=function () {
	var obj=this;
	for (var i=0; i<this.numOfSets; i++) {
		(function () {
			var j=i;
			DOMEvent.addDomListener(obj.buttons[j],"click",function () {
				obj.notifyListeners("onSlideSetChange",j);
			});
		})();
	}
	DOMEvent.addDomListener(this.nextButton,"click",function () {
		if (obj.currentScreen<(obj.numOfScreens-1)) {
			obj.setPosition(++obj.currentScreen);
		}
	});
	DOMEvent.addDomListener(this.prevButton,"click",function () {
		if (obj.currentScreen!=0) {
			obj.setPosition(--obj.currentScreen);
		}
	});
}

SlideSetSelectorSmall.prototype.setPosition=function (screenNum) {
	this.animation.setPosition(-1*screenNum*this.parameters.buttonWidth*this.parameters.numOfSetsPerScreen);
	this.setPrevNextButtonsDisplay();
}

SlideSetSelectorSmall.prototype.setPrevNextButtonsDisplay=function () {
	if (this.currentScreen==0) {
		DHTMLApi.Visibility.hide(this.prevButton);
	} else {
		DHTMLApi.Visibility.show(this.prevButton);
	}
	if (this.currentScreen==(this.numOfScreens-1)) {
		DHTMLApi.Visibility.hide(this.nextButton);
	} else {
		DHTMLApi.Visibility.show(this.nextButton);
	}
}

SlideSetSelectorSmall.prototype.onSlideSetChange=function (slideSetNum) {
	this.currentScreen=Math.floor(slideSetNum/this.parameters.numOfSetsPerScreen);
	this.setPosition(this.currentScreen);
}

