/**
 * 
 * Gestion IFRAME des images dans les fiches
 *
 */

// on englobe le tout dans une fonction anonyme onload
Event.observe(window, 'load', function(event)
{
  
  // effacement du DIV
	if ($('conteneur_gestionimg') != undefined)
	{
		$('conteneur_gestionimg').style.display = "none";
	}

	// clic du bouton d'ouverture
	// $('buttonimg').onclick = function()
	// {
    // gestion_images();
	// };
  
/*   $('formimages').onsubmit = function()
  {
    // on envoie les données dans le DIV
    gestion_images();
    
    return false;
  } */
});

// envoi des données dans le DIV en AJAX
function gestion_images(idObj, typeObj, numero)
{
	// $('conteneur_gestionimg').style.opacity = 0.0;
	$('conteneur_gestionimg').style.display = "block";
	$('conteneur_gestionimg').update(sprintf(uneIframe, idObj, typeObj, numero));
	// $('conteneur_gestionimg').update(uneIframe);
	
	// new Effect.Appear(
		// $('conteneur_gestionimg'),
		// { duration: 1, from: 0.0, to: 1.0 }
	// );
	
	
	// conteneur aux dimensions de la page
	var arrayPageSize = this.getPageSize();
	$('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });


	// clic du bouton de fermeture
	$('fermerimg').onclick = function()
	{
		ferm_gestion_images();
	};

}


// envoi des données dans le DIV en AJAX
function ferm_gestion_images()
{
	$('conteneur_gestionimg').style.display = "none";
	$('conteneur_gestionimg').update("");
}




/**
	*
	* Réaffichage et mise à jour d'une image dans le DOM du parent depuis l'iFrame
	*
	*/
function reaffiche_image(idImage, urlImage)
{
	if ($('conteneur_gestionimg') != undefined)
	{
		$(idImage).src = urlImage;
	}
}










/**
	* Fonction getPageSize()
	* détermine les dimensions de la page pour pouvoir étaler un DIV sur toute la page
	*
	* partie de :
	*/
// -----------------------------------------------------------------------------------
//
//	Lightbox v2.04
//	by Lokesh Dhakar - http://www.lokeshdhakar.com
//	Last Modification: 2/9/08
//
//	For more information, visit:
//	http://lokeshdhakar.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//  	- Free for use in both personal and commercial projects
//		- Attribution requires leaving author name, author link, and the license info intact.
//	
//  Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets.
//  		Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous.
//
// -----------------------------------------------------------------------------------
function getPageSize()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY)
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) 
	{	// all except Explorer
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		}
		else
		{
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{	
		pageWidth = xScroll;		
	}
	else
	{
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}


