var hints = [];
var hintObjects = [];
function addHint(what, hint) {
if (typeof what != 'string') hintObjects[hintObjects.length] = what;
hints[what] = hint;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function getLeft(obj) {
 var left = 0;
 while (obj) {
  left += obj.offsetLeft;
  obj = obj.offsetParent;
 }
 return left;
}
function getTop(obj) {
 var top = 0;
 while (obj) {
  top += obj.offsetTop;
  obj = obj.offsetParent;
 }
 return top;
}
function showHint(what) {
var h = document.getElementById('hint');
var hintText;
if (what.name != "") hintText = hints[what.name];
else hintText = hints[what];
if (!hintText) hintText = hints[what.name];
if (hintText && h) {
	h.childNodes[0].innerHTML = hintText;
	h.style.left = (getLeft(what)+what.offsetWidth+8)+'px';
	h.style.top = (getTop(what)/*+what.offsetHeight+5*/)+'px';
	h.style.display = "inline";
}
}
function hideHint() {
var h = document.getElementById('hint');
h.style.display = "none";
}
function addHintEvents(obj) {
	if (!obj) return;
	if (typeof obj.onmouseover != 'function') obj.onmouseover = function () {
				showHint(this);
			}
	if (typeof obj.onfocus != 'function') obj.onfocus = function () {
				showHint(this);
			}
	if (typeof obj.onmouseout != 'function') obj.onmouseout = function () {
				hideHint();
			}
	if (typeof obj.onblur != 'function') obj.onblur = function () {
				hideHint();
			}
}
function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		addHintEvents(inputs[i]);
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		addHintEvents(selects[k]);
	}
	var other = hintObjects;
	for (var l=0; l<other.length; l++) {
		if (typeof other[l] != 'string') {
			addHintEvents(other[l]);
		}
		else {
			// addHintEvents(document.getElementById(other[l]));
		}
	}
}

function g(id) {
return document.getElementById(id);
}

function vaheta(valik, id) {
 for (var i=0; i<valik.length; i++) {
   if (valik.options[i].value == id) valik.selectedIndex = i;
 }
}

function menyy(mis) {
 if (mis.options[mis.selectedIndex].value != '') {
   return mis.options[mis.selectedIndex].text
 }
 else return '';
}

