function mng_shortlist(action, id_accom_room_type)
{
	$.ajax({
		type: "POST",
		url: "/body_incs/short_list.php",
		data:
		{
			action: action,
			id_accom_room_type: id_accom_room_type
		},
		success: function(html)
		{
			if (action == 'update')
			{
				$("#shortlist_container").html(html);
				if (html == '') $("#shortlist_container").hide();
				else $("#shortlist_container").show();
			}
			else
			{
				mng_shortlist('update');
			}
		}
	});	
}

$(function() {
	
	$('a.short_add').live('click', function(e) {
		
		e.preventDefault();
		var id = $(this).attr('rel');
		
		mng_shortlist('add', id);
		
		$('a.short_add').each(function() {
			if( $(this).attr('rel') == id) {
				$(this).removeClass('short_add');
				$(this).addClass('short_remove');
				$(this).html('Remove from Shortlist');
			}
		});
	
		
	});
	
	$('a.short_remove').live('click', function(e){
		
		e.preventDefault();
		var id = $(this).attr('rel');
		
		mng_shortlist('remove', id);
		
		$('a.short_remove').each(function() {
			if( $(this).attr('rel') == id) {
				$(this).removeClass('short_remove');
				$(this).addClass('short_add');
				$(this).html('Add to Shortlist');
			}
		});
		
	});
	
	$('a.sl_rm').live('click', function(e){
		
		e.preventDefault();
		var id = $(this).attr('rel');
		
		mng_shortlist('remove', id);
		
		$('a.short_remove').each(function() {
			if( $(this).attr('rel') == id) {
				$(this).removeClass('short_remove');
				$(this).addClass('short_add');
				$(this).html('Add to Shortlist');
			}
		});
		
		$('li.slitem').each(function() {
			if( $(this).attr('id') == 'sl_large_'+id) {
				$(this).fadeOut(1000);
			}
		});
		
	});
	
	mng_shortlist('update');
	
});
