function addToWatchList(hotelId) {
  jQuery.get('actionh.php', { action: 'addToWatchList', hotelId: hotelId }, function(data) {
   getWatchList();
   jQuery.fancybox.close();
 } );
 jQuery('#hotelButtons2' + hotelId).hide();
}
function removeFromWatchList(hotelId) {
  jQuery.get('actionh.php', { action: 'removeFromWatchList', hotelId: hotelId }, function(data) {
    getWatchList();
 } );
 jQuery('#hotelButtons2' + hotelId).show();
}
function getWatchList() {
  jQuery.get('actionh.php', { action: 'listWatchList' }, function(data) {
    if(data != '0') {
      jQuery('#merkliste').show();
      jQuery('#merkliste .box .hotels').html(data);
      sifrconfig();
    } else {
      jQuery('#merkliste').hide();
    }
    jQuery('#merkliste .box .hotels li').each(function() {
      var id = jQuery(this).attr('class').substr(7);
      jQuery('#hotelButtons2' + id).hide();
    });
 } );
}
function watchListToEnquiry() {
  jQuery('#merkliste .box .hotels').html(data);
}
jQuery(function ($) {
  getWatchList();
	$('a.fancy, a.addToWatchList').each(function() {
    $(this).removeAttr('href');
  });
  $('a.fancy').click(function() {
    $.get('actionh.php', { action: 'chooseWatchList', hotelId: $(this).attr('id').substr(12) }, function(data) {
      $.fancybox({
  			'titlePosition'		: 'inside',
  			'transitionIn'		: 'none',
  			'transitionOut'		: 'none',
  			'overlayOpacity'  : '0.7',
  			'overlayColor'    : '#000000',
    		'content' : data
      });
    });
  });
	$('a.addToWatchList').click(function() {
    $.get('actionh.php', { action: 'addToWatchList', hotelId: $(this).attr('id').substr(12) }, function() {
      $.get('actionh.php', { action: 'itemAddedToWatchList' }, function(data) {
        getWatchList();
        if( jQuery('#merkliste .box .hotels li').length == 0 ) { // show only once
          $.fancybox({
      			'titlePosition'		: 'inside',
      			'transitionIn'		: 'none',
      			'transitionOut'		: 'none',
      			'overlayOpacity'  : '0.7',
      			'overlayColor'    : '#000000',
      			'content' : data
          });
        }
      });
    });
  });
  jQuery('#merkliste .submit').click(function () {
    var hotelIds = '';
    jQuery('#merkliste ul li').each(function (index) {
      hotelIds += jQuery(this).attr('class').substr(7) + ',';
    });
    hotelIds = hotelIds.substr(0, hotelIds.length - 1);
    jQuery('#merkliste form .hotelIds').val(hotelIds);
    jQuery('#merkliste form').submit();
  });
});
