var frameName = 'mainContent';
var currentAlbum = "";
var currentImage = "";
var useAlbumOnlyLoad = 1;

function setCurrentAlbum(inString) {
	currentAlbum = inString;
}

function setCurrentImage(inString) {
	currentImage = inString;
}

function getCurrentAlbum() {
	return currentAlbum;
}

function getCurrentImage() {
	return currentImage;
}


function hideAll() {
	if (!useAlbumOnlyLoad == 1) {
		albumSub = "album_";
		divs = document.getElementsByTagName('div');
		for (i = 0; i < divs.length; i++) {
			currentDiv = divs[i].id;
			if (currentDiv.substring(0, albumSub.length) == albumSub) {
				hideAlbum(currentDiv);
			}
		}
	}
}

function hideAlbum(inAlbum) {
	if (!useAlbumOnlyLoad == 1) {
		document.getElementById(inAlbum).style.display = 'none';
	}
}

function showAlbum(inAlbum) {
	if (!useAlbumOnlyLoad == 1) {
		setCurrentAlbum(inAlbum);
		inAlbum = "album_" + inAlbum;
		hideAll();
		document.getElementById(inAlbum).style.display = 'inline';
	} else {
		getFile("gallery.loadAlbum.php", "gallery/", "_scrollLocation", "?album="+inAlbum);
	}
}


function showEnlarged(inLoc, inWidth, inHeight){
	setFocus(frameName);
	if (inLoc.length > 0){
		if (setSectionTitle) {
			newTitle = "Gallery";
			newTitle += inLoc.substring(inLoc.indexOf('/'), inLoc.lastIndexOf('/')).replace(/[\/]/g, " - ") + ' - ';
			newTitle += '"' + inLoc.substring(inLoc.lastIndexOf('/') + 1) + '"';
			setSectionTitle(newTitle, frameTitle);
		}
		var url="gallery/gallery.enlarge_include.php?loc="+inLoc+"&width="+inWidth+"&height="+inHeight;
		xmlHttp=GetXmlHttpObject(stateChanged);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	} else {
		document.getElementById(frameName).innerHTML="";
	}
}

function showText(inLoc){
	setFocus('galleryText');
	if (inLoc.length > 0){
		url="gallery/gallery.show_text.php?loc="+inLoc;
		xmlHttp=GetXmlHttpObject(stateChanged);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	} else {
		document.getElementById(frameName).innerHTML="";
	}
}

function stateChanged() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById(focusDiv).innerHTML=xmlHttp.responseText;
//		alert(xmlHttp.getAllResponseHeaders());
	} else {
//		updateProg(xmlHttp.responseText.length/*, xmlHttp.getResponseHeader("Content-Length")*/)
//		alert(xmlHttp.readyState);
//		alert(xmlHttp.getResponseHeader("Date"));
	}
}

function GetXmlHttpObject(handler){ 
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This example doesn't work in Opera");
		return;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP";
		}
		try{
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler;
			return objXmlHttp;
		}
		catch(e){
			alert("Error. Scripting for ActiveX might be disabled");
			return;
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler;
		return objXmlHttp;
	}
}
