function GetId(obj)
{
	return document.getElementById(obj);
}

function createAlbumFrom(album)
{
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e)
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2)
		{
			try {  xhr = new XMLHttpRequest();     }
			catch (e3) {  xhr = false;   }
		}
	}
	
	xhr.onreadystatechange  = function()
	{
		if(xhr.readyState  == 4)
		{
			if(xhr.status  == 200)
			{
				GetId(album).innerHTML = xhr.responseText;
			}
			else
				GetId(album).innerHTML = "Cr&eacute;tion de l'album " + album + " : Error code " + xhr.status;
		}
	};
	
	xhr.open ("GET", "/pages/albumAjax.php?a="+album,  true);
	xhr.send(null);
}

function createLegendFrom(album)
{
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e)
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2)
		{
			try {  xhr = new XMLHttpRequest();     }
			catch (e3) {  xhr = false;   }
		}
	}
	
	xhr.onreadystatechange  = function()
	{
		if(xhr.readyState  == 4)
		{
			if(xhr.status  == 200)
			{
				GetId(album+"-legend").innerHTML = xhr.responseText;
			}
			else
				GetId(album+"-legend").innerHTML = "Cr&eacute;tion de l'album " + album + " : Error code " + xhr.status;
		}
	};
	
	xhr.open ("GET", "/pages/albumAjax.php?a="+album+"&legendOnly=1",  true);
	xhr.send(null);
}

function picSwap(idx)
{
	GetId("album-photo-1").style.width = (widths[idx]+18) + "px";
	GetId("album-photo-1").style.height = (heights[idx]+18) + "px";
	GetId("album-photo-2").style.width = widths[idx] + "px";
	GetId("album-photo-2").style.height = heights[idx] + "px";
	GetId("album-photo-2").style.backgroundImage = "url(" + path + photos[idx] + ")";

/*	if (idx > 0)
		GetId("photo-prev").onclick = "javascript:picSwap(" + (idx-1) + ")";
	else
		GetId("photo-prev").onclick = "javascript:picSwap(" + (total-1) + ")";

	if (idx < total)
		GetId("photo-next").onclick = "javascript:picSwap(" + (idx+1) + ")";
	else
		GetId("photo-next").onclick = "javascript:picSwap(0)";*/

	if (idx > 0)
		prev = "<div id=\"photo-prev\" onclick=\"javascript:picSwap(" + (idx-1) + ")\">Photo pr&eacute;c&eacute;dente</div>";
	else
		prev = "<div id=\"photo-prev\" onclick=\"javascript:picSwap(" + (total-1) + ")\">Photo pr&eacute;c&eacute;dente</div>";

	if (idx < total-1)
		next = "<div id=\"photo-next\" onclick=\"javascript:picSwap(" + (idx+1) + ")\">Photo suivante</div>";
	else
		next = "<div id=\"photo-next\" onclick=\"javascript:picSwap(0)\">Photo suivante</div>";
	
		GetId("album-nav").innerHTML = prev + next;
}

