	
	// images
	imgs = new Array();
	var currImg = null;
	var imgShown = false;

	window.onload = initialize;
	
	historyChange = function(newLocation, historyData) {
		if (historyData != null){
	        popDiv(historyData[0],historyData[1],historyData[2],historyData[3],true);
        } else {
        	if (imgShown) {
        		hidePic(true);
        	}
        }
      }
	
	function initialize() {
	
		htmlStore = document.getElementById("content").innerHTML;
		showThumbs();
		
        // initialize the DHTML History
        // framework
        dhtmlHistory.initialize();
        
        // subscribe to DHTML history change
        // events
        dhtmlHistory.addListener(historyChange);
        
        if(dhtmlHistory.isInternetExplorer()){
        	var n = document.location.href.indexOf("#");
        	if (n != -1){
	        	var doLoad = document.location.href.substr(n);
	        	historyChange(doLoad, null);
        	} else {
        		historyChange("", null);
        	}
        }

        if (dhtmlHistory.isFirstLoad()) {
        	
        }
    }
    
	

	registerImg = function (theURL, theCap, theUid, theIndex){
		if(imgs[theUid + ""] == undefined){
			imgs[theUid + ""] = new Array();
		}
		if (imgs[theUid + ""][theIndex] == undefined){
			imgs[theUid + ""][theIndex] = new Array(theURL, theCap);
		}
	}
	
	function popDiv(theURL, theCap, theUid, theIndex, historyMode){
			var c = document.getElementById("content");
			c.innerHTML = "";
			
			var nIndex = theIndex + 1;
			if((theIndex + 1) >= imgs[theUid].length){
		  		nIndex = 0;
		  	}
		  	
		  	var nURL = imgs[theUid][nIndex][0];
		  	var nCap = imgs[theUid][nIndex][1];
		  	c.innerHTML = "<div class='centered'><img border='0' src='" + theURL + "'/></div>";
		  	imgShown = true;
		  	
		  	if (historyMode == undefined || historyMode != true){
				var dat = new Array(theURL, theCap, theUid, theIndex);
				dhtmlHistory.add(theUid + "_" +theIndex, dat);
			}
		  }
		  
		  
		  function hidePic(){
			 document.getElementById("content").innerHTML = htmlStore;
		  }
		  
		  
		  function showThumbs(){
		  	document.getElementById("thumbs").style.display = "block";
		  }
		  
		  function hideThumbs(){
		  	document.getElementById("thumbs").style.display = "none";
		  }
