/**
* /recording/
* for Recording Room 画像切り替えスクリプト
* 
* @since 2008.08.1
* @update 2008.08.1
* @auther info@rise-tec.com
* @copyright Copyright &copy; 2008, rise-tec.com
*/

jQuery.noConflict();
jQuery(function($){	//onload event
	$('div.section a[href$=.jpg]').unbind('click');	//Recording Room無いのプレビュー画像から、lightboxのクリックイベントを解除。
	$('div#recordingRoom a[href$=.jpg]').click(function(){return false;});	//リンク要素をクリックしても何もしない。
	$('div#about_recording a[href$=.jpg]').click(function(){window.open(this.href); return false;});	//別窓で開く。
	
	$('#mainContents').prepend("\n" + '<div id="roomPhoto"></div>' + "\n");	//拡大画像の表示領域を作成。div#mainContentsの先頭に挿入。
	
	//拡大画像を表示する
	var showRoomPhoto = function(img, cameraNum) {
		$(img).css('border-color', '#ff3');
		$('#recRoomMap').attr('src', gRootDir + '/images/skin/recording/rec_room_camera' + cameraNum + '.gif');
		$('#roomPhoto').html('<img src="' + img.magnifySrc + '" width="554" height="300" alt="' + img.alt + '" title="' + img.title + '" />');
		
		$('#roomPhoto').stop();
		$('#roomPhoto').css('display', 'block').animate(	//fadeIn
			{opacity: 1.0},
			{duration: 'slow', queue: false}
		);
	}
	
	//拡大画像を隠す
	var hideRoomPhoto = function(img) {
		if (img) {
			$(img).css('border-color', '#45a');
		}
		$('#recRoomMap').attr('src', gRootDir + '/images/skin/recording/rec_room.gif');
		//$('#roomPhoto').html('');

		$('#roomPhoto').animate(	//fadeOut
			{opacity: 0.0},
			{
				duration: 'normal',
				queue: false,
				complete: function() {
					$(this).css('display', 'none');
				}
			}
		);
	}
	
	$('#roomPhoto').animate(	//初回非表示。
			{opacity: 0.0},
			{duration: 0, queue: false}
	);
	
	//プレビュー画像のmouseout()が反応せず、拡大画像のみ残った場合、拡大画像をmouseoverで消す。
	$('#roomPhoto').mouseover(hideRoomPhoto).mouseout(hideRoomPhoto);
	
	var previews = $('div#floorPhotos a img');	//プレビュー画像のimg要素配列
	previews.each(function(num){
		var img = this;
		img.magnifySrc = img.src.replace(/_prev/, '');	//拡大画像のsrc属性をset
		var cameraNum = num +1;
		
		//プレビュー画像のmouseover / mouseoutを設定
		$(this).hover(
			function() {	//mouseover event
				showRoomPhoto(img, cameraNum);
			},
			function() {	//mouseout event
				hideRoomPhoto(img);
			}
		);
		
		//注：area要素ではなぜかIE6&IE7が$().hover()が実行されなかったため、下記のmouseover()とmouseout()を使用する。
		//クリッカブルマップのカメラ
		$('#camera' + cameraNum).mouseover(function() {	
			showRoomPhoto(img, cameraNum);
		});
		
		$('#camera' + cameraNum).mouseout(function() {	
			hideRoomPhoto(img);
		});
		
		
	});	//end of each()

});


