/*
*	Common script File 
*	by Maksimus
*   Prev Ver 1.3h	
*       Ver 1.4h
*/

function toggle(div)
{
	if (document.getElementById(div).style.display == "none")
		document.getElementById(div).style.display = "block";
	else 
		document.getElementById(div).style.display = "none";
}
function togglei(div)
{
	if (document.getElementById(div).style.display == "none")
		document.getElementById(div).style.display = "inline";
	else 
		document.getElementById(div).style.display = "none";
}
function toShowI(div)
{
	document.getElementById(div).style.display = "inline";
}
function toShow(div)
{
	document.getElementById(div).style.display = "block";
}
function toHide(div)
{
	document.getElementById(div).style.display = "none";
}
function switchTo(div, divs)
{
	for(var d = 0; d<divs.length; d++)
	{
		document.getElementById(divs[d]).style.display = "none";
	}
	if (typeof div == "number")
		document.getElementById(divs[div]).style.display = "block";
	else
		document.getElementById(div).style.display = "block";
}
function displayError(message,error)
{
	document.getElementById('errorArea').innerHTML = '<div class="'+ (error ? 'errorBox' : 'messageBox')+'">'+message+'</div>';
}
function htmlspecialchars(str)
{
	re1 = new RegExp("&","g");
	re2 = new RegExp("<","g");
	re3 = new RegExp(">","g");
	re4 = new RegExp("\"","g");
	str = str.replace(re1, "&amp;");
	str = str.replace(re2, "&lt;");
	str = str.replace(re3, "&gt;");
	str = str.replace(re4, "&quot;");
	return str;
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

var dialog = "inDialog";

function closeDialog()
{
	toHide('dialog');
	toHide('busy');
}
function showDialog(ev, width, height)
{
	width  = width==undefined ? 400 : width;
	height = height==undefined ? 300 : height;
	pos = Math.max(100, Math.min(ev.clientY, getClientHeight() - height-50));
	document.getElementById("dialog").style.top = pos+"px";
	document.getElementById(dialog).style.width = width+"px"; 
	document.getElementById(dialog).style.height = height+"px";
	toShow('dialog');
	toShow('busy');
}