function computeWindowDimension(width, height, flags)
{
	var offsetY = 16;
	var posX = (screen.availWidth - (0 + width - 10)) / 2;
	if (flags.indexOf("toolbar=yes") != -1)
		offsetY += 32;
	if (flags.indexOf("status=yes") != -1)
		offsetY += 16;
	height -= offsetY;
	var posY = ((screen.availHeight - height) / 2) - offsetY;
	if (posX < 0)
		posX = 0;
	if (posY < 0)
		posY = 0;
	return 'width=' + width + ',height=' + height + ',top=' + posY + ',left=' + posX;
}

function openWindow(url, width, height)
{
    var flags = 'status=yes,toolbar=yes,location=no,directories=no,scrollbars=yes,resizable=yes';
	window.open(encodeURI(url.replace(/[#]/g, '%23')), '', computeWindowDimension(width, height, flags) + ',' + flags);
}

function openWindowWithFlags(url, width, height, flags)
{
	window.open(encodeURI(url.replace(/[#]/g, '%23')), '', computeWindowDimension(width, height, flags) + ',' + flags);
}

function openPopup(url, width, height)
{
    var flags = 'status=no,toolbar=no,location=no,directories=no,scrollbars=yes,resizable=yes';
	window.open(encodeURI(url.replace(/[#]/g, '%23')), '', computeWindowDimension(width, height, flags) + ',' + flags);
}

function openPopupNoScroll(url, width, height)
{
    var flags = 'status=no,toolbar=no,location=no,directories=no,scrollbars=no,resizable=yes';
	window.open(encodeURI(url.replace(/[#]/g, '%23')), '', computeWindowDimension(width, height, flags) + ',' + flags);
}

function switchBlock(blockId) 
{
	var Block, Img;
	Block = document.getElementById(blockId);
	Img = document.getElementById(blockId + 'Img');
	if (Block.style.display == 'none')
	{
		Block.style.display = 'inline';
		Img.src = 'fo/images/fleche_bas.gif';
	}
	else
	{
		Block.style.display = 'none';
		Img.src = 'fo/images/fleche_droite.gif';
	}	
}

function switchOneBlock(blockId) 
{
	var Block, i;		
	for(i=1; i<5; i++)
	{
		i = i + "";																				
		Block = document.getElementById(i);
		Block.style.display = 'none';			
	}
	
	Block = document.getElementById(blockId);		
	Block.style.display = 'inline';
}

function switchOneBlockWithin(blockId,max) 
{
	var Block, i;		
	for(i=1; i<= max; i++)
	{
		i = i + "";																				
		Block = document.getElementById(i);
		Block.style.display = 'none';			
	}
	
	Block = document.getElementById(blockId);		
	Block.style.display = 'inline';
}
