var pattern = new RegExp("Microsoft Internet Explorer", "g");
var isIE = navigator.appName.match(pattern);

function createImageDiv(src)
{
    // var container = document.body;
    var container = document.getElementById("viewer");
	var divId = "_div";
    var imgId = "_img";

    if(document.getElementById(divId) != null)
		container.removeChild(document.getElementById(divId));

	var div = document.createElement("div");
	div.id = divId;
	div.style.backgroundColor = "#fff";
	div.style.border = "1px solid #ccc";
	div.style.padding = "10px";
	/* div.style.position = "absolute"; */
	div.style.zIndex = "2";

	var img = document.createElement("img");
	img.id  = imgId;
	img.src = src;

	var divWidth, divHeight, winWidth, winHeight;

	img.onclick = function ()
	{
		new Effect.BlindUp(divId);
	}
	img.onload = function ()
	{
		// scale the div to img bounds
		// not needed with absolute positionning
		div.style.width = img.offsetWidth;
		// make the div visible
		/* div.style.visibility = "visible"; */

		/*
		// used to "center" the div when using absolute positionning
		if(isIE)
		{
			winWidth = document.body.offsetWidth;
			winHeight = document.body.offsetHeight;
		}
		else
		{
			winWidth = document.body.clientWidth;
			winHeight = document.body.clientHeight;
		}
		divWidth  = document.getElementById(divId).offsetWidth;
		divHeight = document.getElementById(divId).offsetHeight;
		*/
		new Effect.BlindDown(divId);
	}

	div.appendChild(img);

	var p = document.createElement("p");
	p.innerHTML = "Pour fermer cette image, il vous suffit de cliquer dessus";
	p.style.textAlign = "center";
	div.appendChild(p);
	container.appendChild(div);
}


function centerWin(url, name, width, height, features)
{
	var win;
    var top =  (screen.height - height) / 2;
	var left = (screen.width - width )  / 2;
	win = window.open(url, name," top = " +
		top + ", left = " + left +
		", width = " + width +
		", height = " + height +
		", " + features);
	win.focus();
}

function navigateToURL(url)
{
   // if(document.location.href != url)
	document.location.href = url;
}

function resizeContainers()
{
	var div01 = document.getElementById("pannelContent");
	var div02 = document.getElementById("sideBarContent");

	var vgap = 10;

	if(div01.offsetHeight > div02.offsetHeight)
	{
		div02.style.height = div01.offsetHeight + vgap + "px";
		div01.style.height = div01.offsetHeight + vgap +  "px";
	}
	else if(div01.offsetHeight < div02.offsetHeight)
	{

		div01.style.height = div02.offsetHeight + vgap + "px";
		div02.style.height = div02.offsetHeight + vgap + "px";
	}
}

function resizeContent()
{
	document.getElementById("windowContent").style.height =
		document.getElementById("palmaresTB").offsetHeight + "px";
}