// Funkcia pre odstranenie medier, novych riadkov na konci a zaciatku stringu
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
// Odtranenie znakov z cisla, zmena znaku ',' na znak '.' ako oddelovat desatinnych miest
//String.prototype.toFloat = function(b) { if (this.length>0) { var value = this.replace(/[,]/g,'.').replace(/[^0-9.\-]/g,'').replace('.',',').replace('-','min').replace(/[.]/g,'').replace(/[,]/g,'.').replace('-','').replace('min','-'); if (value=='-' || value=='') value='0'; if (b) { this = value } return value; } else { if (b) {this = ''; } return ''; } };
//String.prototype.toInteger = function(b) { if (this.length>0) { var value = this.toFloat(); if (value.indexOf('.')>-1) value=value.substring(0,value.indexOf('.')); if (b) { this = value; } return value; else { if (b) { this = ''; } return ''; } }
String.prototype.toFloat = function(b) { if (this.length>0) { var value = this.replace(/[,]/g,'.').replace(/[^0-9.\-]/g,'').replace('.',',').replace('-','min').replace(/[.]/g,'').replace(/[,]/g,'.').replace('-','').replace('min','-'); if (value=='-' || value=='') value='0'; if (b) {  } return parseFloat(value); } else { if (b) {  } return ''; } };
String.prototype.toInteger = function(b) { if (this.length>0) { var value = this.toFloat().toString(); if (value.indexOf('.')>-1) value=value.substring(0,value.indexOf('.')); if (b) {  } return parseInt(value); } else { if (b) {  } return ''; } }
Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "" : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); };
String.prototype.toMoney = function(c,d,t) { if(this.trim().length>0) { return parseFloat(this.trim().toFloat()).formatMoney(c,d,t); } else { return ''; } }
Number.prototype.toMoney = function(c,d,t) { return this.formatMoney(c,d,t); }
function monetary(b) {
	var r = Math.round(b*100)/100;var rr=r.toString().split('.');
	if(
			rr.length==1 ||
			rr[1].length==0){
		rr[1]='00'};
	if (rr[1].length==1){
		rr[1]+='0';}
	return rr[0]+'.'+rr[1];
}
var current = 1;
function isset(varname) {
	return eval('typeof('+ varname + ') != "undefined"');
}
function my_dump(value) {
	window.prompt('DUMP: ',value);
}

function ask(question,default_answer) {
	if (typeof default_answer=='string') {
		var predefined = default_answer 
	} else {
		var predefined = '';
	}
	var return_value = window.prompt(question,predefined);
	if (typeof return_value=='string') {
		if (return_value.length>0 && return_value.trim().length>0) {
			return return_value.trim();
		} else {
			return ask(question);
		}
	} else {
		if (return_value == null) {
			return ask(question);
		} else {
			return false;
		}
	}
}

function openImage(cesta) {
	var image_win = create_win(cesta);
	if (image_win) {
		image_win.focus();
		var imageWidth = 600;
		var imageHeight = 400;
		try {
			imageWidth = image_win.document.images[0].width;
			imageHeight = image_win.document.images[0].height;
		} catch(e) {
		}
		imageWidth+=20;
		imageHeight+=40;
		image_win.resizeTo(imageWidth, imageHeight); 
		return false;
	} else {
		return true;
	}
}
var window_count=0;
function create_win(loc,width,height,scroll,allways_open) {
	if (!(width>0)) {
		width = 300;
	}
	if (!(height>0)) {
		height = 300;
	}
	if (scroll==true) {
		scroll_int=1;
	} else {
		scroll_int=0;
	}
	var okno = open_win(loc,width,height,0,0,0,0,0,scroll_int,0,0,5,'win'+(window_count++));
	if (!okno) {
		if (allways_open!=false) {
			location = loc;
		}
		return false;
	} else {
		return okno;
	}
}
/* windowopen.js (function open_win) V 1.0 copyright Andrew Holt  This script is free to use provided this notice remains. Full instructions can be found @ http://www.webdevtips.com/webdevtips/js/openwindow.shtml */
function open_win(what_link,the_x,the_y,toolbar,addressbar,directories,statusbar,menubar,scrollbar,resize,history,pos,wname){ 
	var the_url = what_link;
	the_x -= 0;
	the_y -= 0;
	var how_wide = screen.availWidth;
	var how_high = screen.availHeight;
	if(toolbar == "0") {
		var the_toolbar = "no";	
	} else {
		var the_toolbar = "yes";
	}
	if(addressbar == "0"){
		var the_addressbar = "no";
	}else{
		var the_addressbar = "yes";	
	}
	if(directories == "0"){
		var the_directories = "no";
	}else{
		var the_directories = "yes";
	}
	if(statusbar == "0"){
		var the_statusbar = "no";
	}else{
		var the_statusbar = "yes";
	}
	if(menubar == "0"){
		var the_menubar = "no";
	}else{
		var the_menubar = "yes";
	}
	if(scrollbar == "0"){
		var the_scrollbars = "no";
	}else{
		var the_scrollbars = "yes";
	}
	if(resize == "0"){
		var the_do_resize =  "no";
	}else{
		var the_do_resize = "yes";
	}
	if(history == "0"){
		var the_copy_history = "no";
	}else{
		var the_copy_history = "yes";
	}
	top_pos=0;left_pos=0;
	if(pos == 1){
		top_pos=0;left_pos=0;
	}
	if(pos == 2){
		top_pos = 0;left_pos = (how_wide/2) -  (the_x/2);
	}
	if(pos == 3){
		top_pos = 0;left_pos = how_wide - the_x;
	}
	if(pos == 4){
		top_pos = (how_high/2) -  (the_y/2);left_pos = 0;
	}
	if(pos == 5){
		top_pos = (how_high/2) -  (the_y/2);left_pos = (how_wide/2) -  (the_x/2);
	}
	if(pos == 6){
		top_pos = (how_high/2) -  (the_y/2);left_pos = how_wide - the_x;
	}
	if(pos == 7){
		top_pos = how_high - the_y;left_pos = 0;
	}
	if(pos == 8){
		top_pos = how_high - the_y;left_pos = (how_wide/2) -  (the_x/2);
	}
	if(pos == 9){
		top_pos = how_high - the_y;left_pos = how_wide - the_x;
	}
	if (window.outerWidth ){
		var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
		wname=window.open(the_url, wname, option);
	} else {
		var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
		if (!wname.closed && wname.location){
			wname.location.href=the_url;
		} else {
			wname=window.open(the_url, wname, option);
			//wname.resizeTo(the_x,the_y);
			wname.focus();
			wname.location.href=the_url;
		}
	}
	return wname;
}
var change_display_timeouts = new Array();
function changeDisplay(name,hide,timeout) {
	var visibility = "";
	if (hide) {
		visibility = "none";
	} else {
		window.clearTimeout(change_display_timeouts[name]);
	}
	timeout=timeout*1;
	if (timeout>0) {
      change_display_timeouts[name] = window.setTimeout("changeDisplay('"+name+"','"+!hide+"')",timeout);
	}
	var obj = xGetElementById(name);
	if (obj) {
		obj.style.display = visibility;
	}
}
function changeClass(name,which) {
	var obj = xGetElementById(name);
	if (obj) {
		obj.className = which;
	}
}
// http://4umi.com/web/javascript/array.js
// Standard functions

// Array.concat() - Join two arrays
if( typeof Array.prototype.concat==='undefined' ) {
 Array.prototype.concat = function( a ) {
  for( var i = 0, b = this.copy(); i<a.length; i++ ) {
   b[b.length] = a[i];
  }
  return b;
  };
}

// Array.copy() - Copy an array
if( typeof Array.prototype.copy==='undefined' ) {
 Array.prototype.copy = function() {
  var a = [], i = this.length;
  while(i) {
   i=i-1;
   a[i] = typeof this[i].copy!=='undefined' ? this[i].copy() : this[i];
  }
  return a;
 };
}

// Array.pop() - Remove and return the last element of an array
if( typeof Array.prototype.pop==='undefined' ) {
 Array.prototype.pop = function() {
  var b = this[this.length-1];
  this.length=this.length-1;
  return b;
 };
}

// Array.push() - Add an element to the end of an array, return the new length
if( typeof Array.prototype.push==='undefined' ) {
 Array.prototype.push = function() {
  for( var i = 0, b = this.length, a = arguments, l = a.length; i<l; i++ ) {
   this[b+i] = a[i];
  }
  return this.length;
 };
}

// Array.shift() - Remove and return the first element
if( typeof Array.prototype.shift==='undefined' ) {
 Array.prototype.shift = function() {
  for( var i = 0, b = this[0], l = this.length-1; i<l; i++ ) {
   this[i] = this[i+1];
  }
  this.length=this.length-1;
  return b;
 };
}

// Array.slice() - Copy and return several elements
if( typeof Array.prototype.slice==='undefined' ) {
 Array.prototype.slice = function( a, c ) {
  var i, l = this.length, r = [];
  if( !c ) { c = l; }
  if( c<0 ) { c = l + c; }
  if( a<0 ) { a = l - a; }
  if( c<a ) { i = a; a = c; c = i; }
  for( i = 0; i < c - a; i++ ) { r[i] = this[a+i]; }
  return r;
 };
}

// Array.splice() - Remove or replace several elements and return any deleted elements
if( typeof Array.prototype.splice==='undefined' ) {
 Array.prototype.splice = function( a, c ) {
  var i = 0, e = arguments, d = this.copy(), f = a, l = this.length;
  if( !c ) { c = l - a; }
  for( i; i < e.length - 2; i++ ) { this[a + i] = e[i + 2]; }
  for( a; a < l - c; a++ ) { this[a + e.length - 2] = d[a - c]; }
  this.length -= c - e.length + 2;
  return d.slice( f, f + c );
 };
}

// Array.unshift() - Add an element to the beginning of an array
if( typeof Array.prototype.unshift==='undefined' ) {
 Array.prototype.unshift = function() {
  this.reverse();
  var a = arguments, i = a.length;
  while(i) { i=i-1; this.push(a[i]); }
  this.reverse();
  return this.length;
 };
}

// 4umi additional functions

// Array.forEach( function ) - Apply a function to each element
Array.prototype.forEach = function( f ) {
 var i = this.length, j, l = this.length;
 for( i=0; i<l; i++ ) { if( ( j = this[i] ) ) { f( j ); } }
};

// Array.indexOf( value, begin, strict ) - Return index of the first element that matches value
Array.prototype.indexOf = function( v, b, s ) {
 for( var i = +b || 0, l = this.length; i < l; i++ ) {
  if( this[i]===v || s && this[i]==v ) { return i; }
 }
 return -1;
};

// Array.insert( index, value ) - Insert value at index, without overwriting existing keys
Array.prototype.insert = function( i, v ) {
 if( i>=0 ) {
  var a = this.slice(), b = a.splice( i );
  a[i] = v;
  return a.concat( b );
 }
};

// Array.lastIndexOf( value, begin, strict ) - Return index of the last element that matches value
Array.prototype.lastIndexOf = function( v, b, s ) {
 b = +b || 0;
 var i = this.length; while(i>b) {
 	i=i-1;
	if( this[i]===v || s && this[i]==v ) { return i; }
 }
 return -1;
};

// Array.random( range ) - Return a random element, optionally up to or from range
Array.prototype.random = function( r ) {
 var i = 0, l = this.length;
 if( !r ) { r = this.length; }
 else if( r > 0 ) { r = r % l; }
 else { i = r; r = l + r % l; }
 return this[ Math.floor( r * Math.random() - i ) ];
};

// Array.shuffle( deep ) - Randomly interchange elements
Array.prototype.shuffle = function( b ) {
 var i = this.length, j, t;
 while( i ) {
  j = Math.floor( ( i ) * Math.random() );
  i=i-1;
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }
 return this;
};

// Array.unique( strict ) - Remove duplicate values
Array.prototype.unique = function( b ) {
 var a = [], i, l = this.length;
 for( i=0; i<l; i++ ) {
  if( a.indexOf( this[i], 0, b ) < 0 ) { a.push( this[i] ); }
 }
 return a;
};

// Array.walk() - Change each value according to a callback function
Array.prototype.walk = function( f ) {
 var a = [], i = this.length;
 while(i) { i=i-1; a.push( f( this[i] ) ); }
 return a.reverse();
};
/**
 *  Priradi urcite udalosti objektu zadanou obsluznou funkci. Rozhodne
 *  automaticky, zda pouzit attachEvent, nebo addEventListener. Resi problem
 *  s pouzitim this uvnitr obsluzne funkce.
 *  @param obj Objekt, u nehoz chceme udalost obsluhovat.
 *  @param event Udalost, jiz hodlame obslouzit - ve formatu click, load apod.
 *               (nikoliv onclick, onload).
 *  @param funct Nazev obsluzne funkce.
 */
function addEvent(obj, event, funct) {
  if (obj.attachEvent) { //IE
    obj['e' + event + funct] = funct;
    obj['x' + event + funct] = function() {
          obj['e' + event + funct](window.event);
        }
    obj.attachEvent('on' + event, obj['x' + event + funct]);
  } else // other browser
    obj.addEventListener(event, funct, false);
}
/**
 *  Odstrani zadanou obsluznou funkci registrovanou u objektu.
 *  @param obj Objekt, u nehoz chceme obsluznou funkci odstrani.
 *  @param event Udalost, jiz doposud funkce obsluhovala - ve formatu click,
 *               load apod. (nikoliv onclick, onload).
 *  @param funct Nazev obsluzne funkce, jiz planujeme odstranit.
 */
function removeEvent(obj, event, funct) {
  if (obj.detachEvent) { // IE
    obj.detachEvent('on' + event, obj[event + funct]);
    obj['x' + event + funct] = null;
  } else // other browser
    obj.removeEventListener(event, funct, false );
}
function checkvalue(obj) {
	checked = false;
	if (obj.length && obj.length>1) {
		for(j=0;j<obj.length;j++) {
			if (obj[j].checked) {
				checked = true;
			}
		}
	} else {
		if(obj.checked!=undefined) {
			checked = obj.checked;
		}
	}
	return checked;
}
function getvalue(obj) {
	var values = new Array();
	checked = false;
	if (obj.length && obj.length>1) {
		var type = 'radio';
		for(j=0;j<obj.length;j++) {
			type = obj[j].type;
			if (obj[j].checked) {
				values[values.length]=obj[j].value;
			}
		}
		if (type=='radio') {
			if (values.length<1) {
				return null;
			} else {
				return values[0];
			}
		} else {
			return values;
		}
	} else {
		if(obj.checked!=undefined) {
			checked = obj.checked;
			if (checked==true) {
				values[values.length]=obj.value;
			}
		}
		if (values.length>0) {
			return values[0];
		} else {
			return null;
		}
	}
}
function getFormElement(formular,find_value,suffix,search_attribute) {
	if (!suffix) {
		suffix = '';
	}
	if (!search_attribute) {
		search_attribute = 'name';
	}
	var form = xGetElementById(formular);
	if (!form) {
		var form = eval('document.'+formular);
	}
	var i;
	var elements = new Array();
	for(i=0;i<form.elements.length;i++) {
		if (form.elements[i].getAttribute(search_attribute)==find_value) {
			if (form.elements[i].id.length>0) {
				var element = form.elements[i].id;
			} else {
				var element = form.elements[i].name;
			}
			elements[elements.length]=element+suffix;
		}
	}
	return elements;
}
// Replaces all instances of the given substring.
String.prototype.replaceAll = function(
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
 
	// Keep looping while an instance of the target string
	// still exists in the string.
	while (intIndexOfMatch != -1){
		// Relace out the current instance.
		strText = strText.replace( strTarget, strSubString )

		// Get the index of any next matching substring.
		intIndexOfMatch = strText.indexOf( strTarget );
	}
 
	// Return the updated string with ALL the target strings
	// replaced out with the new substring.
	return( strText );
}

function deleteTableColumn(table_id,column_order,reference_cell_id) {
	if (reference_cell_id.length>0 && column_order==false) {
		var cell = xGetElementById(reference_cell_id);
		if (cell) {
			var tds = cell.parentNode.getElementsByTagName('td');
			if (tds) {
				var i;
				for(i=0;i<tds.length;i++) {
					var id = tds.item(i).getAttribute('id');
					if (id==reference_cell_id) {
						column_order = i;
					}
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	}
	var table = xGetElementById(table_id);
	var trs = table.getElementsByTagName('tr');
	var i;
	for (i=0;i<trs.length;i++) {
		trs.item(i).removeChild(trs.item(i).getElementsByTagName('td').item(column_order));
	}
}
function MakeFirst() {
	var popup = document.getElementById('popup');
	var change = false;
	if (popup) {
		changePopup(true);
	}
	if (opener_location!='') {
		window.opener.location = opener_location;
		window.opener.focus();
		window.close();
	} else {
		if (!popup) {
			if (popup_action!='') {
				var akcia = time2msec(popup_action);
				var teraz = new Date();
				var hod = teraz.getHours();
				var min = teraz.getMinutes();
				var sec = teraz.getSeconds();
				var teraz_msec = time2msec(hod+':'+min+':'+sec);
				var akcia_o = (akcia - teraz_msec);
				setTimeout(function() {
					window.focus();
					teraz = new Date();
					min = teraz.getMinutes();
					if (min<10) {
						min = '0'+min.toString();
					}
					var cas = teraz.getHours()+':'+min;
					if (window.confirm('V denník je na '+cas+' akcia.\nÍsť na denník?')) {
						location='dennik.php?cas='+cas;
					}
				},akcia_o);
			}
		}
		if (db_status!='') {
			alert(db_status);
		}
		if (return_path!='') {
			location = return_path;
		}
	}
	if (typeof page_start!='undefined' && (typeof page_start=='function')) {
		page_start();
	}
}
// xAniOpacity r1, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xAniOpacity(e, o, t, a, oe)
{
  if (!(e=xGetElementById(e))) return;
  var o0 = xOpacity(e); // start value
  var dx = o - o0; // displacement
  var fq = 1 / t; // frequency
  if (a) fq *= (Math.PI / 2);
  var t0 = new Date().getTime(); // start time
  var tmr = setInterval(
    function() {
      var et = new Date().getTime() - t0; // elapsed time
      if (et < t) {
        var f = et * fq; // constant velocity
        if (a == 1) f = Math.sin(f); // sine acceleration
        else if (a == 2) f = 1 - Math.cos(f); // cosine acceleration
        f = Math.abs(f);
        xOpacity(e, f * dx + o0); // instantaneous value
      }
      else {
        clearInterval(tmr);
        xOpacity(e, o); // target value
        if (typeof oe == 'function') oe(); // 'onEnd' handler
        else if (typeof oe == 'string') eval(oe);
      }
    }, 10 // timer resolution
  );
}
// xGetElementById r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetElementById(e)
{
  if(typeof(e)=='string') {
    if(document.getElementById) e=document.getElementById(e);
    else if(document.all) e=document.all[e];
    else e=null;
  }
  return e;
}
// xOpacity r1, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xOpacity(e, o)
{
  var set = xDef(o);
  //  if (set && o == 1) o = .9999; // FF1.0.2 but not needed in 1.5
  if(!(e=xGetElementById(e))) return 2; // error
  if (xStr(e.style.opacity)) { // CSS3
    if (set) e.style.opacity = o + '';
    else o = parseFloat(e.style.opacity);
  }
  else if (xStr(e.style.filter)) { // IE5.5+
    if (set) e.style.filter = 'alpha(opacity=' + (100 * o) + ')';
    else if (e.filters && e.filters.alpha) { o = e.filters.alpha.opacity / 100; }
  }
  else if (xStr(e.style.MozOpacity)) { // Gecko before CSS3 support
    if (set) e.style.MozOpacity = o + '';
    else o = parseFloat(e.style.MozOpacity);
  }
  else if (xStr(e.style.KhtmlOpacity)) { // Konquerer and Safari
    if (set) e.style.KhtmlOpacity = o + '';
    else o = parseFloat(e.style.KhtmlOpacity);
  }
  return isNaN(o) ? 1 : o; // if NaN, should this return an error instead of 1?
}
// xDef r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
// xStr r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}
var xEventListeners = new Array(); // Zoznam ulozenych eventListenerov
function xRegisterEventListener(e,eT,eL,cap) {
	if(!(e=xGetElementById(e)))return;
	xEventListeners[xEventListeners.length] = [e,eT,eL,cap];
	xAddEventListener(e,eT,eL,cap);
}
function xCallEventListeners(e,eT) {
	if(!(e=xGetElementById(e)))return false;
	var ret = true;
	
	if (e['on'+eT]) {
		var sub_ret = e['on'+eT](); 
		ret = ret && sub_ret;
	}
	for(var i=0;i<xEventListeners.length;i++) {
		if (xEventListeners[i][0]==e && xEventListeners[i][1]==eT) {
			var f=xEventListeners[i][2];
			var sub_ret = f();
			ret = ret && sub_ret;
		}
	}
	return ret;
}
function xChangeValue(e,v) { // Zmeni hodnotu objektu a ked je na objekte definovane onchange alebo eventlistenery change, tak ich vykona
	if(!(e=xGetElementById(e)))return;
	e.value=v;
	return xCallEventListeners(e,'change');
}
// xAddEventListener r8, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xAddEventListener(e,eT,eL,cap)
{
  if(!(e=xGetElementById(e)))return;
  eT=eT.toLowerCase();
  if(e.addEventListener) {
  	e.addEventListener(eT,eL,cap||false);
  } else if(e.attachEvent) {
  		e.attachEvent('on'+eT,eL);
	} else {
		var o=e['on'+eT];
		e['on'+eT]=typeof o=='function' ? function(v){ o(v);eL(v);} : eL;
	}
}
// xScrollLeft r3, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xScrollLeft(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
    else if(w.document.body && xDef(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollLeft)) offset = e.scrollLeft;
  }
  return offset;
}
// xScrollTop r3, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xScrollTop(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
    else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}
// xNum r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xNum()
{
  // By spacesystems.sk: || arguments[i].toString().length==0
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number' || arguments[i].toString().length==0) return false;}
  return true;
}
// xPageX r2, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xPageX(e)
{
  var x = 0;
  e = xGetElementById(e);
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return x;
}
// xPageY r4, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xPageY(e)
{
  var y = 0;
  e = xGetElementById(e);
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return y;
}
function switchDisplay(name) {
	if (document.all) {
		var obj = eval('document.all.'+name);
	} else if (document.getElementById) {
		var obj = document.getElementById(name);
	}
	if (obj) {
		if (obj.style.display.toString()=='none') {
			changeDisplay(name);
		} else {
			changeDisplay(name,true);
		}
	}
}
function moneycomp(a,comp,b,decimals) { // Porovnavanie float premennych na decimals desatinnych miest, default 2
	if (!decimals)
		decimals = 2;
	var multiplier = Math.pow(10,decimals);
	a = Math.round(a * multiplier); // multiply to do integer comparison instead of floating point
	b = Math.round(b * multiplier);
	switch (comp) {
		case ">":
			return (a > b);
		case ">=":
			return (a >= b);
		case "<":
			return (a < b);
		case "<=":
			return (a <= b);
		case "==":
			return (a == b);
	}
	return null;
}
function markAll(attribute,value) {
	var form = $('formular');
	var elements = new Array();
	for(var i=0;i<form.elements.length;i++) {
		var attr = form.elements[i].getAttribute(attribute);
		if (attr==value) {
				form.elements[i].checked=true;
		}
	}
	return true;
}
function multipleselection_add(obj_name) {
	var selected = $(obj_name+'_not_selected').selectedIndex;
	if (selected>-1) {
		var obj_not = $(obj_name+'_not_selected');
		var obj_yes = $(obj_name+'_selected');
		if (!isNaN(obj_not[selected].value)) {
			var value = obj_not[selected].value;
			var text = obj_not[selected].text;
			var found = false;
			for (i=0;i<obj_yes.length;i++) {
				if (obj_yes[i].value == value ) {
					found = true;
				}
			}
			if (found===false) {
				var option = new Option(text,value);
				obj_yes[obj_yes.length]=option;
			}
	 	}
	}
	multipleselection_setvariable(obj_name);
}
function multipleselection_remove(obj_name) {
	var index = $(obj_name+'_selected').selectedIndex;
	if (index>-1) {
		$(obj_name+'_selected').remove(index);
	}
	multipleselection_setvariable(obj_name);
}
function multipleselection_setvariable(obj_name) {
	var objekty = '';
	var obj = $(obj_name+'_selected');
	for(i=0;i<obj.length;i++) {
		if (i>0) {
			objekty+=':';
		}
		objekty+= obj[i].value;
	}
	$(obj_name).value = objekty;
}
function updateFileNameObj(objFileName,objNameName) {
	var path = $(objFileName).value;
	path = path.split('\\')
	var last = path.pop(); 
	path = last.split('/')
	var last = path.pop(); 
	var orig = $(objNameName);
	var changed = false;
	if (orig.value.length==0) {
		orig.value = last;
		changed = true;
	} else {
		if (last!=orig.value && window.confirm('Zmena pôvodného názvu?')) {
			orig.value = last;
			changed = true;
		}
	}
//	if (changed == true) {
//		files_FileName = last;
//		updateNazovName();
//	}
}
function convert_to_textarea(obj,text,textarea_name,rows,cols,style) {
	if ($(obj)) {
		var obj_new = document.createElement('textarea');
		obj_new.setAttribute('rows',rows);
		obj_new.setAttribute('cols',cols);
		obj_new.setAttribute('style',style);
		obj_new.setAttribute('name',textarea_name);
		var obj_text = document.createTextNode(text.replace(/(\r\n|[\r\n])/g, "<br />"));
		$(obj).innerHTML='';
		obj_new.appendChild(obj_text);
		$(obj).appendChild(obj_new);
	}
}
