function doGallery(main, sub){
	document.getElementById('section').style.display = "none";
	document.getElementById('thumbnails').style.display = "none";
	document.getElementById('gallery_photo').style.display = "none";
	var url = "getGallery.php?action=gallery&main=" + main + "&sub=" + sub;
	sendHttpRequest(url, showGallery);
}

function showGallery(rText){
	var gData = rText.split("|");
	document.getElementById('section').innerHTML = gData[0];
	document.getElementById('thumbnails').innerHTML = gData[1];
	document.getElementById('gallery_photo').innerHTML = gData[2];
	document.getElementById('section').style.display = "block";
	document.getElementById('thumbnails').style.display = "block";
	document.getElementById('gallery_photo').style.display = "block";

	if(document.getElementById('tab1_on') != null){
		document.getElementById('tab1_off').style.display = "none";
		document.getElementById('tab2_on').style.display = "none";
		document.getElementById('tab1_on').style.display = "block";
		document.getElementById('tab2_off').style.display = "block";
	}
	
}

function doPhotos(main){
	document.getElementById('thumbnails').style.display = "none";
	document.getElementById('gallery_photo').style.display = "none";
	var url = "getGallery.php?action=photos&main=" + main;
	sendHttpRequest(url, showPhotos);
}

function showPhotos(rText){
	var gData = rText.split("|");
	document.getElementById('thumbnails').innerHTML = gData[0];
	document.getElementById('gallery_photo').innerHTML = gData[1];
	document.getElementById('thumbnails').style.display = "block";
	document.getElementById('gallery_photo').style.display = "block";
}

function doPhoto(img){
	document.getElementById('gallery_photo').style.display = "none";
	var url = "getGallery.php?action=photo&img=" + img;
	sendHttpRequest(url, showPhoto);
}

function showPhoto(rText){
	document.getElementById('gallery_photo').innerHTML = rText;
	document.getElementById('gallery_photo').style.display = "block";

	if(document.getElementById('tab1_on') != null){
		document.getElementById('tab1_off').style.display = "none";
		document.getElementById('tab2_on').style.display = "none";
		document.getElementById('tab1_on').style.display = "block";
		document.getElementById('tab2_off').style.display = "block";
	}
}

function doPhoto2(img){
	document.getElementById('gallery_photo').style.display = "none";
	var url = "getGallery.php?action=photo2&img=" + img;
	sendHttpRequest(url, showPhoto2);
}

function showPhoto2(rText){
	document.getElementById('gallery_photo').innerHTML = rText;
	document.getElementById('gallery_photo').style.display = "block";

	if(document.getElementById('tab1_on') != null){
		document.getElementById('tab1_off').style.display = "none";
		document.getElementById('tab2_on').style.display = "none";
		document.getElementById('tab1_on').style.display = "block";
		document.getElementById('tab2_off').style.display = "block";
	}
}

var photos = new Array("photo_before_after", "photo_after");
function tabToggle(tab, photo){
	for(i = 1; i <= 2; i++){
		document.getElementById('tab'+i+'_on').style.display = "none";
		document.getElementById('tab'+i+'_off').style.display = "block";
	}
	document.getElementById('tab'+tab+'_off').style.display = "none";
	document.getElementById('tab'+tab+'_on').style.display = "block";
	for(i = 0; i < photos.length; i++){
		document.getElementById(photos[i]).style.display = "none";
	}
	document.getElementById(photo).style.display = "block";
}