$(document).ready(function() {
    getCommerceForAccommodation(accommodationid, "accommodation");

    $('img.accommodation_photos').each(function(i, e) {
	$(e).hover(
	    function () {
		changeMainImage($(e));
	    },
	    function () {
		return;
	    }
	    );
    });
});

/**
 * Replaces the main accommodation with replacementImage.
 *
 * We remove the 'thumbnails/' part from the source url to
 * get the larger image.
 */
function changeMainImage(replacementImage)
{
    var src = replacementImage.attr('src').replace('/thumbnails', '') ;

    $('img#main_illus_image').attr('src', '/images/ajax-loader-commerce.gif');

    //this preload the image before replacing the content with it
    jQuery("<img>").attr("src", src).ready(function() {
	$('img#main_illus_image').attr('src', src);
    });
}
