
var value=0;
var l_background_color="black";
var timer;
var timer2;
var compteur = 10;
setOpacity(value,l_background_color);


function setOpacity(value,l_background_color) {
	var page = document.getElementById('div_opacity');
	var content = document.getElementById('page');
	
	if ( value > 0 )
	{
		page.style.backgroundColor = l_background_color;
		page.style.opacity = value/10;
		page.style.filter = 'alpha(opacity=' + value*10 + ')';
		content.style.opacity = 100;
	}
	else
	{
		return true;
	}
}

function decremente(compteur)
{
	if ( compteur == 0 )
	{
		clearTimeout(timer);
	}
	else
	{
		compteur = compteur - 0.2;
		setOpacity(compteur,background_color);
		if ( compteur > 1 )
		{
			timer = setTimeout("decremente("+compteur+")",42);
		}
	}

}


function loadImage(l_image_src){

  ImagesLoader=new Image();

  ImagesLoader.onload = function() {
	document.getElementsByTagName("body")[0].background = l_image_src;
	clearTimeout(timer2);
	decremente(compteur);


  };

  ImagesLoader.src= l_image_src;
}   


function resizeFooter(){
	if ( document.getElementById('div_opacity') )
	{
		var opacity = document.getElementById('div_opacity');
	}
	if ( page.offsetHeight > 2000 && opacity)
	{
		opacity.style.height = page.offsetHeight + "px";
	}
	else if ( opacity ) 
	{
		opacity.style.height = 2048 + "px";
	}
}

function esec_ajax_initialize ()
	{
	if ( window.XMLHttpRequest )
		{ esec_ajax = new XMLHttpRequest() }
	else if ( window.ActiveXObject )
		{ esec_ajax = new ActiveXObject("Microsoft.XMLHTTP") }
	}

esec_ajax_initialize();

function esec_aja_request (src,destination,action, params)
	{
	if (esec_ajax)
		{
		esec_ajax.abort();
		if ( document.getElementById(src) )
			{
				var obj = document.getElementById(src);
				var recherche = obj.value;
			}
		else
			{
				var status = src;
			}
		esec_ajax.onreadystatechange = function()
			{
			if ( esec_ajax.readyState == 4 )
				{

				if ( esec_ajax.status == 200 )
					{
					document.getElementById(destination).innerHTML = esec_ajax.responseText;
					}
				else
					{
					document.getElementById(destination).innerHTML = "";
					}
				}
			}
		}
		if ( document.getElementById(src) )
			{
		esec_ajax.open("GET","reference_eleve.php?action="+action+"&"+params,true);

		esec_ajax.send(null);
			}
		else
			{
		esec_ajax.open("GET","reference_eleve.php?action="+action+"&"+params,true);
		esec_ajax.send(null);
			}
	}




function displayNotification(img,id)
{
	height = img.offsetHeight;

	notification = document.getElementById("note_image_" + id);
	notification.style.marginTop = "-" + height + "px";
	notification.style.display = "block";

}
function unDisplayNotification(id)
{
	notification = document.getElementById("note_image_" + id);
	notification.style.display = "none";

}
function setWrapperHeight(img_height){
	
	if( img_height > 850 )
	{
		return 874;
	}
	if( img_height > 800 )
	{
		return 828;
	}

	if( img_height > 750 )
	{
		return 782;
	}

	if( img_height > 700 )
	{
		return 736;
	}
	if( img_height > 650 )
	{
		return 690;
	}
	if( img_height > 600 )
	{
		return 644;
	}

	if( img_height > 550 )
	{
		return 598;
	}

	if( img_height > 500 )
	{
		return 552;
	}
	if( img_height > 450 )
	{
		return 506;
	}

	if( img_height > 400 )
	{
		return 460;
	}
	if( img_height > 350 )
	{
		return 414;
	}
	if( img_height > 300 )
	{
		return 368;
	}
	if( img_height > 200 )
	{
		return 322;
	}

}
function displayPhoto(div)
{	

	if ( document.getElementById(div.id + "_n") )
	{
		divNote = document.getElementById(div.id + "_n");
	}
	else
	{
		divNote = false;
	}
	divW = document.getElementById(div.id + "_p");
	divW2 = document.getElementById(div.id + "_p2");
	img = document.getElementById(div.id + "_i");
	imgHeight = img.offsetHeight;
	
	height_target = setWrapperHeight(imgHeight) - 11;
	
	if ( divW.style.height == height_target + "px" )
	{	
		

		divW.style.height = "";
		divW2.style.height = 35 + "px";
		divW2.style.position = "relative";
		divW2.style.bottom = "200px";
		div.style.overflow = "hidden";
		if ( divNote )
		{
			divNote.style.display = "none";
		}
	}
	else
	{
		divW.style.height = height_target + "px";
		divW2.style.position = "static";
		div.style.overflow = "visible";
		if ( divNote )
		{
			divNote.style.display = "block";
		}
	}
}
