

//####################################//


function checkInputData(type)
{
	if(type == 'int')
	{
		if((event.keyCode < 48) || (event.keyCode > 57) && event.keyCode != 13)
			event.returnValue = false;
	}
	else
	if(type == 'float')
	{
		if((event.keyCode < 48 || event.keyCode > 57)
			 && event.keyCode != 46 && event.keyCode != 44 && event.keyCode != 13)
			event.returnValue = false;
	}
}


//####################################//


function newWnd(obj, wWidth, wHeight, wName)
{
	if(obj == null)
		return false;

	var name = (wName == null) ? "newWnd" + Math.ceil( Math.random() * 3000 ) : wName;
	var width = (wWidth == null) ? 500 : parseInt(wWidth);
	var height = (wHeight == null) ? 400 : parseInt(wHeight);
	var loc = null;
	
	if(obj.tagName == "A" & obj.getAttribute("href") != null)
	{
		loc = obj.getAttribute("href");
	}
	
	if(loc != null)
	{
		wnd = window.open(loc , name, 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=yes,status=no,width='+width+',height='+height);
		wnd.focus();
		return false;
	}
	else
	{
		return true;
	}
}


//####################################//


var wndMargin = 0;
var screenW, screenH;

screenW = window.screen.availWidth;
screenH = window.screen.availHeight;

function closeWnd()
{
	if(window.opener != null)
		window.opener.focus();
		
	this.window.close();
}

function resizeWnd(w, h)
{
	var wndW, wndH = 0;
	var posX, posY = 0;
	w += wndMargin;
	h += wndMargin;
	
	if(w >= screenW)
		wndW = screenW;
	else
		wndW = w;
	if(h >= screenH)
		wndH = screenH;
	else
		wndH = h;

	posX = Math.ceil((screenW / 2) - (wndW / 2));
	posY = Math.ceil((screenH / 2) - (wndH / 2));
	if(posX < 0)
		posX = 0;
	if(posY < 0)
		posY = 0;
	
	window.resizeTo(wndW, wndH);
	window.moveTo(posX, posY);
}


//####################################//


function display(id, doDisplay)
{
	var layer = document.getElementById(id);
	
	if(layer == null)
		return;

	if(doDisplay == null)
		layer.style.display = (layer.style.display == 'none') ? 'block' : 'none';
	else
		layer.style.display = (doDisplay == true) ? 'block' : 'none';

}


//####################################//


