$(document).ready(function(){
	// ligthBox
    $(function() {
            $('.pic a').lightBox({
    	overlayOpacity: 0.6,
    	imageLoading: '/images/lightbox-ico-loading.gif',
        imageBlank: '/images/lightbox-blank.gif',
    	imageBtnClose: '/images/zavrit.png',
    	imageBtnPrev: '/images/predchozi.png',
    	imageBtnNext: '/images/dalsi.png',
    	containerResizeSpeed: 350,
    	txtImage: 'Obrázek',
    	txtOf: 'z',
    	maxWidth: 600
       });
    });

	//Tooltips
    $(".tip_trigger").hover(function(){
        tip = $(this).find('.tip');
        tip.show(); //Show tooltip
    }, function() {
        tip.hide(); //Hide tooltip
    }).mousemove(function(e) {
        var mousex = e.pageX+20; //Get X coodrinates
        var mousey = e.pageY+20; //Get Y coordinates
        var tipWidth = tip.width(); //Find width of tooltip
        var tipHeight = tip.height(); //Find height of tooltip

        //Distance of element from the right edge of viewport
        var tipVisX = $(window).width() - (mousex + tipWidth);
        //Distance of element from the bottom of viewport
        var tipVisY = $(window).height() - (mousey + tipHeight);

        if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
            mousex = e.pageX - tipWidth - 20;
        } if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
            mousey = e.pageY - tipHeight - 20;
        }
        //Absolute position the tooltip according to mouse position
        tip.css({  top: mousey, left: mousex });
    });
	
	
$(".div_reveal").hide(); //Hide all content
$(".tab_content").hide(); //Hide all content
if(location.hash != "") {
var target = "#"+location.hash.split("#")[1]; // need semicolon at end of line
$(location.hash).show(); //Show first tab content
$("ul.tabs li:has(a[href="+target+"])").addClass("active").show(); //need �?+’ either side of �?target’
} else {
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
}

//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any “active” class
$(this).addClass("active"); //Add “active” class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab content
if($.browser.msie)
{$(activeTab).show();}
else
{$(activeTab).fadeIn();}
if($(this).find("a").attr("id") != 'ajaxed')
    {return false;}
});

$("#zarezervuj").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any “active” class
$("ul.tabs .cenarezervace").addClass("active"); //Add “active” class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $("ul.tabs .cenarezervace").find("a").attr("href"); //Find the href attribute value to identify the active tab content
if($.browser.msie)
{$(activeTab).show();}
else
{$(activeTab).fadeIn();}
return false;
});

// záložky svět
	
  var startHeight = $('.obalovaci1').height();
		$('.btn1').click(function() {
		   // find nearby elements
		   var obalovaci1 = $(this).parents().find('.obalovaci1');
		   var vnitrni1 = obalovaci1.children('.vnitrni1');  
		   
		   // collect current heights
		   var vnitrni1H = vnitrni1.height();
		   var obalovaci1H = obalovaci1.height();
		   
		   // calculate new height
		   var newHeight =  + parseInt(vnitrni1H);
	
		   // determines whether to toggle height
		   newHeight = obalovaci1H > startHeight ? startHeight : newHeight;
		   obalovaci1.animate({height:newHeight}, 300);
		   $(this).toggleClass("active");
    });
    
    var startHeight = $('.mestaobal').height();
		$('.rozbalmesta').click(function() {
		   // find nearby elements
		   var mestaobal = $(this).parents().find('.mestaobal');
		   var vnitrni1 = mestaobal.children('.vnitrni1');  
		   
		   // collect current heights
		   var vnitrni1H = vnitrni1.height();
		   var mestaobalH = mestaobal.height();
		   
		   // calculate new height
		   var newHeight =  + parseInt(vnitrni1H);
	
		   // determines whether to toggle height
		   newHeight = mestaobalH > startHeight ? startHeight : newHeight;
		   mestaobal.animate({height:newHeight}, 300);
		   $(this).toggleClass("rozjeto");
    });

//Show the paging and activate its first link
$(".paging a:first").addClass("active");

//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel div").size();
var imageReelWidth = imageWidth * imageSum;

//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});

//Paging  and Slider Function
rotate = function(){
    var triggerID = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

    $(".paging a").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

    //Slider Animation
    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500 );

}; 

//Rotation  and Timing Event
rotateSwitch = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.paging a.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.paging a:first'); //go back to first
        }
        rotate(); //Trigger the paging and slider function
    }, 10000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitch(); //Run function on launch

//On Hover
$(".image_reel div a").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitch(); //Resume rotation timer
});	

//On Click
$(".paging a").click(function() {
    $active = $(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotate(); //Trigger rotation immediately
    rotateSwitch(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
});    

//Newsletter
$(".newslettermail").focus(function() {

      $(this).val('');

      });
   
});

