	
	// id's of menu divs
	var menuDivs = new Array();
	
	// images
	var imgs = new Array();
	
//	window.onload = initialize;
	
	
	function initialize() {
        // 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()) {
        	
//        }
    }
    
	function historyChange(newLocation, historyData) {
		if (newLocation != ""){
	        openPage(newLocation.substring(1), historyData, true);
        } else {
        	openPage("index.php?id=" + uid + "&type=1", historyData, true);
        }
      }

	var 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 addMenuDiv(id,pid,cid){
		menuDivs[id] = new Array();
		menuDivs[id]["pid"] = pid;
		menuDivs[id]["cid"] = cid;
	}
	
	function closeMenuDivs(){
		for (var key in menuDivs){
			if (document.getElementById(key) == undefined) continue;
			if(menuDivs[key]["pid"] != ""){
				document.getElementById(key).style.display = "none";
			} else {
				document.getElementById(key).style.display = "block";
			}
		}
	}
	
	function openChildDivs(id){
		for (var key in menuDivs){
			if (document.getElementById(key) == undefined) continue;
			if(menuDivs[key]["pid"] == id){
				document.getElementById(key).style.display = "block";
			}
		}
	}
	
	function openMenuDiv(id){
		closeMenuDivs();
		openParentMenuDiv(id);
		openChildDivs(id);
	}
	
	function openParentMenuDiv(id){
		if (document.getElementById(id) == undefined) return;
		document.getElementById(id).style.display = "block";
		openChildDivs(id);
		if(menuDivs[id]["pid"] != ""){
			openParentMenuDiv(menuDivs[id]["pid"]);
		}
	}
	
	function openPage(url, title, historyMode){	
		openMenuDiv(url);
		hidePicNoRestore();
		var elem = document.getElementById("content");
		document.getElementById("loading").style.display= "block";
		var page_request = false
		if (window.XMLHttpRequest){ // if Mozilla, Safari etc
			page_request = new XMLHttpRequest();
			if (page_request.overrideMimeType) {
                page_request.overrideMimeType('text/xml');
            }
		} else if (window.ActiveXObject){ // if IE
			try {
				page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} catch (e){
				try{
					page_request = new ActiveXObject("Microsoft.XMLHTTP")
				} catch (e){}
			}
		} else return false;
		
		page_request.onreadystatechange=function(){
			loadpage(page_request, url, title, historyMode);
		}
		
		page_request.open('GET', url, true);
		page_request.send(null);

		return false;
	}
	
	function loadpage(page_request, url, title, historyMode){
		var id = "content";
		var elem = document.getElementById(id);
		elem.style.display="none";
		if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
			elem.innerHTML=page_request.responseText;
			elem.style.display="block";
			htmlStore = document.getElementById("content").innerHTML;
			var execs = document.getElementsByName("execMe");
			var s = document.getElementsByTagName("script");
			
			if (historyMode != true){
				dhtmlHistory.add("_"+url, title);
			}
			
			// opera
			for(var i = 0; i < s.length;i++){
				if(s[i].getAttribute("name") == "execMe"){
					eval(s[i].innerHTML);
				}
			}
			
			document.getElementById("loading").style.display= "none";
			elem.style.display="block";
		}
	}
	
	function popDiv(theURL, theCap, theUid, theIndex){
		  	document.getElementById("content").innerHTML = "";
		  	popD.innerHTML = "<table cellpadding='0' cellspacing='0'><tr><td class='img'><a href='javascript:hidePic();'><img border='0' src='" + theURL + "'/></a></td><td class='caption'>"+theCap+"<span id='prevImg'></span><a href='javascript:hidePic();'> x </a><span id='nextImg'></span><br/></td></tr></table>";
		  	if (theIndex > 0){
		  		writePrevNext(theUid, theIndex-1, "prevImg", "&lt;-");
		  	}
		  	
		  	if((theIndex + 1) < imgs[theUid].length){
		  		writePrevNext(theUid, theIndex+1, "nextImg", "-&gt;");
		  	}
		  	
		  	popD.style.display = "block";
		  	scrollD.style.display = "block";
		  }
		  
		  function writePrevNext(theUid, theIndex, direction, theString){
		  	var s = document.getElementById(direction);
		  	var theURL = imgs[theUid][theIndex][0];
		  	var theCap = imgs[theUid][theIndex][1];
		  	s.innerHTML="<a href=\"javascript:popDiv('"+ theURL+"', '"+ theCap+"', '"+theUid+"', "+theIndex+");\">"+theString+"</a>";
		  }
		  
		  function hidePic(){
			  hidePicNoRestore();
			  document.getElementById("content").innerHTML = htmlStore;
		  }
		  
		  function hidePicNoRestore(){
		    popD.innerHTML = "";
			popD.style.display = "none";
		    scrollD.style.display = "none";
    		document.getElementById("content").style.display = "block";
			document.getElementById("scroll").style.display = "block";

		  }
