function initMenu(menuid) {

	/*if (document.all && document.getElementById) {
		navRoot = document.getElementById(menuid);         
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI" && this.className) {
				node.onmouseover = function() {
					this.className += " over";
  				}
  				node.onmouseout = function() {
  					this.className = this.className.replace(" over", "");
   			    }
   		}
  		}
 	}*/
	$("ul#menu").children("li").not(".nb").mouseover( function() { $(this).addClass("over"); } );
	$("ul#menu").children("li").not(".nb").mouseout( function() { $(this).removeClass("over"); } );

}

var timeOut;
var scrollSpeed = 3;

function scrollGallery(dir) {

	var top = parseFloat($("#galleryScrollBox").css("top"));
	var height = $("#galleryScrollBox").height();

	if (top-dir*scrollSpeed>30) { $("#galleryScrollBox").css("top",30); return 0; }
	if (top-dir*scrollSpeed<-(height-480)) { return 0; }	

	$("#galleryScrollBox").css("top",top-dir*scrollSpeed);
	
	timeOut = setTimeout("scrollGallery("+dir+");",10);
}

function initScroll() {

	externalLinks();
	$(".txtDate").datepicker({showOn: 'both', buttonImage: '/img07/date.gif', buttonImageOnly: true});
	$("#scrollUp").hover(function() {
		timeOut = setTimeout("scrollGallery(-1);",10);	
		return false;
	},function() { clearTimeout(timeOut); });

	$("#scrollDown").hover(function() {
		timeOut = setTimeout("scrollGallery(1);",10);	
		return false;
	},function() { clearTimeout(timeOut); });

}

window.onload = function() {
	initMenu("menu");	
	initScroll();	
}
                                     
function loadHotelTermin(hotel,termin,links) {
    
    if (termin==undefined) { 
        var tb = $("#terminListTB");
        terminS = ""; 
    } else { 
        var tb = $("#inTbDates");
        terminS = "&"+termin; 
    }
    
    linksS = "";
    if (links!=undefined) { linksS = "&links=true"; }
    
    tb.html("<div class=\"loading\">Nahrávám termíny</div>");
    tb.load("/zajezdy/axtermin/?id="+hotel+terminS+linksS, {}, function() {
        $(".terminDates").find("a").attr("href","javascript:void(0);");
        $(".terminDates").find("a").click(function() {
            var rel = $(this).attr("rel");
            loadHotelTermin(hotel,rel,true);    
            
            $(".terminDates>li").removeClass("active");
            $(this).parent().addClass("active");
                    
        });
    });
    
}