/** |READ ME| **********************************************************************************************************

"住宅情報館"

JavaScript File
コンテンツ制御用JS

Ver.201107

------------------------------------------------------------------------------------------------------------------------

このファイルは、『コンテンツ制御用JS』が記述されています。

01. ロールオーバー
02. フリップフロップ
03. 物件検索
04. トピックス
05. おすすめ物件

********************************************************************************************************** |READ ME| **/





/** |01. ロールオーバー| >> ******************************************************************************* >> START **/


function rollover(){

	var image_cache = new Object();

	$('.swap a img, .swap input[type="image"]').not('[src*="_on."]').each(function(i){

		//デフォルトで表示する画像を取得
		var img = $(this).attr('src');

		//ロールオーバー時に表示する画像を取得
		var dot = img.lastIndexOf('.');
		var img_on = img.substr(0, dot) + '_on' + img.substr(dot, 4);

		//プリロード
		image_cache[img] = new Image();
		image_cache[img].src = img_on;

		//イベント発生時の動作設定
		$(this).hover(
			function(){$(this).not('[src*="_ac."]').attr('src',img_on);},
			function(){$(this).not('[src*="_ac."]').attr('src',img);}
		);

	});

}


/** |01. ロールオーバー| << ********************************************************************************* << END **/





/** |02. フリップフロップ| >> ***************************************************************************** >> START **/


function flipflop(){

	$('.flipflop a').click(function(){
		$('html,body').scrollTop(0);
		return false;
	});

}


/** |02. フリップフロップ| << ******************************************************************************* << END **/





/** |03. 物件検索| >> ************************************************************************************* >> START **/


function searchBox(){

	//初期化
	$('.searchbox .category a img:eq(0)').attr('src',function(i){return $(this).attr('src').replace('.','_ac.');});
	$('.searchbox .type').css('cssText', 'display:none !important;');
	$('.searchbox .type:eq(0)').show();

	$('.searchbox .category a').each(function(i){

		$(this).click(function(){

			$('.searchbox .category a img[src*="_ac"]').attr('src',function(i){return $(this).attr('src').replace('_ac.','.');});

			var key =($(this).children('img').attr('src').indexOf('_on.') != -1)?'_on.':'.';
			$(this).children('img').attr('src',function(i){return $(this).attr('src').replace(key,'_ac.');});

			$('.searchbox .type').css('cssText', 'display:none !important;');
			$('.searchbox #' + $(this).attr('rel')).show();

			return false;

		});

	});

}


/** |03. 物件検索| << *************************************************************************************** << END **/





/** |04. トピックス| >> *********************************************************************************** >> START **/


function topicsDeco(){
	$('.topics dl:odd').css('background-color','#F4F5F6');
}


/** |04. トピックス| << ************************************************************************************* << END **/






/** |05. おすすめ物件| >> ********************************************************************************* >> START **/


function recommendBox(){

	//初期化
	$('.recommend .area ul').addClass($('.recommend .area li:eq(0) a').attr('rel'));
	$('.recommend .area img:eq(0)').attr('src',function(i){return $(this).attr('src').replace('.','_ac.');});
	$('.recommend .estate').hide();
	$('.recommend .estate:eq(0)').show();
	$('.recommend .estate div.scrolling').css({'height':'153px','overflow':'auto'});
	fleXenv.initByClass('scrolling');

	$('.recommend .area a').each(function(i){

		$(this).click(function(){

			//スタイルセット
			$('.recommend .area ul').removeAttr('class');
			$('.recommend .area ul').addClass($(this).attr('rel'));

			//ボタンセット
			$('.recommend .area img[src*="_ac"]').attr('src',function(i){return $(this).attr('src').replace('_ac.','.');});
			$(this).children('img').attr('src',function(i){return $(this).attr('src').replace('.','_ac.');});

			//物件情報セット
			$('.recommend .estate').hide();
			$('.recommend dd#' + $(this).attr('rel')).show();
			fleXenv.initByClass('scrolling');

			return false;

		});

	});

}


/** |05. おすすめ物件| << *********************************************************************************** << END **/

