$(document).ready(function() {
	var change = function(that, a_selector, img_selector, imgover, width, height) {
        $(that).css('display', 'block');
        $(that).css('position', 'relative');
        $(that).append('<div id="imgover" style="background: url(' + imgover + ') no-repeat center center; position: absolute; bottom: 0; left: 0; width: ' + width + 'px; height: ' + height + 'px;" />');
        if ($(that).attr('href') != $(img_selector).attr('src')) {
            $(that).find('#imgover').css('display', 'none');
        }
	    $(that).click(function(e) {
	        e.preventDefault();
	        $(img_selector).attr('src', $(this).attr('href'));
    		$(a_selector).each(function() {
	    		if ($(this).attr('href') == $(img_selector).attr('src')) {
		    		$(this).addClass('selected');
			    	$(this).find('#imgover').css('display', 'block');
    			} else {
		    		$(this).removeClass('selected');
	    			$(this).find('#imgover').css('display', 'none');
			    }
    		});
	    });
	    $(that).hover(function() {
            $(this).find('#imgover').css('display', 'block');
    	}, function() {
            if ($(this).attr('href') != $(img_selector).attr('src')) {
            	$(this).find('#imgover').css('display', 'none');
            }
    	});
	}

//客室
	$('ul#imgbgjproom a').each(function() { change(this, 'ul#imgbgjproom a', 'img#bgjproom_bg', 'images/imgover.gif', 59, 59); });
	$('ul#imgbgwtroom a').each(function() { change(this, 'ul#imgbgwtroom a', 'img#bgwtroom_bg', 'images/imgover.gif', 59, 59); });
	$('ul#imgbgwtjproom a').each(function() { change(this, 'ul#imgbgwtjproom a', 'img#bgwtjproom_bg', 'images/imgover.gif', 59, 59); });
	
//温泉
	$('ul#imgbghoshii a').each(function() { change(this, 'ul#imgbghoshii a', 'img#bghoshii_bg', 'images/imgover.gif', 59, 59); });
	$('ul#imgbg_tsuki a').each(function() { change(this, 'ul#imgbg_tsuki a', 'img#bg_tsuki_bg', 'images/imgover.gif', 59, 59); });
	$('ul#imgbg_todoroki a').each(function() { change(this, 'ul#imgbg_todoroki a', 'img#bg_todoroki_bg', 'images/imgover.gif', 59, 59);
	$('ul#imgbg_tousen a').each(function() { change(this, 'ul#imgbg_tousen a', 'img#bg_tousen_bg', 'images/imgover.gif', 59, 59); });
});

//お料理
	$('ul#imgbgdishes a').each(function() { change(this, 'ul#imgbgdishes a', 'img#bgdishes_bg', 'images/imgover.gif', 155, 75); });
});
