function SimpleGallery(rootId, optionsObj){
	this.rootEmt = document.getElementById(rootId);
	this.images = this.rootEmt.getElementsByTagName("img");
	this.optionsObj = optionsObj;
	
	this.currentImage = 0;
	
	this.loop = false;
	this.currentDisplay = null;
	this.infoDisplay = null;
	
	
	
	this.showImage = function(imgIdx){
		for(var i = 0; i < this.images.length; i++){
			this.images[i].style.display = "none";
		}
		
		if(this.images.length > imgIdx){
			this.images[imgIdx].style.display = "inline";
		}
		
		this.currentImage = imgIdx;
		
		if(this.currentDisplay != null){
			this.currentDisplay.innerHTML = (this.currentImage + 1) + ' / ' + this.images.length;
		}
		
		var hasAlt = (this.images[imgIdx].alt != null && this.images[imgIdx].alt != 'undefined' && this.images[imgIdx].alt != '' && this.images[imgIdx].alt.indexOf('.gif') < 0 && this.images[imgIdx].alt.indexOf('.jpg') < 0 && this.images[imgIdx].alt.indexOf('.jpeg') < 0) ? true : false;
		
		if(this.infoDisplay != null && hasAlt){
			this.infoDisplay.innerHTML = this.images[imgIdx].alt;
		}
	}
	
	
	
	
	
	this.next = function(){
		if(this.currentImage < (this.images.length - 1)){
			this.showImage(this.currentImage + 1);
		}
		else if(this.loop == true){
			this.showImage(0);
		}
	}
	
	
	
	
	this.prev = function(){
		if(this.currentImage > 0){
			this.showImage(this.currentImage - 1);
		}
		else if(this.loop == true){
			this.showImage((this.images.length - 1));
		}
	}
	
	
	
	
	
	
	this.init = function(){
		if(this.optionsObj != null && this.optionsObj != 'undefined'){
			if(this.optionsObj.loop == true || this.optionsObj.loop == false){
				this.loop = this.optionsObj.loop;
			}
			
			if(this.optionsObj.currentDisplay != null && this.optionsObj.currentDisplay != 'undefined'){
				this.currentDisplay = document.getElementById(this.optionsObj.currentDisplay);
			}
			
			if(this.optionsObj.infoDisplay != null && this.optionsObj.infoDisplay != 'undefined'){
				this.infoDisplay = document.getElementById(this.optionsObj.infoDisplay);
			}
		}
		
		if(this.images.length > 0){
			this.showImage(0);
		}
	}
	
	
	
	
	
	this.init();
}




function resizeWin(winWidth, winHeight){
	window.resizeTo(winWidth, winHeight);
}