var popphoto;
var popphoto_zone;
var popphoto_content;

var popphoto_title;
var popphoto_text;
var popphoto_close;

var popphoto_img;

var popphoto_width = 785;
var popphoto_height = 566;


function popPhotoLb_init(photo)
{
	popphoto = $('photo_cont');
	popphoto_zone = $('photo_zone');
	popphoto_content = $('photo_content');
	popphoto_close = $('photo_close');
	
	/*
	popphoto_title = $('photo_title');
	popphoto_img = $('photo_img');
	*/
	
	//Taille de la fenetre ...
	if(getFrameHeight() < (popphoto_height + 60)) popphoto_height = getFrameHeight() - 60;
	if(getFrameWidth() < (popphoto_width + 60)) popphoto_width = getFrameWidth() - 60;
	
	/***/
	
	popphoto_close.onclick = function()
	{
		popPhotoLbOnClose();
	};
	
	/***/
	
	var phpFile = site_url + 'ajax/popphoto.ajx.php';
	var params = '?rub_id=' + rub_id + '&artiste_id=' + artiste_id + '&photo=' + photo;
	
	var aj = new Ajax.Updater(popphoto_content, phpFile + params, {
		onComplete: 
		function()
		{
			popphoto_title = $('photo_title');
			popphoto_img = $('photo_img');
			
			popPhoto_ShowMap();
		}
		});
}


function popPhoto_Update()
{
	if(popphoto.style.display != 'none')
	{
		if(document.all)
		{
			popphoto.style.top = getScrollHeight() + "px";
			popphoto.style.left = getScrollWidth() + "px";
		}
	
		/***/
	
		if(is_ie || is_opera)
		{
			popphoto.style.top = getScrollHeight() + "px";
			popphoto.style.left = getScrollWidth() + "px";
	
			popphoto.style.width = $('dom_hack').offsetWidth + "px";
			popphoto.style.height = $('dom_hack').offsetHeight + "px";
		}
		else
		{
			popphoto.style.top = "0px";
			popphoto.style.left = "0px";
	
			popphoto.style.width = $('dom').offsetWidth + "px";
			popphoto.style.height = $('dom').offsetHeight + "px";
		}
		
		/***/
	
		if(is_ie || is_opera)
		{
			popphoto_zone.style.left = ((getFrameWidth() - popphoto_zone.offsetWidth)/2) + "px";
			popphoto_zone.style.top = ((getFrameHeight() - popphoto_zone.offsetHeight)/2) + "px";
		}
		else
		{
			popphoto_zone.style.left = getScrollWidth() + ((getFrameWidth() - popphoto_zone.offsetWidth)/2) + "px";
			popphoto_zone.style.top = getScrollHeight() + ((getFrameHeight() - popphoto_zone.offsetHeight)/2) + "px";
		}

		/***/
			
		popphoto.style.display = 'block';
	}
}


function popPhoto_ShowMap()
{	
	if(document.all)
	{
		popphoto.style.top = getScrollHeight() + "px";
		popphoto.style.left = getScrollWidth() + "px";
	}
	
	
	if(is_ie || is_opera)
	{
		popphoto.style.top = getScrollHeight() + "px";
		popphoto.style.left = getScrollWidth() + "px";
	
		popphoto.style.width = $('dom_hack').offsetWidth + "px";
		popphoto.style.height = $('dom_hack').offsetHeight + "px";
	}
	else
	{
		popphoto.style.top = "0px";
		popphoto.style.left = "0px";
	
		popphoto.style.width = $('dom').offsetWidth + "px";
		popphoto.style.height = $('dom').offsetHeight + "px";
	}
		
	/***/	
	
	if(is_ie || is_opera)
	{
		popphoto_zone.style.left = ((getFrameWidth() - popphoto_width)/2) + "px";
		popphoto_zone.style.top = ((getFrameHeight() - popphoto_height)/2) + "px";
	}
	else
	{
		popphoto_zone.style.left = getScrollWidth() + ((getFrameWidth() - popphoto_width)/2) + "px";
		popphoto_zone.style.top = getScrollHeight() + ((getFrameHeight() - popphoto_height)/2) + "px";
	}
	
	/***/
	
	popPhotoLbOnShow();
}


function popPhotoLbOnShow()
{
	if(!is_ie6)
	{
		new Effect.Appear(popphoto, {duration: 0.5, queue: 'front'});
	}
	else
	{
		if(cacheInputSelect())
		{
			new Effect.Appear(popphoto, {duration: 0.5, queue: 'front'});
		}
	}
}


function popPhotoLbOnClose()
{
	if(!is_ie6)
	{
		new Effect.Fade(popphoto, {duration: 0.5, queue: 'front'});
	}
	else
	{
		if(decacheInputSelect())
		{
			new Effect.Fade(popphoto, {duration: 0.5, queue: 'front'});
		}
	}
}


function popPhotoLbAddLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		if(!is_ie)
		{
			window.onload = func;
		}
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}


function popPhotoLbAddResizeEvent(func)
{
	var oldonresize = window.onresize;
	if (typeof window.onresize != 'function')
	{
		window.onresize = func;
	}
	else
	{
		window.onresize = function()
		{
			oldonresize();
			func();
		}
	}
}


function popPhotoLbAddScrollEvent(func)
{
	var oldonscroll = window.onscroll;
	if (typeof window.onscroll != 'function')
	{
		window.onscroll = func;
	}
	else
	{
		window.onscroll = function()
		{
			oldonscroll();
			func();
		}
	}
}


function popPhotoLbAddLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		if(!is_ie)
		{
			window.onload = func;
		}
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}


function popPhotoLbAddClickEvent(obj,func)
{
	var oldonclick = obj.onclick;
	if (typeof obj.onclick != 'function')
	{
		obj.onclick = func;
	}
	else
	{
		obj.onclick = function()
		{
			oldonclick();
			func();
		}
	}
}
