function initMenu() {
 $('#horizontalMenu > ul > li').hover(function(){
	  var ul = $(this).find('ul');
	  if(ul[0]!=null) {
	      setVisibilityToProblemsElements(false);
	      /*
	      if($.browser.msie && parseInt($.browser.version)<7) {
	    	  $(this).find('.background').height(ul.height())
	      }	
	      */  
	      ul.show();
	      //ul.slideDown("fast")
	  }
	 },function(){
	  var ul = $(this).find('ul');
	  if(ul[0]!=null) {		  		  		  
	      ul.hide();
	      setVisibilityToProblemsElements(true);
	  }   
	 });
}

//In IE6 and older we hide or visible problems elements as select, object and embed
setVisibilityToProblemsElements = function(visibility) {    
    if($.browser.msie && parseInt($.browser.version)<7) {
        $("select,object,embed").css('visibility',(visibility?'visible':'hidden'));
    }
}

function initCalendar() {
    var calendar = new CalendarBox();  
    $('#actualDate').data('calendarConf', new CalendarConfigure());
    $('#actualDate').data('calendarConf').set({panelToDisplay: $('#calendarBox')})
    calendar.show($('#actualDate'));
 }

/**
 * Funkce na nastaveni LighBoxu
 * @return
 */
function setLightBox() {
	var ll = $('a[@rel*=lightbox]');	
	var gallerySize = getPageSize();	
	if(ll!=null) {
		var list = new Array();
		ll.each(function(index,link){
			link.href += '?x='+(gallerySize[2] - 20)+'&y='+(gallerySize[3] - 100);
			var ls = /lightbox\[(.*)\]/.exec(link.rel);
			if(ls != null && jQuery.inArray(ls[1], list)==-1) {
				list.unshift(ls[1]);
			}
		});	
		for(nn in list) {
			$('a[@rel*='+list[nn]+']').lightBox();
		}
		$('a[@rel=lightbox]').lightBox();
		/*
		ll.lightBox();
		ll.each(function(index,link) {
			link.href += '?x='+(gallerySize[2] - 20)+'&y='+(gallerySize[3] - 100);
		});	
		*/
	}
}

/**
 * Funkce pro nastaveni photoPaperu, prepinani fotek
 * @return
 */
var indexShow = 1;
function setSwitchPhoto(div) {
  function doIt() {	
	div.children('a').hide();
	div.children('a:eq('+indexShow+')').show();
	indexShow++;
	if(indexShow>=div.children('a').length) {
		indexShow = 0;
	}
  }
  setInterval(doIt,5000)
}

function onLoadAction() {	
	initMenu();
	initCalendar();
	setLightBox();
	setSwitchPhoto($('.photoPaper'));
}

if(typeof $ != 'object' && typeof $ != 'function') {
 alert('Please load jquery.js !!!');
}else{  
 $(document).ready(onLoadAction);
}

/* Functions */
function switchVerticalMenu(link) {
	$(link).parent('li').toggleClass('open');
}
