function addToWatchList(hotelId) {
  jQuery.get('actionh.php', { action: 'addToWatchList', hotelId: hotelId }, function(data) {
   getWatchList();
   //jQuery.fancybox.close();
   jQuery.colorbox.close();
 } );
 jQuery('#hotelButtons2' + hotelId).hide();
 urchinTracker('/watchlist/add');
}
function removeFromWatchList(hotelId) {
  jQuery('#watchlist-item' + hotelId).remove();
  jQuery.get('actionh.php', { action: 'removeFromWatchList', hotelId: hotelId }, function(data) {
    getWatchList();
 } );
 jQuery('#hotelButtons2' + hotelId).show();
 urchinTracker('/watchlist/remove');
}
function getWatchList() {
  jQuery.get('actionh.php', { action: 'listWatchList' }, function(data) {
    if(data != '0') {
      jQuery('#merkliste').show();
      jQuery('#merkliste .box .hotels').html(data);
      sifrconfig();
      
      jQuery('#merkliste .box .hotels li').each(function() {
        var id = jQuery(this).attr('class').substr(7);
        jQuery('#hotelButtons2' + id).hide();
      });
    } else {
      jQuery('#merkliste').hide();
    }
 } );
}
function watchListToEnquiry() {
  jQuery('#merkliste .box .hotels').html(data);
}
jQuery(function ($) {
  getWatchList();
	$('a.fancy, a.addToWatchList').each(function() {
    $(this).removeAttr('href');
  });
  $('a.fancy').live('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
      });*/
      $.colorbox({html:data});
    });
    return false;
  });
	$('a.addToWatchList').live('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
          });*/
          $.colorbox({html:data});
        //}
      });
    });
    return false;
  });
  jQuery('#merkliste .submit').live('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();
    urchinTracker('/watchlist/submit');
    return false;
  });
  jQuery('#inline1 .submit').live('click', function () {
    var hotelIds = '';
    jQuery('#inline1 .watchlist-items').each(function (index) {
      hotelIds += jQuery(this).val() + ',';
    });
    hotelIds = hotelIds.substr(0, hotelIds.length - 1);
    jQuery('#merkliste form .hotelIds').val(hotelIds);
    jQuery('#merkliste form').submit();
    urchinTracker('/watchlist/submit');
    return false;
  });
});

