/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function callServer(url, returnFct) {
  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = eval(returnFct);

  // Send the request
  xmlHttp.send(null);
}

function getAlbum(album,lang){
	if(album==""){
  		return;
  	}
	var url = "lib/ajax/getAlbum.php?lang=" + lang + "&album=" + album;
	callServer(url,"displayAlbum");
}

function displayAlbum(){
	var photoDiv = document.getElementById("photoDiv");
	var photoNavBar = document.getElementById("photoNavBar");

	if (xmlHttp.readyState == 4) {
    	var response = xmlHttp.responseText;
		//alert("response: " + response);
		photoDiv.innerHTML = response;
		photoNavBar.innerHTML = "List -> ";
	}
}

function getAllAlbum(lang){
	var url = "lib/ajax/getAllAlbum.php?lang=" + lang;
	callServer(url,"displayAllAlbum");
}

function displayAllAlbum(){
	var photoDiv = document.getElementById("photoDiv");
	var photoNavBar = document.getElementById("photoNavBar");

	if (xmlHttp.readyState == 4) {
    	var response = xmlHttp.responseText;
		//alert("response: " + response);
		photoDiv.innerHTML = response;
		photoNavBar.innerHTML = "List";
	}
}
