var xmlHttp;
var albumXmlHttp;

function photosInit() {
	/*
	var albumCollection = document.getElementById('albumscontainer').getElementsByTagName('a');
	for (var j = 0; j < albumCollection.length; j++) {
		albumCollection[j].setAttribute('href', 'javascript:void(0);');
	}
	
	var photoCollection = document.getElementById('photoscontainer').getElementsByTagName('a');
	for (var i = 0; i < photoCollection.length; i++) {
		photoCollection[i].setAttribute('href', 'javascript:void(0);');
	}
	*/
}

function changePhoto(photoNum) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
  		alert ("Your browser does not support AJAX!");
		return;
  	}
  	var url = "photofetcher.php";
	url = url + "?photoid=" + photoNum;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function changeAlbum(albumNum) {
	albumXmlHttp = GetXmlHttpObject();
	if (albumXmlHttp == null) {
  		alert ("Your browser does not support AJAX!");
		return;
  	}
  	var url = "albumfetcher.php";
	url = url + "?albumid=" + albumNum;
	albumXmlHttp.onreadystatechange = albumStateChanged;
	albumXmlHttp.open("GET", url, true);
	albumXmlHttp.send(null);
}


function albumStateChanged() {
	if(albumXmlHttp.readyState == 4) {
		document.getElementById('photoscontainer').innerHTML = albumXmlHttp.responseText;
	}
}

function stateChanged() {
	if(xmlHttp.readyState == 4) {
		document.getElementById('photocontent').innerHTML = xmlHttp.responseText;
	}
}

function photopopup(photoNum) {
	window.open('photos/' + photoNum + '.jpg', 'photo');
}
