function otvor (theURL,wx,wy,okno) {
	mx = Math.round((screen.width-wx)/2);
	if (okno=='') okno='tab';
	window.open(theURL,okno,"width="+wx+",height="+wy+",toolbar=no,directories=no,scrollbars=yes,location=no,resizable=yes,menubar=no,left="+mx+",top=10").focus();
}

function otvor_search (theURL,wx,wy) {
	mx = Math.round((screen.width-wx)/2);
	tab = window.open(theURL,"search","width="+wx+",height="+wy+",toolbar=no,directories=no,scrollbars=yes,location=no,resizable=yes,menubar=no,left="+mx+",top=10");
	if (tab) tab.focus();
}
function checksearch (form) {
	var q = form.q.value;
	otvor_search('../hladaj/search.php?ps=20&wm=sub&q=' +q+'&cat=',750,550);
	return false;
}

var actual_chng_box;
	var actBox;
	var boxes = 3;
	function chng_load(){//sets first box visible
		var maxHeight = 100;
		boxes--;
		box = new Array(3);
		for (i=0;i<=boxes;i++) {//zistujem najvyssi div
			boxId = document.getElementById('chng_box_content_' + (i+1));
			boxHeight=boxId.offsetHeight;		
			if (maxHeight < boxHeight) maxHeight=boxHeight;		
			boxId.style.display='none'; 					
			document.getElementById('chng_box_zal_' + (i+1)).style.background='url(../images/chng_'+(i+1)+'.gif)'; 
   			
			
		}		
		for (i=0;i<=boxes;i++) {//zvacsim vsetky na najvyssi aby neskakal obsah pod nim
			boxId = document.getElementById('chng_box_content_' + (i+1))
			boxId.style.height = maxHeight;
		}	
	
		actual_chng_box = document.getElementById('chng_box_zal_1');
		actual_chng_box.style.backgroundPosition='0px -33px';			
		actBox = document.getElementById('chng_box_content_1');
		actBox.style.display="block";		
		
		
							
	}	
	
	function chng_box(targt){
		if (actual_chng_box!=targt) {
			targt.style.backgroundPosition='0px -33px';				
			actual_chng_box.style.backgroundPosition='0px 0px';					
			actual_chng_box = targt; 
			}			
		cntBox = document.getElementById('chng_box_content_'+targt.id.substr(13));
		actBox.style.display="none";
		cntBox.style.display="block";
		actBox = cntBox;		
	}
	
	function box_event(targt,act){
		target=document.getElementById(targt);
		image = document.getElementById('img_' + targt);
		
		if (act == 'minmax') {		
			if (target.style.display=='none') {	target.style.display='';
												image.src='../images/box_minimize.gif';
												}				
			else {	target.style.display='none';
					image.src = '../images/box_maximize.gif';
 				 }	
		}
		//neviem, ci by sa close nemalo robit na refresh aby sa to mohlo zapisat do DB
		if (act == 'close') target.style.display='none'; 
	
	}

function SitemapOpenClose(elNum, imgMain) {	
	if (elNum != '')
	{
		var image;
		var list = document.getElementById ? document.getElementById('submenu'+elNum) : document.all['submenu'+elNum];
		if (imgMain) image = document.getElementById ? document.getElementById('mainimage'+elNum) : document.all['mainimage'+elNum];
		else image = document.getElementById ? document.getElementById('subimage'+elNum) : document.all['subimage'+elNum];
		if (list)
		{
			if (list.style.display == 'none')
			{
				list.style.left = '';
				list.style.position = '';
				list.style.display = '';
				if (image)
				{
					if (imgMain) image.src = '../images/sitemap_minus.gif';
					else image.src = '../images/sitemap_minus.gif';
				}
	//			alert('if - list: '+list.style.display+'; image: '+image.src);
			}
			else
			{
				list.style.left = '-1000px';
				list.style.position = 'absolute';
				list.style.display = 'none';
				if (image)
				{
					if (imgMain) image.src = '../images/sitemap_plus.gif';
					else image.src = '../images/sitemap_plus.gif';
				}
//				alert('else - list: '+list.style.display+'; image: '+image.src);
			}
//			alert(list.style.position);
		}
	}
}

function SitemapOpenCloseAll(openMap)
{
	if (openMap)
	{
		var position = '';
		var left = '';
		var display = '';
		var imgSrcMain = '../images/sitemap_minus.gif';
		var imgSrcSub = '../images/sitemap_minus.gif';
	}
	else
	{
		var position = 'absolute';
		var left = '-1000px';
		var display = 'none';
		var imgSrcMain = '../images/sitemap_plus.gif';
		var imgSrcSub = '../images/sitemap_plus.gif';
	}
	var element = document.getElementsByTagName("UL");
	for(var i = 0; i < element.length; i++)
	{
		if (element[i].className.indexOf('menu_list') == -1 && element[i].id != 'top_table')
		{
			element[i].style.position = position;
			element[i].style.left = left;
			element[i].style.display = display;
		}
	}
	var image = document.getElementsByTagName("IMG");
	for(var i = 0; i < image.length; i++)
	{
		if (image[i].id.indexOf("subimage") > -1)
		{
			image[i].src = imgSrcSub;
		}
		else if (image[i].id.indexOf("mainimage") > -1)
		{
			image[i].src = imgSrcMain;
		}
	}
}

/*
function dictinary_tooltip(elmId, show) {
	var elm = document.getElementById('dictionary-holder-'+elmId);
	if (elm) {
		elm.style.left = '100px';
		elm.style.top = '100px';
		if (show) elm.style.display = 'block';
		else elm.style.display = 'none';
	}
}*/

/* tooltip pre Slovnik pojmov */
var DH = 0;
var an = 0;
var al = 0;
var ai = 0;
if (document.getElementById) {
	ai = 1;
	DH = 1;
} else {
	if (document.all) {
		al = 1;
		DH = 1;
	} else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			an = 1;
			DH = 1;
		}
	}
}
function fd(oi, wS) {
	if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi);
	if (al) return wS ? document.all[oi].style: document.all[oi];
	if (an) return document.layers[oi];
}
function pw() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}
function mouseX(evt) {
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
	else return null;
}
function mouseY(evt) {
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	else return null;
}
function dictinary_tooltip(evt,oi) {
	oi = 'dictionary-holder-'+oi;
	if (DH) {
		var wp = pw();
		ds = fd(oi,1);
		dm = fd(oi,0);
		st = ds.visibility;
		if (dm.offsetWidth) {
			while (dm.offsetWidth/dm.offsetHeight <= 4/3) {
				//alert(dm.offsetWidth);
				//alert(dm.offsetHeight);
				dm.style.width = (dm.offsetWidth+20)+'px';
			}
			ew = dm.offsetWidth;
		} else if (dm.clip.width) ew = dm.clip.width;
		if (st == "visible" || st == "show") {
			ds.visibility = "hidden";
		} else {
			tv = mouseY(evt) + 20;
			lv = mouseX(evt) - (ew/4);
			if (lv < 2) lv = 2;
			else if (lv + ew > wp) lv -= ew/2;
			if (!an) {
				lv += 'px';
				tv += 'px';
			}
			ds.left = lv;
			ds.top = tv;
			ds.visibility = "visible";
		}
	}
}

function tv(ver) {
	var sep;
	var loc = window.location.toString();
	if (loc.indexOf('#') > -1) loc = loc.substr(0, loc.indexOf('#'));
	if (loc.indexOf('set_subframe') > -1) loc = loc.substr(0, loc.indexOf('set_subframe')-1);
	if (loc.indexOf('?') > -1) sep = '&';
	else sep = '?';
	if (!ver) ver = '';
	window.location = loc + sep + 'set_subframe='+ver;
	return false;
}