function PopupDialog(url, action, init)
{
	Dialog(url, action, init);
}

function Dialog(url, action, init)
{
	if (typeof init == "undefined") init = window;
	Dialog._geckoOpenModal(url, action, init);
}

Dialog._return = null;
Dialog._modal = null;
Dialog._arguments = null;

Dialog._geckoOpenModal = function(url, action, init)
{
	windowname = 'a_' + Math.round(Math.random() * 100000);
	var dlg = window.open(url, windowname, "toolbar=no,menubar=no,personalbar=no,width=860,height=500," +
			      "scrollbars=no,resizable=yes");
	Dialog._modal = dlg;
	Dialog._arguments = init;
	if (action) action(dlg);
	Dialog._return = function (val)
	{
		if (val && action) action(val);
	}
}

function popupText (item, id)
{
	PopupDialog(vr + "/popup.php?object=" + item + "&id_item=" + id);
}

function popupSubText (item, id)
{
	PopupDialog(vr + "/popup_sub.php?object=" + item + "&id_item=" + id);
}

function dlgInit()
{
	var body = document.getElementById('popup-contents');
	var w = body.offsetWidth;
	var h = body.offsetHeight;
	if (!document.all)
		window.resizeTo(w, h + 40);
	else
		window.resizeTo(w, h + 20);
	var x = (screen.availWidth - w) / 2;
	var y = (screen.availHeight - h) / 2;
	window.moveTo(x, y);
}

function show(id)
{
	oList = document.getElementById('second_nav').getElementsByTagName('ul');
	for (i = 0; i < oList.length; i++)
	{
		if (oList[i].id == 'menu_' + id)
		{
			oList[i].className = '';
			document.getElementById('gallery_' + id).className = 'prev';
		} else {
			tid = oList[i].id.replace('menu_', '');
			oList[i].className = 'hidden';
			document.getElementById('gallery_' + tid).className = 'prev hidden';
		}
	}
	return false;
}

function showBis(sender,id)
{
	oList = document.getElementById('gal_nav').getElementsByTagName('ul');
	for (i = 0; i < oList.length; i++)
	{
		if (oList[i].id == 'gallery_' + id)
			oList[i].className = 'prev';
		else
			oList[i].className = 'prev hidden';
	}
	
	var secondNavLinks = document.getElementById('second_nav').getElementsByTagName('a');
	for(var i = 0; i < secondNavLinks.length; i++) {
	  secondNavLinks[i].style.color = '#fff';
	}
	sender.style.color = '#cc3'
	this.blur();
	return false;
}

function showItem(frame)
{
	if (frame == currentFrame)
		return false;
	oList = document.getElementById('gal_nav').getElementsByTagName('li');
	for (i = 0; i < oList.length; i++)
	{
		if (oList[i].id == 'picture_' + frame)
			oList[i].className = 'act';
		else
			oList[i].className = '';
	}
	oListBis = document.getElementById('second_nav').getElementsByTagName('a');
	for (i = 0; i < oListBis.length; i++)
	{
		if (oListBis[i].id == 'menu_' + frame)
			oListBis[i].className = 'act';
		else
			oListBis[i].className = '';
	}
	Effect.Fade('content_' + currentFrame);
	oTemp = document.getElementById('right-content').getElementsByTagName('div');
	for (i = 0; i < oTemp.length; i++)
	{
		if (oTemp[i].id != '')
		{
			if (oTemp[i].id != 'content_' + currentFrame)
			{
				oTemp[i].style.display = 'none';
				oTemp[i].className = 'box_2 hidden';
			}
			if (oTemp[i].id == 'content_' + frame) {
				setTimeout("Effect.Appear('content_" + frame + "');", 1050);
				oTemp[i].className = 'box_2';
			}
		}
	}
	currentFrame = frame;
	return false;
}

function showItemBis(frame)
{
	if (frame == currentFrame)
		return false;
	oList = document.getElementById('third_nav').getElementsByTagName('li');
	for (i = 0; i < oList.length; i++)
	{
		if (oList[i].id == 'picture_' + frame)
			oList[i].className = 'act';
		else
			oList[i].className = '';
	}
	Effect.Fade('content_' + currentFrame);
	oTemp = document.getElementById('right-content').getElementsByTagName('div');
	for (i = 0; i < oTemp.length; i++)
	{
		if (oTemp[i].id != '')
		{
			if (oTemp[i].id != 'content_' + currentFrame)
			{
				oTemp[i].style.display = 'none';
				oTemp[i].className = 'box_2 hidden';
			}
			if (oTemp[i].id == 'content_' + frame) {
				setTimeout("Effect.Appear('content_" + frame + "');", 1050);
				oTemp[i].className = 'box_2';
			}
		}
	}
	currentFrame = frame;
	return false;
}

function showSubItem(id, pic)
{
	oList = document.getElementById('item_list').getElementsByTagName('li');
	for (i = 0; i < oList.length; i++)
	{
		if (oList[i].id == 'sub_item_' + id)
		{
			oList[i].className = 'act';
		} else {
			oList[i].className = '';
		}
	}
	oList = document.getElementById('item_list_bis').getElementsByTagName('li');
	for (i = 0; i < oList.length; i++)
	{
		if (oList[i].id == 'sub_item_' + id)
		{
			oList[i].className = 'act';
		} else {
			oList[i].className = '';
		}
	}
	document.getElementById('picture_text').src = pic;
	return false;
}

function updateGallery(pic, legend)
{
	document.getElementById('legend').innerHTML = legend;
	document.getElementById('text-pic').src = vr + '/user/carnet_pictures/' + pic;
}