function ImgObj(url,cap){
	this.url = url;
	this.cap = cap;
	
	function setUrl(url){
		this.url = url;
	}this.setUrl = setUrl;
	
	function getUrl(){
		return(this.url);
	}this.getUrl = getUrl;
	
	function setCaption(cap){
		this.cap = cap;
	}this.setCaption = setCaption;
	
	function getCaption(cap){
		return(this.cap);
	}this.getCaption = getCaption;
}

function RotoImgList(){
	this.images = new Array();
	this.currInd = 0;
	
	function addImg(url,cap){
		this.images[this.images.length] = new ImgObj(url,cap);
	}this.addImg = addImg;

	function getNextInd(){
		return( (this.currInd + 1)%this.images.length );
	}
	this.getNextInd = getNextInd;

	function getPrevInd(){
		return( (this.currInd - 1 + this.images.length)%this.images.length );
	}
	this.getPrevInd = getPrevInd;

	function getCurrImg(){
		return(this.images[this.currInd]);
	}
	this.getCurrImg = getCurrImg;

	function gotoNextImg(){
		this.currInd = this.getNextInd();
		return(this.images[this.currInd]);
	}
	this.gotoNextImg = gotoNextImg;

	function gotoPrevImg(){
		this.currInd = this.getPrevInd();
		return(this.images[this.currInd]);
	}
	this.gotoPrevImg = gotoPrevImg;
	
	function getNextImgUrl(){
		//alert(this.getNextInd());
		var img = this.images[this.getNextInd()];
		return( img.getUrl() );
	}this.getNextImgUrl = getNextImgUrl;
	
	function cacheNextImg(){
		if (this.images.length){
			var i = new Image();
			i.src = this.getNextImgUrl();
		}
	}this.cacheNextImg = cacheNextImg;
	
	
	function loadNext(elemid){
		if (this.images.length){
			var imgObj;
			elem = document.getElementById(elemid);
			imgObj = this.gotoNextImg();
			//elem.src = imgObj.getUrl();
			elem.style.backgroundImage = 'url('+imgObj.getUrl()+')';
		}
	}this.loadNext = loadNext;
	
	function loadPrev(elemid){
		if (this.images.length){
			var imgObj;
			elem = document.getElementById(elemid);
			imgObj = this.gotoPrevImg();
			//elem.src = imgObj.getUrl();
			elem.style.backgroundImage = 'url('+imgObj.getUrl()+')';
		}
	}this.loadPrev = loadPrev;

	function loadCurr(elemid){
		if (this.images.length){
			var imgObj;
			elem = document.getElementById(elemid);
			imgObj = this.getCurrImg();
			//elem.src = imgObj.getUrl();
			elem.style.backgroundImage = 'url('+imgObj.getUrl()+')';
		}
	}this.loadCurr = loadCurr;

}


function ric_RotoImgList(){
	this.images = new Array();
	this.currInd = 0;
	
	function addImg(url,cap){
		this.images[this.images.length] = new ImgObj(url,cap);
	}this.addImg = addImg;

	function getNextInd(){
		return( (this.currInd + 1)%this.images.length );
	}
	this.getNextInd = getNextInd;

	function getPrevInd(){
		return( (this.currInd - 1 + this.images.length)%this.images.length );
	}
	this.getPrevInd = getPrevInd;

	function getCurrImg(){
		return(this.images[this.currInd]);
	}
	this.getCurrImg = getCurrImg;

	function gotoNextImg(){
		this.currInd = this.getNextInd();
		return(this.images[this.currInd]);
	}
	this.gotoNextImg = gotoNextImg;

	function gotoPrevImg(){
		this.currInd = this.getPrevInd();
		return(this.images[this.currInd]);
	}
	this.gotoPrevImg = gotoPrevImg;
	
	function getNextImgUrl(){
		//alert(this.getNextInd());
		var img = this.images[this.getNextInd()];
		return( img.getUrl() );
	}this.getNextImgUrl = getNextImgUrl;
	
	function cacheNextImg(){
		if (this.images.length){
			var i = new Image();
			i.src = this.getNextImgUrl();
		}
	}this.cacheNextImg = cacheNextImg;
	
	
	function loadNext(elemid){
		//alert("hej");
		if (this.images.length){
			var imgObj;
			elem = document.getElementById(elemid);
			imgObj = this.gotoNextImg();
			//elem.src = imgObj.getUrl();
			changeOpac(0, elem.id);
			elem.style.backgroundImage = 'url('+imgObj.getUrl()+')';
			opacity(elem.id, 0, 100, 300);
		}
	}this.loadNext = loadNext;
	
	function loadPrev(elemid){
		if (this.images.length){
			var imgObj;
			elem = document.getElementById(elemid);
			imgObj = this.gotoPrevImg();
			//elem.src = imgObj.getUrl();
			changeOpac(0, elem.id);
			elem.style.backgroundImage = 'url('+imgObj.getUrl()+')';
			opacity(elem.id, 0, 100, 300);
		}
	}this.loadPrev = loadPrev;

	function loadCurr(elemid){
		if (this.images.length){
			var imgObj;
			elem = document.getElementById(elemid);
			imgObj = this.getCurrImg();
			//elem.src = imgObj.getUrl();
			elem.style.backgroundImage = 'url('+imgObj.getUrl()+')';
		}
	}this.loadCurr = loadCurr;

}
