/*
  Ajax Lightbox 
  (c) 2008-2009 xul.fr
  GPL license
*/  


// height of current view for all browsers but IE

function viewHeight() 
{
    if(window.innerHeight)return(window.innerHeight);
    if(document.documentElement && document.documentElement.clientHeight) 
         return(document.documentElement.clientHeight);
    if(document.body) return(document.body.clientHeight); 
    return 50;
}

// images are loaded asynchronously with no delay

function preloading(i, url)
{
	var xhr=createXHR();   
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			i.src = url;
		} 
	}; 

	xhr.open("GET", url , true);
	xhr.send(null); 
} 



function openbox( div )
{
	jQuery('document').ready(function() {
		
	  //alert("Tout est chargé OK");
	  var box = $('#'+div);
	  var filter =  $('#filter');
	  filter.show();
		
	  if(navigator.appName.substring(0, 3) == "Mic")  // for IE
	  {
		//filter.css("opacity", "alpha(opacity=60)");
		x = ($(window).height() - $('#'+div).height()) / 2;
		y = ($("#filter").width() - $('#'+div).width() )/ 2;
		
		
		var xx = document.body.scrollTop+x;
		box.css("top", xx+"px" );
		box.css("left", y + "px");
		//filter.css("top", expression(fixed_top(this,10)) );
		box.fadeIn();
		
	  }
	  else
	  {
		//alert("HEIGHT w:"+jQuery(window).height()+" box : "+$('#'+div).height());
		//alert("WIDHT w:"+jQuery(window).width()+" box : "+$('#'+div).width());
		
		x = (jQuery(window).height() - $('#'+div).height()) / 2;
		y = (jQuery(window).width() - $('#'+div).width() )/ 2;
		
		box.css("top", x + "px");
		box.css("left", y + "px");
		box.css("position",'fixed'); // fixed does not work on IE
		filter.css("position",'fixed'); // fixed does not work on IE
		//filter.style.position='fixed'; 
		box.fadeIn();
	  }
	});

	
}	



function closebox( div )
{
	$('#'+div).fadeOut();
	$('#filter').hide();
   //document.getElementById('box').style.display='none';
   //document.getElementById('filter').style.display='none';
}



