
function next_up()
{
	var the_div = $("thumb_inner_container");
	var the_height = the_div.getHeight();
	if (parseInt(the_div.style.top)==0)
		quick_message("Aucune autre photo","Photo",alertImg);
	else
		if(parseInt(the_div.style.top)+265<0)
			the_div.style.top = parseInt(the_div.style.top)+265;
		else
			the_div.style.top = 0;
}

function next_down()
{
	//the thumb_viewer is 265px high in photo_viewer.aspx	
	//the inner go up
	var the_div = $("thumb_inner_container");
	var the_height = the_div.getHeight();
	var the_max = the_height-265;
	if ((the_height-265)+parseInt(the_div.style.top)==0)
		quick_message("Aucune autre photo","Photo");
	else
	{
		if (parseInt(the_div.style.top) - 265 > 0-the_max) 
			the_div.style.top = parseInt(the_div.style.top) - 265;
		else 
			the_div.style.top = 0-(the_max);	
	}
}


function change_photo(the_img)
{
	processing();
	new Ajax.Updater('photo_container', 'photo_container.aspx', {evalScripts:true,
  			parameters: {theurl:the_img},
   			onComplete:function(){is_completly_loaded();}
			});	
	
}

function is_completly_loaded()
{
	try {
		if ($("first_photo") == null || !$("first_photo").complete) {
			is_completly_loaded.delay(global_delay);
		}
		else 
			resize_photo();
	}catch(e){alert("error in fucntion is_completly_loaded in photo.js"+e)}
}

function resize_photo()
{
	var original_width = $("first_photo").getWidth();
	
	if(original_width>740)
	{
		var the_pourcentage = (740/original_width);
		var ratio = $("first_photo").getWidth()/$("first_photo").getHeight();
		
		
		$("first_photo").style.width = $("first_photo").getWidth()*the_pourcentage;
		$("first_photo").style.height = $("first_photo").getWidth()/ratio;
	}
	page_assembly('resize_photo');
}























function initiate_photos()
{
	try{
		if (is_in_process('load_photo')) {	
			initiate_photos.delay(global_delay);		
		}
		else {			
			show_albums_thumbs();		
		}
		
	}catch(e){"error in function initiate_photos() in photo"+e}
}
function show_albums_thumbs()
{
		function_initiated("show_albums_thumbs");
		if (!Object.isElement($("album_list"))) {
			function_initiated("inner_show_albums_thumbs");
			var current_album = -99;
			var timer = 0;
			
			var equipeContainer = document.createElement("div");
			equipeContainer.className = "album_list";
			equipeContainer.id = "equipe_album_list";
			equipeContainer.onclick = function(){
				show_equipe();
			};
			var the_thumb = document.createElement("img");
			the_thumb.className = "album_thumb";
			the_thumb.id = "equipe_thumb";
			the_thumb.src = pathToImages + "equipe_thumb.gif";
			
			var the_title = document.createElement("span");
			the_title.className = "album_title";
			the_title.id = "equipe_album_title";
			the_title.innerHTML = "Notre  \u00c9quipe";
			equipeContainer.appendChild(the_thumb);
			equipeContainer.appendChild(the_title);
			
			$("middle_container").appendChild(equipeContainer);
			photoArray.each(function(ph){
				function_initiated("photoArray");
				if (ph.albumID != current_album) {
					var outerContainer = document.createElement("div");
					outerContainer.className = "album_list";
					outerContainer.id = ph.albumID + "album_list";					
					var the_thumb = document.createElement("img");
					the_thumb.className = "album_thumb";
					the_thumb.id = ph.albumID + "_thumb";
					the_thumb.src = "images/photos/" + ph.theThumbURL;
					the_thumb.onclick = function(){
						function_initiated("show_thumbs");
						show_thumbs(ph.albumID);						
					};
					
					var the_title = document.createElement("span");
					the_title.className = "album_title";
					the_title.id = ph.albumID + "album_title";
					the_title.innerHTML = ph.albumName;
					the_title.onclick = function(){
						show_this_album(ph.albumID,ph.albumName);
					};
					
					outerContainer.appendChild(the_thumb);
					outerContainer.appendChild(the_title);
					
					if (selected_user.status > 24) {
						var the_delete = document.createElement("span");
						the_delete.style.color = "red";
						the_delete.style.fontWeight = "bold";
						the_delete.innerHTML = "  [ SUPPRIMER ]  ";
						the_delete.onclick = function(){
							show_alert("delete_album",ph.albumID);
						};
						outerContainer.appendChild(the_delete);
					}
					
					$("middle_container").appendChild(outerContainer);
					current_album = ph.albumID;
				}
				function_completed("photoArray");
			});
			function_completed("inner_show_albums_thumbs");
		}
		else 
			center_container.style.display = "block";
		
		function_completed("show_albums_thumbs");
		page_assembly('show_albums_thumbs');
}


function show_image(photo_id)
{
	if (!all_loading_completed()) 
		show_image.delay(global_delay, photo_id);
	else {
		try {
			$(current_displayed_photo + "photo").style.display = "none";
			$(current_displayed_photo + "_thumb").style.border = "none";
		} 
		catch (e) {
		};
		$(photo_id + "photo").style.display = "block";
		$(photo_id + "photo").style.marginLeft="auto";
		$(photo_id + "photo").style.marginRight="auto";
		current_displayed_photo = photo_id;
		$(photo_id + "_thumb").style.border = "2px solid #11f7ef";
		container.style.height = $(photo_id + "photo").getHeight() + 150;
	}
}

function ajouter_cyclo_photos()
{
	$("for_site").value="cyclo";
	
	var final_value = $("cycloAlbumTitle").value.strip();

	if ((final_value == "") && ($('cycloAlbumList').selectedIndex == 0)) 
		alert("Choisir un album");
	else if ((final_value != "") && ($('cycloAlbumList').selectedIndex > 0)) 
			alert("Vous ne pouvez choisir un album et en créer un autre simultanément");
	else {
		if ((final_value == "") && ($('cycloAlbumList').selectedIndex > 0)) 
			$("albumID").value = document.Form1.cycloAlbumList.options[document.Form1.cycloAlbumList.selectedIndex].value;
		else 
		{
			$("execute").value="newAlbum";
			$("albumTitle").value=$("cycloAlbumTitle").value;
		}	

		document.Form1.submit();
	}
}

function ajouter_roue_photos()
{
	$("for_site").value="roue";
	
	var final_value = $("roueAlbumTitle").value.strip();

	if ((final_value == "") && ($('roueAlbumList').selectedIndex == 0)) 
		alert("Choisir un album");
	else if ((final_value != "") && ($('roueAlbumList').selectedIndex > 0)) 
			alert("Vous ne pouvez choisir un album et en créer un autre simultanément");
	else {
		if ((final_value == "") && ($('roueAlbumList').selectedIndex > 0)) 
			$("albumID").value = document.Form1.roueAlbumList.options[document.Form1.roueAlbumList.selectedIndex].value;
		else 
		{
			$("execute").value="newAlbum";
			$("albumTitle").value=$("roueAlbumTitle").value;
		}	

		document.Form1.submit();
	}
}


