/**
 * @name main.js
 * @fileOverview
 * @version 1.0
 * @description
 * <p>(c) FOURDIGIT Inc. Licensed <a href="http://ja.wikipedia.org/wiki/GNU_General_Public_License">GNU General Public License</a>.</p>
 */
//他ライブラリと共存する場合、下の一行削除($無効化)
//jQuery.noConflict();
(function($){
	var config = function () {
	//bodyのクラスにブラウザ情報を追加
		$.addClassUA();
	//easyOverのターゲット設定
		$("img.ahover, .ahoverArea img").easyOver();
	//IE5,6にてPNG有効化 (pngfixの読み込みが必要)
		$("img[src$=png],p.png").enablePNG();
	//Flash
		//$("object, embed").enableFlash();
	//ポップアップリンクに置換
		$(".commonPop").easyPop();
	//他ドメインリンク時にpageTracker有効化
		//$("a,area").blankLogToGoogle();
	//アンカーリンクをスムージング
		$("a[href^=#]").smoothScroll();
	//対象の要素をスクロールに追従するようにする
		//$("#fixBox").fixPosition("stopperID","normal");
	}
	//onload
	$(function() {
		config();
		switch (jQuery("body").attr("id")) {
			case "pageID":
				//eachPageFunction
			break;
			case "pageID":
				//eachPageFunction
			break;
		}
	});
})(jQuery);

function easySwapImage (targetID) {
	var block = document.getElementById(targetID);
	var elms = $(block).find("a[@rel=ESIMG]").each(function(){
		var btImg = $(this).find('img')[0];
		var targetSrc = this.href;
		//this.href = "javascript:void(0)";
		$(this).click(function(){
			var ttt = function() {
				var btImg = $(this).find('img')[0];
				btImg.className = "ahover";
				btImg.src = $($(this).find('img')[0]).attr('dsrc');
			}
			$(block).find("a[@rel=ESIMG]").each(ttt);
			btImg.src = $($(this).find('img')[0]).attr('hsrc');
			btImg.className = "";
			$(btImg).unbind('mouseout');
			$(btImg).unbind('mouseover');
//-----------
			hideAndSeek("block-"+this.className,"blocks");
//-----------
			initRollOvers('madoriBtn');
		});
	});
	$($(block).find("a[@rel=ESIMG]")[0]).click();
}

function hideAndSeek (objId, objsclass) {
	$("div."+objsclass).css("display","none");
	$("div#"+objId).css("display","block");
	//$("div#"+objId).fadeIn();
}

$(function(){
	if($("body #roomplan")[0]){
		$(".madoriArea").hide();

		var own = $("#planBtArea a:first img.ahover")[0];

		$("img.ahover")	
			.click(function(){
				$(own)
					.attr("src",$(own).attr("dsrc"))
					.easyOver();
				$(this)
					.attr("src",$(this).attr("hsrc"))
					.removeEasyOver();
				own = this;
			})
		.end();
		$("#planBtArea a").click(function(){
			var planType = $(this).attr("class");
			$(".madoriArea").hide();
			$("#"+planType).show();
		});
	}
})
onload = function () {
	if($("body #roomplan")[0]){
		$("#planBtArea a:first").click();
		$("#planBtArea a:first img.ahover").each(function(){
			$(this).attr("src",$(this).attr("hsrc"));
		})
	}
}