/**
 *  Presmeruvava na vybranu sekciu.
 *  Vyuziva sa v hornej navigacii so select boxom.
 */
function changeSection(host) 
{
	box=document.forms["sections_nav"].section;
	destination=host+"/szukaj?keyword="+box.options[box.selectedIndex].value;
	if (destination) location.href=destination;
}
function changeSection2(host) 
{
	box=document.forms["special_section"].section;
	destination=host+"/"+box.options[box.selectedIndex].value;
	if (destination) location.href=destination;
}		  
/**
 *  Meni formular medzi instituciou a osobu-pri kto je kto
 */
function changeForm(host)
{
	box=document.forms['ipform'].ftype;
	destination=host+box.options[box.selectedIndex].value;
	if (destination) location.href=destination;
}
/**
 *  Meni adresu pri vybrani sortovanie clankov alebo eventov z nejakej sekcie.
 *  Vyuziva sa koli zmene partnerov na pravo, aby sa zobrazili partnery vybranej sekcie.
 */
function filterButtonChange(host)
{
	box=document.forms['navigation'];		  
	if (box) {
  	asection=box.asection.value;
  	type=box.atype.value;
  	section=box.section.options[box.section.selectedIndex].value;
  	mounth=box.mounth.options[box.mounth.selectedIndex].value;
  	year=box.year.options[box.year.selectedIndex].value;
  	if (section == "") {
  		section="all";
  	}			  
    if (asection == "agenda") {
      destination=host+"/"+asection+"/"+section+"/"+mounth+"/"+year;
    } 
    else {
  	  if (section == "all") {
         destination=host+"/"+"archiwum"+"/pokazac/"+type+"/"+section+"/"+mounth+"/"+year 
 			} 
 			else {
          destination=host+"/"+"archiwum"+"/pokazac/"+type+"/"+section+"/"+mounth+"/"+year
  		}
  	}
  	if (destination) location.href=destination;
	}
}
/**
 * Prida stranku do oblubenych
 */
function addToFavourites(site,title)
{
  NS4=(document.layers) ? 1 : 0;
  IE4=(document.all) ? 1 : 0;
  if (IE4 && !NS4) {	
    window.external.AddFavorite(site,title);
  }
	else {	
    alert('You must have IE 5.0 or higher for this service');
	}
}
		  
function findPosY(obj)
{
  var curtop=0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curtop += obj.offsetTop
      obj=obj.offsetParent;
	 }
	}
	else if (obj.y)
    curtop += obj.y;
	return curtop;
}

function findPosX(obj)
{
  var curleft=0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curleft += obj.offsetLeft
		  obj=obj.offsetParent;
		}
	}
	else if (obj.x)
    curleft += obj.x;
	return curleft;
}
/**
 *  Zobrazuje a skryva element.
 */
function showTable(table, linka) {
  t=document.getElementById(table);
  caption=document.getElementById(table+'_caption');
	link=document.getElementById(linka);
	t.style.left=findPosX(link)+'px' ;
	t.style.top=findPosY(link)+20+'px'; 
	if (t.style.visibility == "visible") {
    t.style.visibility="hidden";
    caption.style.visibility="hidden";
    caption.style.cursor="normal";
	} else {
    t.style.visibility="visible";
    caption.style.visibility="visible";
    caption.style.cursor="move";
	}
}	  
/*
 *  posuvanie tabuliek
 */

var tempY=0;
var tempX=0;
var posY=0;
var posX=0;

var adjuststate=0;
var tempA=0;
var tempB=0;
var tempC=0;
var tempD=0;

var y=0;
var x=0;
var topPos=0;
var leftPos=0;
var offsetPosY=0;
var offsetPosX=0;
var mouseoffset=0;
var mouseoffset2=0;

var curKnownPos=0;
var currentslider=null;


function getMouseXY(e) {		  	
  if(navigator.appName == "Netscape"){
    tempX=e.pageX;
		tempY=e.pageY;
  } else {
    tempX=window.event.clientX+window.document.body.scrollLeft;
		tempY=window.event.clientY+window.document.body.scrollTop;
	}
	if (tempX <= 0) {tempX=0}
  if (tempY <= 0) {tempY=0}
  posX=tempX;
  posY=tempY;
	if (adjuststate == 1) {
    topPos=parseFloat(document.getElementById(currentslider).style.top);
    leftPos=parseFloat(document.getElementById(currentslider).style.left);
		tempB=tempA;
		tempA=posY;
    tempD=tempC;
		tempC=posX;
    mouseoffset=tempB-topPos;
    offsetPosY=posY-mouseoffset;
    mouseoffset2=tempD-leftPos;
    offsetPosX=posX-mouseoffset2;
    y=posY-tempB;
		x=posX-tempD;
		if (y>1) y=1;
		if (y<-1) y=-1;
    document.getElementById(currentslider).style.top=offsetPosY+'px';
    document.getElementById(currentslider).style.left=offsetPosX+'px';
	}
	return true
}
function captureStart(slider, state){
  currentslider=slider;
  adjuststate=state;
  if (adjuststate == 0){
    adjuststate=1;
		tempA=posY;
		tempC=posX;
	} else {
    adjuststate=0;
	}
}

//document.onmousemove=setTimeout("getMouseXY()", 3000);

/*
 *
 *  Zmena velkosti prisma
 *  pouziva sa pri clankoch a roznych detailoch
 *
 */		  
/* aktualny krok pri meneni velkosti */
var actual=1;		  
/* 
 *  pole objektov ktorych velkosti sa menia
 *  0-id objektu
 *  1-zakladna velkost
 *  2-minimalna velkost
 *  3-maximalna velkost
 */
var ch_obj=Array();		  
/**
 * Prida objekt s danymy parametrami k objektom ktorych velkost sa bude menit.
 */
function setRes(id, init, min, max) 
{
	actual=1;
	if (!ch_obj) ch_obj=Array();
	ch_obj[ch_obj.length]=Array(id, init, min, max);
}

/**
 *  Zvecsi alebo zmensi nastavene objekty o danu hodnotu.
 */
function resize(size) 
{
  	actual=actual+size;
	if (!refresh()) actual=actual-size;
	return true;
}
/**
 *  Refreshe na stranke velkosti pouzivanych objektov.
 */
function refresh() 
{
	changed=false; 
	for (i=0; i < ch_obj.length; i++) 
  	{
    	o=document.getElementById(ch_obj[i][0]);
    	init=ch_obj[i][1];
    	min =ch_obj[i][2];
		max =ch_obj[i][3];
		step=ch_obj[i][4];
    	size=init+(actual-1);
		if (size<=max && size>=min) {
		  o.style.fontSize=size+'px';
			if (size>15) o.style.lineHeight=1.5;
			else o.style.lineHeight=1.4;
			changed=true;
		}
	}		  
	return changed;
}
		  
var show=true;

function showWord(pop, anchor) {
  show=true;
  a=document.getElementById(anchor);
  p=document.getElementById(pop);
  p.style.top=findPosY(a)+15+"px";
  p.style.left=findPosX(a)+"px";	  	  
  p.style.visibility="visible";
}
function hideWord(pop) {
  show=false;
  wTimer=window.setTimeout("hm('"+pop+"')",30); 
}		  
function hm(pop) {
  if (!show) {
    p=document.getElementById(pop);
    p.style.visibility="hidden";
	}
}
