

function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox

function openbox()
{
	
  var url=banniere();
  var fadin=1;
  
  var box = document.getElementById('box'); 
  document.getElementById('filter').style.display='block';
  
  var title = document.getElementById('boxtitle');
  title.innerHTML = "<input type='button' onclick='closebox()' value='FERMER'><br><br>";
  
  var content = document.getElementById('boxcontent');
  content.style.padding="0";

  content.innerHTML = "<img src=" + url + " />";

  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }  	
}	

// Close the lightbox

function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
}



// Loading images 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 loadAll()
{

}

function banniere()
{
	var nbimage= 80;
    numimage= Math.round(Math.random()*(nbimage-1)+1);
	if (numimage <= 10)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 10 && numimage <= 20)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 20 && numimage <= 30)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 30 && numimage <= 40)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 40 && numimage <= 50)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 50 && numimage <= 60)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 60 && numimage <= 70)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	if (numimage > 70)
	{
	url = "/lightbox/images/PubRN2009FIN.jpg";
	}
	return url;
}

window.onload=loadAll;

