var KC = new function(){

	var ajax;
	var staticContainer = null;
	var hlaskyObal = null;
	var hlasky = null;

	var ERROR_OK = 1;
	var ERROR_ERROR = 0;
	var ERROR_FATAL = 2;
	var ERROR_NOTICE = 3;
	var ERROR_INFO = 4;
	var ERROR_PRUVODCE = 4;

	this.isFB = false;

	this.isIE = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;

	this.getEl = function(id){
	
		return document.getElementById(id);
	}

	this.akce = function(url){

	   if(!ajax) ajax = new Ajax();

	   url = KC.getAjaxURL(url);
	   
	   preloadStart();

	   ajax.send(zpracujAkci, url);

	   return false;
	}

	this.reloadMenu = function(){

	   this.akce('?reloadMenu=1');
	}

	this.zpracujAkci = zpracujAkci0;

	function zpracujAkci(){

		preloadStop();

		try{
	   	var data = ajax.get('responseJSON');
	   }catch(ex){
	      alert(ajax.get('responseText'));
	   }

	   zpracujAkci0(data);
	}

	function zpracujAkci0(data){

		var obnovitMenu = false;

		if(!data) return;

	   if(data.zmeny){


	      for(var i in data.zmeny){

				var el = document.getElementById(data.zmeny[i].id);
				var el_openWindow = document.getElementById('openWindow_' + data.zmeny[i].id);

				if(data.zmeny[i].id == '') obnovitMenu = true;

				if(!el && !el_openWindow) continue;

	      	for(var a in data.zmeny[i]){

				   if(a == 'id') continue;
				   var obsah = null;

				   if(a == 'outerHTML'){
	         		if(el) el.parentNode['innerHTML'] = data.zmeny[i]['outerHTML'];
	         		if(el_openWindow) el_openWindow.parentNode['innerHTML'] = data.zmeny[i]['outerHTML'];

	         		obsah = el.parentNode;

	         		continue;
				   }

				   if(a == 'style'){

		         	if(el) el.style.cssText = data.zmeny[i][a];
		         	if(el_openWindow) el_openWindow.style.cssText = data.zmeny[i][a];
		         	continue;
				   }
				   
				   if(a.indexOf('on') == 0){

				      //if(el) el[a] = function(){};
				      if(el) el.setAttribute(a, data.zmeny[i][a]);

				      //if(el_openWindow) el_openWindow[a] = function(){};
				      if(el_openWindow) el_openWindow.setAttribute(a, data.zmeny[i][a]);
				   
				   }else{

		         	if(el) el[a] = data.zmeny[i][a];
		         	if(el_openWindow) el_openWindow[a] = data.zmeny[i][a];
	         	
	         	}

				   if(a == 'innerHTML') obsah = el;

				   if(obsah) KC.evalScripts(obsah);

	         }
	      }
	   }


	   if(obnovitMenu) KC.reloadMenu();

	   if(data.zpravy){

	   	for(var i in data.zpravy){

				KC.hlaska(data.zpravy[i].typ, data.zpravy[i].zprava);
	      }
	   }

	   if(data.javascript){

	   	for(var i in data.javascript){

	   	   if(data.javascript[i].script){

	   	      var js = ''+data.javascript[i].script+'';

			   	with(window){
						eval(js);
					}
	   	      continue;
	   	   }

	   	   var script = document.createElement('script');
	   	   script.type = "text/javascript";
	   	   script.href = data.javascript[i].href;

	   	   document.body.appendChild(script);
	      }
	   }
	}

	this.evalScripts = function(obsah){

		var scripts = obsah.getElementsByTagName('script');

      for(var b = 0; b < scripts.length; b++){

         if(scripts[b].src){

	   	   var script = document.createElement('script');
	   	   script.type = "text/javascript";
	   	   script.src = scripts[b].src;

	   	   document.body.appendChild(script);

   	   }else{

	   	   var script = document.createElement('script');
	   	   script.type = "text/javascript";
				script.text = scripts[b].innerHTML;

	   	   document.body.appendChild(script);
   	   }
      }
	}

	this.addEvent = function(kam, udalost, funkce){

		if(kam.attachEvent){
			kam.attachEvent('on'+udalost, funkce);
		}else{
			kam.addEventListener(udalost, funkce, true);
		}
	}

	this.onDomReady = function(f){

		var f2 = function(){ //deklarace obalové funkce
		   if(arguments.callee.done) return; //zjisti zda-li byla funkce jiz volana
		   arguments.callee.done = true;
		   f(); // zavolá předanou funkci
		};

		//registrace funkci na udalosti

		if(document.attachEvent && !document.addEventListener){ // pro IE

			var t = new Date().getTime();
			var id = 'IE-ONDOMREADY-' + t + t*Math.random();

			document.write('<sc'+'ript type="text/javascript" id="'+id+'" src="javascript:void(0)" defer="defer"></sc'+'ript>');
   		var s = document.getElementById(id);
			var f3 = function(){
				if(s.readyState == 'complete') setTimeout(f2, 1);
			};
			s.attachEvent('onreadystatechange', f3);

		}else if(document.readyState && navigator.userAgent.indexOf("Safari") != -1){ // pro Safari

		   var i = setInterval(function(){

				if(document.readyState == 'complete' || document.readyState == 'loaded'){
				   f2();
					clearInterval(i);
				   i = null;
				}
			},10);
		}else{ // pro gecko

			document.addEventListener('DOMContentLoaded', f2, false);
		}

		if(window.addEventListener) window.addEventListener('load', f2, false); // pro ostatni
	};


	this.isDomReady = false;

	this.onDomReady(function(){

		KC.isDomReady = true;
	});

	this.getElementEvent = function(e){

		if(e.srcElement){
			return e.srcElement;
		}else{
			return e.target;
	  };
	};

	this.getElementsByAttribute = function(el, attr, value){

	   if(value !== undefined){

	   	if(attr == 'class' && el.getElementsByClassName) return el.getElementsByClassName(value);
	   	if(attr == 'id') return el.getElementById(value);
	   	if(attr == 'name') return el.getElementsByName(value);
		}

      //if(attr == 'class') attr = 'className';

		return getElementsByAttribute(el, attr, value);
	};

	function getElementsByAttribute(el, attr, value){

		var elementy = new Array();

		for(var i = 0; i < el.childNodes.length; i++){

		   //alert(el.childNodes[i].getAttribute);

			if(!el.childNodes[i].getAttribute) continue;
			if(el.childNodes[i].hasAttribute(attr)){

				if(value === undefined) elementy[elementy.length] = el.childNodes[i];
	   		else if(el.childNodes[i].getAttribute(attr) === value || el.childNodes[i].getAttribute(attr).search(new RegExp('\s'+value+'\s', 'i')) != -1) elementy[elementy.length] = el.childNodes[i];
	   	
	   	}


	   	if(el.childNodes[i].hasChildNodes()){

				var elem = getElementsByAttribute(el.childNodes[i], attr, value);

				for(var a = 0; a < elem.length; a++) elementy[elementy.length] = elem[a];
			}
	   }

	   return elementy;
	}

	this.setOpacity = function(co, kolik){

		/* CSS3		*/ co.style.opacity = kolik;
		/* linux KDE	*/ co.style.KhtmlOpacity = kolik;
		/* Mozilla	*/ co.style.Moz0pacity = kolik;
		/* MS IE	*/ co.style.filter = "Alpha(opacity=" + (kolik * 100) + ")";
		/* MS IE5.5+ DX	*/ co.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + (kolik * 100) + ")";

	}

	function ieDoc(){
	  return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
	};

	this.getCurX = function(e){
		return (e.pageX === undefined) ? e.clientX + ieDoc().scrollLeft : e.pageX;
	};

	this.getCurY = function(e){
		return (e.pageY === undefined) ? e.clientY + ieDoc().scrollTop : e.pageY;
	};

	this.getScrollX = function(el){

	   if(!el){
			if(window.scrollX == undefined) el = ieDoc();
			else el = window;
		}

	   return (el.scrollX == undefined)? el.scrollLeft : el.scrollX;
	};
	this.getScrollY = function(el){

	   if(!el){
			if(window.scrollY == undefined) el = ieDoc();
			else el = window;
		}

	   return (el.scrollY == undefined)? el.scrollTop : el.scrollY;
	};

	this.getPosition = function(pole, typ){

		var pozice = 0;
		var pole0 = pole;

		while(pole){

			pozice += (pole[typ]) ? pole[typ] : 0;
			pole = pole.offsetParent;
		}

		return pozice;
	};

	this.windowOpen = function(url, target, width, height, param){

		if(!param) param = '';

		var leftVal = (screen.width - width) / 2 - 100;
		var topVal = (screen.height - height) / 2 - 50;

		if(leftVal < 0) leftVal = 0;
		if(topVal < 0) topVal = 0;

		param = 'left='+leftVal+',top='+topVal+',width='+width+',height='+height+',scrollbars=1,'+param;


	   var w = window.open(url, target, param);

	   w.focus();

	   return w;
	}

	this.skryjHeslo = function(el, skryt){

	   if(!el.tagName) el = document.getElementById(el);

	   if(skryt) el.type = 'password';
	   else el.type = 'text';

	   el.focus();
	}

	this.hlaska = function(typ, zprava){

		if(!hlasky){

		   hlaskyObal = document.createElement('div');
		   hlaskyObal.style.cssText = 'position:absolute; left:0px; top:0px; width:100%;';

			hlasky = document.createElement('div');
			hlaskyObal.appendChild(hlasky);
			staticContainer.appendChild(hlaskyObal);

			hlasky.className = 'hlasky';
		}

		while(hlasky.hasChildNodes()) hlasky.removeChild(hlasky.firstChild);

		var d = document.createElement('div');

		if(hlasky.firstChild) hlasky.insertBefore(d, hlaskyObal.firstChild);
		else hlasky.appendChild(d);

		d.className = 'hlaska';
		d.innerHTML = zprava;

		d.onclick = function(){

			this.parentNode.removeChild(this);
		}
		
		var pos = -50;
		d.style.cssText = 'position:relative; top:'+pos+'px;';
		
		(function(){

			d.style.top = pos+'px';
			
			if(pos == 0) return;
		   pos += 5;
			
			setTimeout(arguments.callee, 30);
		})();

		if(typ == ERROR_OK) KC.errorEfekt(d, '00ff00', 'ccffcc');
		else if(typ == ERROR_ERROR) KC.errorEfekt(d, '0000ff', '0033ff');
		else if(typ == ERROR_PRUVODCE) KC.errorEfekt(d, 'ffffff', 'ffffff');
		else KC.errorEfekt(d, 'ff0000', '00ffff');
	}
	
	var preload_pocet = 0;
	var preloader = document.createElement('div');
	preloader.className = 'preloader';
	this.setOpacity(preloader, 0.9);

	var preloaderObal = document.createElement('div');
	preloaderObal.className = 'preloaderObal';
	preloaderObal.appendChild(preloader);
	
	function preloadStart(){

		if(preload_pocet == 0) staticContainer.appendChild(preloaderObal);
	   preload_pocet++;
	}
	
	function preloadStop(){
	
	   preload_pocet--;
	   
	   if(preload_pocet == 0) staticContainer.removeChild(preloaderObal);
	}

	this.preloadStart = preloadStart;
	this.preloadStop = preloadStop;

	this.errorEfekt = function(el, color1, color2){

	   var pocet = 0;

	   new KC.zmenaBarvy(el, 'backgroundColor', color1, color2, 2000, 0);

	   (function(){

	      if(pocet > 10){

				return;
	      }

			KC.setOpacity(el, pocet*0.1);
			pocet++;

			setTimeout(arguments.callee, 35);
		})();

      KC.closeEfekt(el, 5000);
	}
	
	this.closeEfekt = function(el, time, step){
	
	   if(!step) step = 50;
	
	   if(!el.appendChild){
	   
	      el = document.getElementById(el);
	   }
	
	   var pocet = 10;
	
		setTimeout(function(){

	      if(pocet < 0){

	         el.style.display = 'none';
				return;
	      }

			KC.setOpacity(el, pocet*0.1);
			pocet--;

			setTimeout(arguments.callee, step);
		}, time);
	}

	this.getAjaxURL = function(url){

		var pos = url.indexOf('#');
		if(pos != -1){

		   url = url.substr(0, pos);
		}

		url = url.replace('&amp;', '&');

	   if(url.indexOf('?') == -1) url += '?ajax=1';
	   else url += '&ajax=1';

	   return url;
	}

	this.getParam = function(data, nazev, oddelovac){

		var h0 = data.split(oddelovac);
		for (i in h0){

			h = h0[i].split("=");

			if(h[0] == ' '+nazev || h[0] == nazev){

			   var val = '';

			   for(var a = 1; a < h.length; a++){

			      if(val != '') val += '=';
			      val += h[a];
			   }


				return val;
			}
		}
		return false;
	}
	
	this.isParam = function(data, nazev, oddelovac){

		var h0 = data.split(oddelovac);
		for (i in h0){

			h = h0[i].split("=");

			if(h[0] == ' '+nazev || h[0] == nazev){

				return true;
			}
		}
		return false;
	}


	this.winH = function(){
   	if (window.innerHeight)

	      return window.innerHeight;
	   else if(document.documentElement && document.documentElement.clientHeight)

	      return document.documentElement.clientHeight;
	   else if (document.body && document.body.clientHeight)

	      return document.body.clientHeight;
	   else
	      return null;
	};

	this.winW = function(){

	   if (window.innerWidth)

	      return window.innerWidth;
	   else if(document.documentElement && document.documentElement.clientWidth)

	      return document.documentElement.clientWidth;
	   else if (document.body && document.body.clientWidth)

	      return document.body.clientWidth;
	   else
	      return null;
	};



	staticContainer = document.createElement('div');

   staticContainer.className = 'staticContainer';
   staticContainer.style.position = 'fixed';
   staticContainer.style.left = '0';
   staticContainer.style.top = '0';

   var zavest = true;
   var rolovat = false;

   if(staticContainer.style.position != 'fixed'){

   	staticContainer.style.position = 'absolute';
   	rolovat = true;
   }

   function zavedContainer(){

   	if(document && document.body && document.body.firstChild){
			try{

	   		document.body.insertBefore(staticContainer, document.body.firstChild);
	   		zavest = false;
   		}catch(ex){

      		setTimeout(zavedContainer, 100);
   		}
      }else{

      	setTimeout(zavedContainer, 100);
      }
   }

   zavedContainer();

	//setTimeout(zavedContainer, 1);

	this.addEvent(window, 'scroll', statickyPosun);

   function statickyPosun(){

      if(!rolovat) return;

	   staticContainer.style.left = KC.getScrollX();
	   staticContainer.style.top = KC.getScrollY();
   }

   this.staticContainer = staticContainer;
}

KC.form = new function(){

	var ajax;



	this.submit = function(form){

		url = form.action;
		method = form.method;

	   if(!ajax) ajax = new Ajax();
	   url = KC.getAjaxURL(url);

		var inputy = form.getElementsByTagName('input');
		var selecty = form.getElementsByTagName('select');
		var textarey = form.getElementsByTagName('textarea');

		var data = '';

	   for(var i = 0; i < inputy.length; i++){

	      var type = inputy[i].type.toLowerCase();

	      if(type == 'radio' || type == "checkbox"){

	      	if(inputy[i].checked){

	      		if(data != '') data += '&';
					data += inputy[i].name +'='+ inputy[i].value.replace('&', '%26');
				}
	      }else{

	      	if(data != '') data += '&';
	      	data += inputy[i].name +'='+ inputy[i].value.replace('&', '%26');
	      }
	   }

	   for(var i = 0; i < textarey.length; i++){

	      if(data != '') data += '&';

	      data += textarey[i].name +'='+ textarey[i].value;
	   }

	   for(var i = 0; i < selecty.length; i++){

	      if(data != '') data += '&';

	      data += selecty[i].name +'='+ selecty[i].value;
	   }

	   ajax.send(zpracujAkci, url, method, data);

	}

	function zpracujAkci(){

		try{
	   	var data = ajax.get('responseJSON');
	   }catch(ex){
	      alert(ex);
	   }

	   KC.zpracujAkci(data);
	}
}

KC.zmenaBarvy = function(el, co, color1, color2, time0, prodleva){

	var krok = 50;
	var interval = null;

	if(el.toLowerCase) el = document.getElementById(el);

	color1 = color1.replace('#', '');
	color2 = color2.replace('#', '');

	var r1,g1,b1,r2,g2,b2,kroku,krokR,krokG,krokB,time;

	this.reStart = function(){

	   time = time0;

		r1 = parseInt(color1.substr(0,2), 16);
		g1 = parseInt(color1.substr(2,2), 16);
		b1 = parseInt(color1.substr(4,2), 16);

		r2 = parseInt(color2.substr(0,2), 16);
		g2 = parseInt(color2.substr(2,2), 16);
		b2 = parseInt(color2.substr(4,2), 16);

		kroku = time/krok;

		krokR = (r2 - r1)/kroku;
		krokG = (g2 - g1)/kroku;
		krokB = (b2 - b1)/kroku;

	   el.style[co] = 'rgb('+Math.round(r1)+', '+Math.round(g1)+', '+Math.round(b1)+')';

	   if(interval) clearInterval(interval);
		if(!prodleva){

			interval = setInterval(casovac, krok);
		}else{

		   setTimeout(function(){

				interval = setInterval(casovac, krok);
			},prodleva);
		}
	}

	function casovac(){

		time -= krok;
	   if(time <= 0){

	      clearInterval(interval);
	      interval = null;
	   }

	   r1 += krokR;
	   g1 += krokG;
	   b1 += krokB;

	   el.style[co] = 'rgb('+Math.round(r1)+', '+Math.round(g1)+', '+Math.round(b1)+')';
	}


	this.reStart();
}

KC.okno = new function(){

	var ajax;
	var stop = 0;


	var pozadi = document.createElement('div');
	pozadi.className = 'okno_pozadi';


	var obal = document.createElement('div');
	obal.className = 'okno_obal';

	obal.style.position = 'absolute';
	//obal.style.top = '0';
	obal.style.width = '100%';

	var okno = document.createElement('div');
	okno.className = 'okno_okno0';

	obal.appendChild(okno);

	okno = okno.appendChild(document.createElement('div'));
	okno.className = 'okno_okno';
	okno.style.position = 'relative';


	var hlavicka = document.createElement('div');
	hlavicka.className = 'okno_hlavicka';

	//okno.appendChild(hlavicka);

	var a = document.createElement('a');
	a.className = 'okno_krizek';
	a.href = 'javascript:;';
	a.title = 'Zavřít okno';
	//hlavicka.appendChild(a);
	okno.appendChild(a);


	KC.addEvent(a, 'click', close);
	KC.addEvent(pozadi, 'click', close);
	KC.addEvent(obal, 'click', function(){setTimeout(close, 100)});
	KC.addEvent(okno, 'click', stopClose);
	KC.addEvent(window, 'resize', init);


	var obsah = document.createElement('div');
	obsah.className = 'okno_obsah';
	obsah.id = 'okno_obsah';

	okno.appendChild(obsah);

	function init(){

		if(KC.isFB){
			obal.style.top = 50 + 'px';
		}else{
		
		   var top = (pozadi.offsetHeight - okno.offsetHeight) / 2 - a.offsetHeight;
		   
		   if(top < 5) top = 5;
		
			obal.style.top = top + 'px';
		}
		
		obal.style.left = '0';

	}

	function pozadiInit(){


		pozadi.style.height = KC.winH() + 'px';
		pozadi.style.width = '100%';

      KC.setOpacity(pozadi, 0.8);
	
	}

	function fb_init(){

	   var posun = 0;

	   if(clanekOpenId){
	   
	      var el;

			if(clanekOpenId.parentNode === undefined) el = document.getElementById(clanekOpenId); else el = clanekOpenId;

	      posun = KC.getPosition(el, 'offsetTop') - 50;

	   	FB.CanvasClient.scrollTo(0, posun);
	   }

		obal.style.top = posun + 'px';
		obal.style.left = '0';

		clanekOpenId = null;

	}

	this.reInit = init;

	var clanekOpenId = null;

	this.open = function(url, id){

		if(!ajax) ajax = new Ajax();

	   url = KC.getAjaxURL(url);

      obal.style.top = '-10000px';
      obal.style.left = '-10000px';

		KC.staticContainer.appendChild(pozadi);
		KC.staticContainer.appendChild(obal);

      clanekOpenId = id;

      pozadiInit();
		KC.preloadStart();
		ajax.send(zobrazData, url);


		return false;
	}

	function zobrazData(){

		KC.preloadStop();
      obsah.innerHTML = ajax.get('responseText');

		if(obsah) KC.evalScripts(obsah);

		if(KC.isFB) fb_init();
		else init();

	}

	this.openData = function(data){

      obal.style.top = '-10000px';
      obal.style.left = '-10000px';

		KC.staticContainer.appendChild(pozadi);
		KC.staticContainer.appendChild(obal);
		
      pozadiInit();

	   obsah.innerHTML = data;

		if(obsah) KC.evalScripts(obsah);

		if(KC.isFB) fb_init();
		else init();
	}

	this.close = function(){

	   close();
	}

	function close(){

	   if(stop != 0){

	      stop--;
			return;
		}

	   if(pozadi.parentNode) pozadi.parentNode.removeChild(pozadi);
	   if(obal.parentNode) obal.parentNode.removeChild(obal);
	}

	function stopClose(e){

	  // if(!e) e = window.event;

		stop++;


		/*
		if(e.preventDefault) e.preventDefault();
		else e.cancelBubble = true;
*/
	   //return false;
	}
}

KC.hl = new function(){ // hodnocení článků


	this.init = function(idClanku){

		var puvodni = 0;
		//var el = [];
		
		var obal = document.getElementById('hod' + idClanku);
		
		if(!obal) return;
		
		var el = obal.getElementsByTagName('a');
		
		for(var i = 0; i < el.length; i++){

	      if(el[i].className == 'akt') puvodni = i;
		}
/*
	   for(var i = 0; i < 5; i++){

	   	el[i] = document.getElementById('h'+i+'-'+idClanku);
	      if(el[i].className == 'aktivni') puvodni = i;

		}
*/


	   for(var i = 0; i < 5; i++){

			KC.addEvent(el[i], 'mouseout', function(){
            active(idClanku, puvodni);
			});
	   }
	   



   	KC.addEvent(el[0], 'mouseover', function(){
         active(idClanku, 0);
		});
   	KC.addEvent(el[1], 'mouseover', function(){
         active(idClanku, 1);
		});
   	KC.addEvent(el[2], 'mouseover', function(){
         active(idClanku, 2);
		});
   	KC.addEvent(el[3], 'mouseover', function(){
         active(idClanku, 3);
		});
   	KC.addEvent(el[4], 'mouseover', function(){
         active(idClanku, 4);
		});



	}

	function active(idClanku, poradi){

		var obal = document.getElementById('hod' + idClanku);

		var els = obal.getElementsByTagName('a');

		for(var i = 0; i < els.length; i++){

	      var el = els[i];

			if(i <= poradi) el.className = 'akt';
			else el.className = '';
		}
/*
		for(var i = 0; i < 5; i++){

	      var el = document.getElementById('h'+i+'-'+idClanku);

			if(i <= poradi) el.className = 'aktivni';
			else el.className = 'neaktivni';
	   }
*/
	}

}

KC.roller = function(krokY, krok_casu){

	var x = 0, y = 0, anchor = '', casovac = null;
	
	var krokX = krokY
	
	this.scroll = function(id){

      var el = document.getElementById(id);

	   anchor = id;

	   x = getPosition(el, 'offsetLeft');
	   y = getPosition(el, 'offsetTop');

		casovac = setInterval(roluj, krok_casu);
	}


	var posledniX = -1;
	var posledniY = -1;
	var kroku = 0;

	function roluj(){

		kroku++;
      var rolujX = krokX;
      var rolujY = krokY;

		var scrollX = KC.getScrollX();
		var scrollY = KC.getScrollY();

		var pridejX = Math.abs(x - scrollX)/30;
		var pridejY = Math.abs(y - scrollY)/30;

		if(scrollX - rolujX <= x && scrollX + rolujX >= x) rolujX = x - scrollX;
		if(scrollY - rolujY <= y && scrollY + rolujY >= y) rolujY = y - scrollY;

		if(scrollX > x) rolujX = -Math.abs(rolujX);
		if(scrollY > y) rolujY = -Math.abs(rolujY);


		if(scrollY == y) rolujY = 0;
		if(scrollX == x) rolujX = 0;

		scrollBy(rolujX, rolujY);

		if((scrollX == x && scrollY == y) || (posledniX == scrollX && posledniY == scrollY)){
			clearInterval(casovac);
			casovac = null;
			posledniX = -1;
			posledniY = -1;
			kroku = 0;
			window.location.hash = '#'+anchor;
			return;
		}

		posledniX = scrollX;
		posledniY = scrollY;
	}

	function getPosition(pole, typ){

		return KC.getPosition(pole, typ);
	}

}

KC.setPage = function(){

	if(!window.KC_config || !KC_config.je_klub) return;
	
	var a = document.getElementsByTagName('a');

	for(var i = 0; i < a.length; i++){

	   if(a[i].href.indexOf('#') == -1) a[i].href += '#kc-page';
	}

	if(!KC.isDomReady) setTimeout(KC.setPage, 20);
}

var je_page = KC.isParam(window.location.hash.substr(1), 'kc-page', ';');


KC.onDomReady(function(){


	function click1(){

		this.className = 'active';
	   this.parentNode.parentNode.className = this.parentNode.parentNode.className + ' active';
	   
		act1.className = '';
	   act1.parentNode.parentNode.className = act1.parentNode.parentNode.className.substr(0, 4);
		act1 = this;
	}
	
	function click2(){

		this.className = 'active';
		act2.className = '';
		act2 = this;
	}


	var box1 = document.getElementById('seznam_kategorie');
	var box2 = document.getElementById('seznam_podkategorie');

	var els1 = box1.getElementsByTagName('a');

	var act1 = null;


	for(var i = 0; i < els1.length; i++){
	
	   if(els1[i].className == 'active') act1 = els1[i];

      KC.addEvent(els1[i], 'click', click1);
	}
	
	if(box2){

		var els2 = box2.getElementsByTagName('a');
		var act2 = null;
	
		for(var i = 0; i < els2.length; i++){

		   if(els2[i].className == 'active') act2 = els2[i];

	      KC.addEvent(els2[i], 'click', click2);
		}
	
	}


});
