function is_mozilla() {return navigator.userAgent.match('Gecko');}

/* -------------------------------------------------------------------------------------------------------------- */

function rs_popup(name,text,question,action)
{
	if (document.getElementById('popup_'+name)) {
		delete this;
		return null;
	}

	var div,action;
	
	this.kill = function() {
		document.body.removeChild(div);
	}

	div = document.createElement('div');
	div.setAttribute('id','popup_'+name);
	div.className = 'popup';

	var fix = false;
	var top = (!fix ? document.documentElement.scrollTop : document.body.scrollTop) + 100;
	if (is_mozilla()) {
		div.setAttribute('style','top: '+top+'px;');
	} else {
		div.style.top = top;
	}

	document.body.appendChild(div);
	
	var table,tr,td;

	div.innerHTML = '<table><tr><td>'+text+'<br><br><span id="table_'+name+'"></span></td></tr></table>';
	var td = document.getElementById('table_'+name);

	function create_link(text,func,cmd)
	{
		var a = document.createElement('a');

		if (is_mozilla()) {
			a.setAttribute('href','javascript:void(0);');
			if (cmd) a.setAttribute('onclick',cmd);
		} else {
			a.setAttribute('href','javascript:'+(cmd ? cmd : 'void(0);'));
		}
		addEvent(a,'click',func);
		a.appendChild(document.createTextNode(text));
		
		return a;
	}

	if (question){
		td.appendChild(create_link('ANO',this.kill,action));
		td.appendChild(document.createTextNode('  '));
		td.appendChild(create_link('NE',this.kill,null));
	} else {
		td.appendChild(create_link('OK',this.kill,null));
	}

	return this;
}

/* -------------------------------------------------------------------------------------------------------------- */

function floater(title,content,fix)
{
	var div;

	this.kill = function() {
		document.body.removeChild(div);
	}

	div = document.createElement('div');
	div.setAttribute('id','floater');
	
	var top = (!fix ? document.documentElement.scrollTop : document.body.scrollTop) + 120;	
	if (is_mozilla()) {
		div.setAttribute('style','top: '+top+'px;');
	} else {
		div.style.top = top;
	}
	
	var text = '<div class="title">'+title+'</div>'
	var a = content.split('|');
	for (i = 0;i < a.length;i++) {
		text += '<div class="'+(i % 2 == 0 ? 'even' : 'odd')+'">'+a[i]+'</div>';
	}

	div.innerHTML = text;
	
	document.body.appendChild(div);

	return this;
}

/* -------------------------------------------------------------------------------------------------------------- */

var fl = null;

function show_floater(nazov,obsah,fix)
{
	if (nazov == '') return;
	
	fl = new floater('Obchodní případ: '+nazov,obsah,fix);
}

function hide_floater()
{
	if (!fl) return;
	
	fl.kill();
	delete fl; fl = null;
}

/* -------------------------------------------------------------------------------------------------------------- */

function hint_handler(obj)
{
	var title = obj.title;
	
	this.show_hint = function() {
		return hint(title);
	}
	
	this.hide_hint = function() {
		return hint(null);
	}

	addEvent(obj,'mouseover',this.show_hint);
	addEvent(obj,'mouseout',this.hide_hint);

	return this;
}

function make_hints()
{
	var a = document.getElementsByTagName('a');
	var i;
	
	for (i = 0;i < a.length;i++) {
		if (a[i].title) new hint_handler(a[i]);
	}
}

