/*tabove*/
$(function(){
	$('#tabs div').hide(); // Hide all divs
	$('#tabs div:first').show(); // Show the first div
	$('#tabs ul li:first').addClass('active'); // Set the class of the first link to active
		$('#tabs ul li a').click(function(){ //When any link is clicked
		$('#tabs ul li').removeClass('active'); // Remove active class from all links
		$(this).parent().addClass('active'); //Set clicked link class to active
		var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
		$('#tabs div').hide(); // Hide all divs
		$(currentTab).show(); // Show div with id equal to variable currentTab
		return false;
		});
});
/*tabove*/
$(function(){
	$('.tabs div').hide(); // Hide all divs
	$('.tabs div:first').show(); // Show the first div
	$('.tabs ul li:first').addClass('active'); // Set the class of the first link to active
		$('.tabs ul li a').click(function(){ //When any link is clicked
		$('.tabs ul li').removeClass('active'); // Remove active class from all links
		$(this).parent().addClass('active'); //Set clicked link class to active
		var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
		$('.tabs div').hide(); // Hide all divs
		$(currentTab).show(); // Show div with id equal to variable currentTab
		return false;
		});
});

$(function(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
});
$(function(){
  $('.gallery-item a').lightbox();
});

$(function() {
	
		var dates = $( "#from, #to" ).datepicker({
			changeMonth: true,
			minDate: 0,
			dateFormat: 'dd-mm-yy',
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
});


/* Котвите */
$(function(){

    $('a[href*=#tabs],a[href*=#reservation]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                    
                return false;
                
            }
            
        }
        
    });
    
});


$(function() {
    var oferta_id = $("#ofertaid").text();
    if (oferta_id > 0) {
      $('.price').html("<a href='#'>Цени</a>");
      $(".price").click(
       function(){GetOffertaData(oferta_id);}
      );
    }
});

