var popvideo;
var popvideo_zone;
var popvideo_title;
var popvideo_text;
var popvideo_close;

var popvideo_width = 490;
var popvideo_height = 330;


function popVideoLb_init(video)
{
	popvideo = $('video_cont');
	popvideo_zone = $('video_zone');
	popvideo_swf = $('video_swf');
	popvideo_close = $('video_close');
	
	//Taille de la fenetre ...
	if(getFrameHeight() < (popvideo_height + 60)) popvideo_height = getFrameHeight() - 60;
	if(getFrameWidth() < (popvideo_width + 60)) popvideo_width = getFrameWidth() - 60;
	
	/***/
	
	popvideo_close.onclick = function()
	{
		popVideoLbOnClose();
	};
	
	/***/
	
	var phpFile = site_url + 'ajax/popvideo.ajx.php';
	var params = '?flv=' + video;
	
	var aj = new Ajax.Updater(popvideo_swf, phpFile + params, {
		onComplete: 
		function()
		{
			popVideo_ShowMap();
		}
		});
}


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

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


function popVideo_ShowMap()
{	
	if(document.all)
	{
		popvideo.style.top = getScrollHeight() + "px";
		popvideo.style.left = getScrollWidth() + "px";
	}
	
	/***/
	
	if(is_ie || is_opera)
	{
		popvideo.style.top = getScrollHeight() + "px";
		popvideo.style.left = getScrollWidth() + "px";
	
		popvideo.style.width = $('dom_hack').offsetWidth + "px";
		popvideo.style.height = $('dom_hack').offsetHeight + "px";
	}
	else
	{
		popvideo.style.top = "0px";
		popvideo.style.left = "0px";
	
		popvideo.style.width = $('dom').offsetWidth + "px";
		popvideo.style.height = $('dom').offsetHeight + "px";
	}
	
	/***/
	
	if(is_ie || is_opera)
	{
		popvideo_zone.style.left = ((getFrameWidth() - popvideo_width)/2) + "px";
		popvideo_zone.style.top = ((getFrameHeight() - popvideo_height)/2) + "px";
	}
	else
	{
		popvideo_zone.style.left = getScrollWidth() + ((getFrameWidth() - popvideo_width)/2) + "px";
		popvideo_zone.style.top = getScrollHeight() + ((getFrameHeight() - popvideo_height)/2) + "px";
	}
	
	/***/
	
	popVideoLbOnShow();
}


function popVideoLbOnShow()
{
	if(!is_ie6)
	{
		new Effect.Appear(popvideo, {duration: 0.5, queue: 'front'});
	}
	else
	{
		if(cacheInputSelect())
		{
			popvideo.style.display = 'block';
		}
	}
}


function popVideoLbOnClose()
{
	if(!is_ie6)
	{
		new Effect.Fade(popvideo, {duration: 0.5, queue: 'front'});
		window.setTimeout('$(\'' + popvideo_swf.id + '\').innerHTML = \'\';', 250);
	}
	else
	{
		if(decacheInputSelect())
		{
			popvideo.style.display = 'none';
			popvideo_swf.innerHTML = '';
		}
	}
}


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


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


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


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


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