/**
* functions to manage input fields
*/
function startInput(input, initValue) {
	if(input != null) {
		if(input.value == initValue) input.value = "";
	}
}

function finishInput(input, initValue) {
	if(input != null) {
		if((input.value == initValue) || (input.value == "")) {
			input.value = initValue;
		}
	}
}

/**
* opens new window with given params:
* - url - url to be displayed
* - title - title of opened window
* - w - window width in pixels
* - h - height
*/
var attrs = "scrollbars=yes,resizable=yes,status=no,toolbar=no,location=no,directories=no,menubar=no";

function popup(url, title, w, h) {
	attrsPlus = attrs;
	var left = 0;
	var top = 0;
	var resX = screenX();
	var resY = screenY();

	if(!isNaN(w)) {
		attrsPlus += ",width=" + w;
		if(!isNaN(resX)) left = Math.round((resX - w)/2);
	}
	attrsPlus += ",left=" + left;
	if(!isNaN(h)) {
		attrsPlus += ",height=" + h;
		if(!isNaN(resY)) top = Math.round((resY - h)/2);
	}
	attrsPlus += ",top=" + top;
	pop = window.open(url, "_blank", attrsPlus);
//	pop.document.title = title;
	pop.focus();
}

/**
* defines user screen width in pixels
*/
function screenX() {
	var result = 0;	// default screen resolution

	if(window.screen) {
		result = window.screen.width;
	}

	return(result);
}

/**
* defines user screen height in pixels
*/
function screenY() {
	var result = 0;	// default screen resolution

	if(window.screen) {
		result = window.screen.height;
	}

	return(result);
}

