    /*var actual_height;
$(document).ready(function() {
	$("#read_more").click(function(){
	actual_height = ($(".header_image_slide").height() == 70) ? "189px" : "70px";
	$(".header_image_slide").animate({
		height: actual_height
	}, 1500 );
	});
});*/

$(document).ready(function() {
	$('#read_more').click(function(){
		var slide = jQuery(this).parent().parent();
		var slide_height = slide.innerHeight();
		var slide_header_height = jQuery(this).parent().innerHeight();
		var animateHeight = slide_height - slide_header_height;
		var animate = '';
		var up = false;
		if(slide.hasClass('up'))
		{
         $(this).removeClass('hide_read_more');
			$(this).toggleClass('show_read_more');
			animate = '+='  +animateHeight + 'px';
			up = true;
		}
		else
		{
			$(this).removeClass('show_read_more');
			$(this).toggleClass('hide_read_more');
			animate = '-=' + animateHeight + 'px';
			up = false;
		}
		slide.stop().animate({
			'top':animate
		},600,function(){
			(up) ? slide.removeClass('up') : slide.addClass('up');
		});
	});

	$(function() {
		$('div.dropdown-box').find('.dropdown-box-title:eq(0)').addClass('open').end().find('div.collapse:gt(0)').hide().end().find('.dropdown-box-title').click(function() {
			$(this).toggleClass('open').siblings().removeClass('open').end()
			.next('div.collapse').slideToggle().siblings('div.collapse:visible').slideUp();
			return false;
		});
	});

	if ($('.zoomable').length) {
      $(function() {
   		$('.zoomable').parent().lightBox();
   	});
	}

	$(function() {
		$('.datepicker').each(function(){
            $(this).datepicker();
        });
        // do not use: $('.datepicker').datepicker(); - because it returns error
        // if no .datepicker class found on the page and then gallery.js doesn't work
	});

  $(function() {
    $('#number_of_children').change(function() {
      var count = $(this).val();
      if (count > 0) {
          $('#ChildrenBirthDateLabel').show();
      }
      else {
          $('#ChildrenBirthDateLabel').hide();
      }
      var newHTML = [];
      var oldValue;
      for(var i = 1; i <= count; i++){
        var oldValue = ($('#children_birth_date' + (i)).length != 0) ? $('#children_birth_date' + (i)).val() : '';
        newHTML.push(((i < 10) ? '0' : '') + i + '. <input id="children_birth_date' + i + '" class="datepicker" name="data[ImpozantImpozant][reservation_children_birth_date][' + i + ']" type="text" value="' + oldValue + '"><br>');
      }
      $('#sandbox').html(newHTML.join(''));
      $('.datepicker').datepicker();
    });
  });
  
  
  //
  // digital clock functionality
  //
  
    digitalClockInit({
      elem : document.getElementById('clock'),
      format : '24',
      sep : ':',
      sec : false,
      hz : false,
      initOffsetTime: gServerTimestamp
    });
  
    function leadingZero(n) {
      return (n>9) ? n : '0'+n;
    }

    function digitalClockFormat(oDate, format, sep, sec, hz) {
      var hour = oDate.getHours();
      var minutes = sep + leadingZero(oDate.getMinutes());
      var seconds = sec ? sep+leadingZero(oDate.getSeconds()) : '';
      switch (format)
      {
        case 'long':
          var str = oDate.toString();
          return str.substring(0, str.length - 4);
          break;
        case '12':
          var ampm = "&nbsp;" + (hour<12 ? "am" : "pm");
          hour = 1 + (hour+11)%12;
          return (hz ? leadingZero(hour) : hour) + minutes + seconds + ampm;
          break;
        default:
          return (hz ? leadingZero(hour) : hour) + minutes + seconds;
          break;
      }
    }

    function digitalClockSet(wdco) {
      setTimeout(function(){digitalClockSet(wdco)}, wdco.sec ? 1000 : 60000);
      var oDate = new Date();
      var afterLoadMS = oDate.getTime() - wdco.initLocalTime;
      oDate.setTime(wdco.initOffsetTime + afterLoadMS);
      wdco.elem.innerHTML = digitalClockFormat(oDate, wdco.format, wdco.sep, wdco.sec, wdco.hz);
    }

    function digitalClockInit(wdco) {
          if (wdco.elem) {
              var oDate = new Date();
              wdco.initLocalTime = oDate.getTime();
              setTimeout(function(){digitalClockSet(wdco)}, 0);
          }
    } 
    
    //
    // weather functionality
    //
    if($.fn.weatherfeed) {
        $('#weather').weatherfeed(['LOXX0010']);
    }
    else {
        console.warn('The weatherfeed() command does not exists!')
    }
    
    //
    // images slideshow functionality
    //
    
    slideShow('.box_image', {slideTime: 5000, changeTime: 1000});
    
    /**
     * Changes images in slideshow. Images must be stocked one over another.
     * If images are placed under different parents then a separate slideshow
     * is launched for each set of images.
     * 
     * @param mixed imagesSelector:
     *      - (string) - a jquery selector to retrieve slideshow images
     *      - (object) - a jquery set of elements pointing to images
     * @param object options:
     *          - slideTime (int) - time in microseconds of one slide duration
     *          - changeTime (int) - time in microseconds of change bwetween two 
     *          slides duration
     */
    function slideShow(imagesSelector, options, /* internal: */ imageIndex) {
      // set defaults
      var defaults = {
        slideTime: 3000,
        changeTime: 'slow'
      };  
      options = $.extend(defaults, options); 
        
      if (typeof(imagesSelector) == 'string') {
          var images = $(imagesSelector);
      }
      else {
          // imagesSelector jquery set of elements 
          var images = imagesSelector;
      }
      // check if images have different parents
      // If yes, then restart the slideShow separately for each set of images
      // NOTE: This can happen only on the very first call of function
      var parents = images.parent();
      if (parents.length > 1) {
          parents.each(function(index){
              slideShow($(this).find(imagesSelector), options)
          });
          return;
      }
      var imagesCount = images.length;
      
      if (imagesCount < 2) {
          return; // nothing to slide if there is 1 or no image
      }
      
      if (imageIndex == undefined) {
          imageIndex = imagesCount - 1;
      }
      // slide
      if (imageIndex == imagesCount - 1) {
          images.eq(imageIndex).fadeIn(options.changeTime, function() {
            images.show();
          });
      }
      else {
          images.eq(imageIndex + 1).fadeOut(options.changeTime);
      }
      // find next index
      if (imageIndex == 0) {
          imageIndex = imagesCount - 1;
      }
      else {
          imageIndex--;
      }
      
      setTimeout(function(){slideShow(images, options, imageIndex)}, options.slideTime);
    }
    
//    //
//    // images slideshow functionality
//    //
//    
//    slideShow('.box_image', {slideTime: 5000, changeTime: 1000});
//    
//    /**
//     * Changes images in slideshow. Images must be stocked one over another
//     * 
//     * @param string imagesSelector - a jquery selectr to retrieve slideshow images
//     * @param object options:
//     *          - slideTime (int) - time in microseconds of one slide duration
//     *          - changeTime (int) - time in microseconds of change bwetween two 
//     *          slides duration
//     */
//    function slideShow(imagesSelector, options, /* internal: */ imageIndex) {
//      // set defaults
//      var defaults = {
//        slideTime: 3000,
//        changeTime: 'slow'
//      };  
//      options = $.extend(defaults, options); 
//        
//      var images = $(imagesSelector);
//      var imagesCount = images.length;
//      
//      if (imagesCount < 2) {
//          return; // nothing to slide if there is 1 or no image
//      }
//      
//      if (imageIndex == undefined) {
//          imageIndex = imagesCount - 1;
//      }
//      // slide
//      if (imageIndex == imagesCount - 1) {
//          images.eq(imageIndex).fadeIn(options.changeTime, function() {
//            images.show();
//          });
//      }
//      else {
//          images.eq(imageIndex + 1).fadeOut(options.changeTime);
//      }
//      // find next index
//      if (imageIndex == 0) {
//          imageIndex = imagesCount - 1;
//      }
//      else {
//          imageIndex--;
//      }
//      
//      setTimeout(function(){slideShow(imagesSelector, options, imageIndex)}, options.slideTime);
//    }
//    
    
});
