function oGallery(aImages) {

	if (! aImages) { aImages=images };
	this.init = function() {
		// The Array 'aImages' is defined by the SSI inclusion of /cgi/imglist.pl within the main html page for this site.
		this.array_end = aImages.length-1
		this.cache_array = new Array()
		for (var cachepos=0;cachepos<=this.array_end;cachepos++)
       			{
		       	this.cache_array[cachepos]=new Image()
			this.cache_array[cachepos].src="css/img/blank.gif"
			this.cache_array[cachepos].title=image_descriptions[cachepos]
		        }
		this.p_prev = this.array_end
		this.p_current = 0
		this.p_next = 1
	
		//We initialise a TimerID for the slideshow function.
		this.tid
	
	        this.cache_check()
		//this.cache_array[this.p_prev].src = "../pictures/"+aImages[this.p_prev]
		//this.cache_array[this.p_current].src = "../pictures/"+aImages[this.p_current]
		//this.cache_array[this.p_next].src = "../pictures/"+aImages[this.p_next]
		this.changeImage()
				}
	
	this.random = function() {
		var rand = Math.random()*this.array_end
		if ( rand == this.p_current || rand == this.p_prev ) { this.random() }
		return Math.round(rand)
				 }

	this.slideshow = function() 	{
		if (!document.getElementById('img_slideshow').checked) { clearInterval(this.tid)}
		else { this.tid = setInterval('gallery.next()',3000) }
					}

	this.cache_check = function()	{
		var img_pointers = new Array("this.p_prev","this.p_current","this.p_next")
		for (var i=0;i<img_pointers.length;i++)
			{
		var p_image = eval(img_pointers[i])
		// alert(this.cache_array[p_image].src)
		if ( !this.cache_array[p_image].src.match(/aImages[p_image]/) )
		//if ( this.cache_array[p_image].src == "http://"+location.host+"/DuMmY")
				{
				this.cache_array[p_image].src = images[p_image]
				//this.cache_array[p_image].src = "../pictures/"+images[p_image]
				}
		// alert("2nd"+this.cache_array[p_image].src)
			}
					}
	this.set_description = function()	{
		if (  this.cache_array[this.p_current].title == "nodesc" )
			{
			document.getElementById('img_description').innerHTML = this.cache_array[this.p_current].src
			}
		else	{
			document.getElementById('img_description').innerHTML = this.cache_array[this.p_current].title
			}
		if ( browser.isNS6up == true || browser.isMozilla == true ) { document.getElementById('div_img_description').style.background = "#000000" }
						}

	this.changeImage = function()	{
		this.cache_check()
		document.getElementById('currentImage').src = this.cache_array[this.p_current].src
		document.getElementById('previousImage').src = this.cache_array[this.p_prev].src
		document.getElementById('nextImage').src = this.cache_array[this.p_next].src
		document.getElementById('img_progress').value="Picture "+(this.p_current+1)+" of "+aImages.length
		this.set_description()
					}

	this.next = function()	{
		if ( document.getElementById('nextImage').complete == false && document.getElementById('currentImage').complete == false ) {alert("Please Wait for the Current image to finish loading."); return false }
		if ( arguments.length == 0 ) { var iterations = 1 }
		else { var iterations = arguments[0] ; }
		for (var i=0;i<iterations;i++)
		{
		this.p_prev = this.p_current
		this.p_current = this.p_next

		if ( this.p_next == this.array_end && !document.getElementById('img_random').checked)
			{
			this.p_next = 0
			}
		else	{
			this.p_next++
			}
		if (document.getElementById('img_random').checked) { this.p_next = eval(this.random()) }
		}
		this.changeImage()
				}
	
	this.prev = function()  {
		if ( arguments.length == 0 ) { var iterations = 1 }
		else { var iterations = arguments[0] ; }
		for (var i=0;i<iterations;i++)
		{
		this.p_next = this.p_current
		this.p_current = this.p_prev
		if ( this.p_prev == 0 )
			{
			this.p_prev = this.array_end
			}
		else	{
			this.p_prev--
			}
		}
		this.changeImage()
				}

	

//End of the Gallery Object
		}

var gallery = new oGallery(images)

//alert(gallery.cache_array[0].title)
// gallery.init()
// alert(gallery.array_end)
