function startup(){
  fleXenv.initByClass('sloupec-obsah');
  var sloupec = getElementsByClass('sloupec-posuvniky',null,'div');
  var elClass = getElementsByClass('sloupec-obsah',null,'div'); 
  var maxScroll = new Array();    
  for(x=0;x<elClass.length;x++){                            
    if (elClass[x] == null) return;	
    maxScroll[x] = elClass[x].fleXdata.scrollPosition[1][1];               
    if(maxScroll[x]!=false)   sloupec[x].innerHTML+='<div class="posuvniky"> <a href="#" class="nahoru" onmouseover="rollSlowStart(this, '+x+',\'top\');" onmouseout="rollSlowStop(this)" onmousedown="rollFastStart(this, '+x+',\'top\');" onmouseup="rollFastStop(this, '+x+',\'top\')"></a> <a href="#" class="dolu" onmouseover="rollSlowStart(this, '+x+',\'bottom\');" onmouseout="rollSlowStop(this)" onmousedown="rollFastStart(this, '+x+',\'bottom\');" onmouseup="rollFastStop(this, '+x+',\'bottom\')"></a> </div>';
  } 
  
function formatTitle(title, currentArray, currentIndex, currentOpts) {
  var whTitle = title.split('||');
  title = whTitle[0];
  comment = (whTitle[1]!=undefined?whTitle[1]:'');   
  return '<span>'+ title +'</span>'+ (comment!=''?'<p>'+ comment +'</p>':'');
}
  $(document).ready(function() { 
    $("a.lightbox").fancybox({
      'zoomSpeedIn': 300,
      'zoomSpeedOut': 300,
      'overlayShow': false,   
      'showCloseButton': true,
      'titleShow': true,      
      'titlePosition': 'over',
      'titleFormat': formatTitle,
      'onComplete': function(){        
        $("#fancybox-title").css({'top':'10px', 'bottom':'auto'});                        
        $("#fancybox-outer").animate({'height': ($("#fancybox-title").height()+$("#fancybox-content").height()+30)},200);
        $("#fancybox-content").animate({'top':$("#fancybox-title").height()+10},200);          
      } 
    });
        
  });  
   
}
       
function hoverMenu(className,show){  
  var getObject = getElementsByClass(className);
  var aElement = getObject[0].getElementsByTagName('a');  
  if(show==true){        
    aElement[0].style.padding='5px 0 6px 35px';
    aElement[0].style.height='18px';
    aElement[0].style.textIndent='0px';                
    $(aElement[0]).animate({width: '145px'},200);            
  }else{        
    aElement[0].style.width='2px';
    aElement[0].style.padding='0';
    aElement[0].style.height='29px';    
    aElement[0].style.textIndent='-1000px';
    var fixErr = document.getElementById('menu');
    fixErr.innerHTML+='';        
  }
} 
      
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
	 
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function hoverDesignImg(blockId){
  var img0 = document.getElementById('img'+blockId+'0');
  var img1 = document.getElementById('img'+blockId+'1');
  
  if(img1.style.display!='block'){
    img0.style.display='none';
    img1.style.display='block';
    return false;
  }else{
    img0.style.display='block';
    img1.style.display='none';
    return false;    
  }
}

function rollSlowStart(that, which, way)
{
  var elClass = getElementsByClass('sloupec-obsah',null,'div');
	var scrollDiv = elClass[which];   
	if (scrollDiv == null) return;	
	
	function scrollTimer(){           
		var currentScroll = scrollDiv.fleXdata.scrollPosition[1][0];
		var maxScroll = scrollDiv.fleXdata.scrollPosition[1][1];
		var currY = (way == 'top'?'-1':'1')+'px';	  
		if((currentScroll < maxScroll && way=='bottom') || (currentScroll > 0 && way=='top'))
		{   
		 if(scrollDiv.fleXcroll) {scrollDiv.fleXcroll.setScrollPos(false,currY,'relative');}      
		} else {
			if (that.scrollSlowTimer) window.clearInterval(that.scrollSlowTimer);
		}
	}
	                                           
	that.scrollSlowTimer = window.setInterval(scrollTimer, 10);
}       

function rollSlowStop(that){
	if (that.scrollSlowTimer) window.clearInterval(that.scrollSlowTimer);
}

function rollFastStart(that, which, way)
{
  var elClass = getElementsByClass('sloupec-obsah',null,'div');
	var scrollDiv = elClass[which];
	if (scrollDiv == null) return;	
	
	function scrollTimer(){
		var currentScroll = scrollDiv.fleXdata.scrollPosition[1][0];
		var maxScroll = scrollDiv.fleXdata.scrollPosition[1][1];
		var currY = (way == 'top'?'-10':'10')+'px';	  
		if((currentScroll < maxScroll && way=='bottom') || (currentScroll > 0 && way=='top'))
		{ 
		 if(scrollDiv.fleXcroll) {scrollDiv.fleXcroll.setScrollPos(false,currY,'relative');}      
		} else {
			if (that.scrollFastTimer) window.clearInterval(that.scrollFastTimer);
		}
	}
	
	if (that.scrollSlowTimer) window.clearInterval(that.scrollSlowTimer);
	that.scrollFastTimer = window.setInterval(scrollTimer, 15);
}       

function rollFastStop(that, which, way){
	if (that.scrollFastTimer) window.clearInterval(that.scrollFastTimer);
	
	rollSlowStart(that, which, way);
}

          
