// JavaScript Document
/*** zakladni funkce ***/

function objGet(x) {
	if (typeof x != 'string') return x;
	else if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);  // pro MSIE 4
	else return null;
}

function objSetStyle (obj,prop,val) {
	var o = objGet(obj);
	if (o && o.style) {
		eval ('o.style.'+prop+'="'+val+'"');
		return true;
	}
	else return false;
}

function objShow (obj,on) {
	return objSetStyle(obj,'visibility',(on) ? 'visible':'hidden');
}

function objDisplay (obj,on,type) {
	if (on && !type) type = 'block';
	return objSetStyle(obj,'display',(on) ? type:'none');
}

// vrati vybrany (oznaceny) text na strance
// http://www.quirksmode.org/js/selected.html
function getSel(el) {
   var selection = false;
   var begin,selection,end;
   if (navigator.userAgent.toLowerCase().indexOf("firefox") > 0) {
      // firefox
      if (el.selectionStart!= undefined) {
         begin = el.value.substr(0, el.selectionStart);
         selection = el.value.substr(el.selectionStart, el.selectionEnd - el.selectionStart);
         end = el.value.substr(el.selectionEnd);
      }
   } else { 
      // other
      if (window.getselection){
         selection = window.getselection();
      } else if (document.selection) {
         selection = document.selection.createRange().text;
      } else if (document.getSelection) {
         selection = document.getSelection();
      }
   }
   return selection;
}

// incrementuje / decrementuje hodnotu ve vstupnim poli
function InputIncrem(inp_id) {
   AheadNum = parseInt(objGet(inp_id).value);
   objGet(inp_id).value = AheadNum + 1;
}
function InputDecrem(inp_id) {
   AheadNum = parseInt(objGet(inp_id).value);
   if(AheadNum > 0) {
      objGet(inp_id).value = AheadNum - 1;
   }
}

