var menuOpen = false;
var divClick = false;

function ViewImage(iFile, iTitle, sNombre)
{
   var win = window.open("", "image", "left=0, top=0, width=" + (parseInt(screen.width) - 100) + ", height=" + (parseInt(screen.height) - 100) + ", resizable=yes");  
   win.document.open();
   win.document.write("<html>\n<head>\n<title>" + iTitle + "</title>\n");
   win.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\">\n");
   win.document.write("</head>\n");
   win.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginwidth=\"0\">\n\n");
   win.document.write("<center>\n<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\" border=\"0\">\n");
   win.document.write("<tr>\n<td align=\"center\" valign=\"middle\">\n");
   win.document.write("<img src=\"resources/" + iFile + "\" width=\"" + (parseInt(screen.width) - 100) + "\" height=\"" + (parseInt(screen.height) - 100) + "\">");
   win.document.write("</td>\n</tr>\n</table>\n</center>\n\n</body>\n</html>");
   win.document.close();
}

function goToURL(URL)
{
	location.href = URL;
}

function showArea(iArea)
{
	document.getElementById("area" + iArea).className = "dialogtdover";
}

function hideArea(iArea)
{
	document.getElementById("area" + iArea).className = "dialogtdout";
}

function showMenu(oMenuParent, iMenu)
{
	hideAllMenus();
	var table = document.getElementById("tableBody");
	var menu = document.getElementById(iMenu);
	menu.style.top = oMenuParent.offsetParent.offsetTop + oMenuParent.clientHeight + 1 + "px";
	menu.style.left = parseInt(table.style.left) + oMenuParent.offsetLeft + 0 + "px";
	menu.style.visibility = "visible";
	menuOpen = true;
}

function hideMenu(iMenu)
{
	if(iMenu < 0)
		hideAllMenus();
	else if(!menuOpen)
	{
		var menu = document.getElementById(iMenu);
		menu.style.visibility = "hidden";
	}
}

function hideAllMenus()
{
	menuOpen = false;
	hideMenu(3);
	hideMenu(4);
}

document.onclick = function()
{
	hideAllMenus();
}

window.onload = function()
{
	var table = document.getElementById("tableBody");
	table.style.top = "0px";
	table.style.left = ((document.body.clientWidth - parseInt(table.style.width)) / 2) + "px";
	table.style.visibility = "visible";
	showAdv(true);
}

function closeDiv(oDiv)
{
	if((oDiv != null) && (oDiv != "undefined"))
	{
		document.getElementById(oDiv).style.visibility = "hidden";
		document.getElementById("adv_1").style.visibility = "hidden";
		document.getElementById("adv_2").style.visibility = "hidden";
	}
}

function showAdv(bShow)
{
	if(bShow)
	{
		var oDiv = document.getElementById("adv");
		if((oDiv != null) && (oDiv != "undefined"))
		{
			oDiv.style.left = ((document.body.clientWidth - parseInt(oDiv.style.width)) / 2) + "px";
			oDiv.style.top = ((document.body.clientHeight - parseInt(oDiv.offsetHeight)) / 2) + "px";
			oDiv.style.visibility = "visible";
			oDiv.filters[0].irisstyle = "SQUARE";
			oDiv.filters[0].Apply();
			oDiv.style.backgroundColor = "#CC6600";
			oDiv.filters[0].Play();
			document.getElementById("adv_1").style.visibility = "visible";
			document.getElementById("adv_2").style.visibility = "visible";
		}
	}
}

function dragDiv(oDiv)
{
	if(divClick && (event.button == 1))
	{
		oDiv.style.left = tempx + event.clientX - offsetx + "px";
		oDiv.style.top = tempy + event.clientY - offsety + "px";
	}
}

function dropDiv(oDiv)
{
	divClick = false;
}

function clickDiv(oDiv)
{
	if(event.button == 1)
	{
		divClick = true;
		offsetx = event.clientX;
		offsety = event.clientY;
		tempx = parseInt(oDiv.style.left);
		tempy = parseInt(oDiv.style.top);
	}
}