// JavaScript Document

/* include  */

$(function( ){
	
	$("div#box_header").load("/include/header.html");
	
	$("div#box_footer").load("/include/footer.html");
	
	$("p.eswsAccess").wrap("<div class='box_access'></div>");

});

jQuery(document).ready(function() {
	jQuery('#slider').bxSlider({
		auto: true,
	    autoControls: false,
	    pager: true,
	    mode: 'horizontal', /* fade,vertical など */
	    speed: 1000,
	    prevText: '&lt;',
	    nextText: '&gt;',
	    pause:	4000,
	    easing: 'jswing',
	    autoHover: true
	});
	
	jQuery(document).ready(function(){
    	jQuery(".bx-prev,.bx-next").wrapAll("<div class='prev-next'></div>");
  	});
  	
  	jQuery('.green-button').append('<span class="hover">Back to Article</span>').each(function () {
  		var span = jQuery('span.hover', this).css('opacity', 0);
  		jQuery(this).hover(function () {
    		span.stop().fadeTo(500, 1);
 		}, function () {
   	span.stop().fadeTo(500, 0);
  		});
	});
});

// 駅名でさがす
$(function() {
	$(".img_map").hide();
	$("#map_tab_rail_01").show();
	$("#tab_rail_01").addClass('active');
	
    $("#box_ttl_tab li").click(function() {
    	var str = $(this).attr("id");
    	var contId = '#map_'+ str;
    	$(".img_map").hide();
        $(contId).show();
        $("#box_ttl_tab li").removeClass('active');
        $(this).addClass('active')
    });
});

// この街に住みたい
$(function() {
	$(".town_info").css('display','none');
	$("#town_tab_kiyose").css('display','block');
	$("#tab_kiyose").addClass('select');
	
    $("#box_town_info li").click(function() {
    	var str = $(this).attr("id");
    	var contId = '#town_'+ str;
    	$(".town_info").css('display','none');
        $(contId).css('display','block')
        $("#box_town_info li").removeClass('select');
        $(this).addClass('select')
    });
});

$(document).ready(function() {
	$("#inner_keyword p:nth-child(3n)").addClass("btn_right");
	$("ul.eswsPropertyInfo li:nth-child(3n)").addClass("info_right");
});


$(function(){
	$("#box_osusume").html(  $("#box_osusume").html().replace( /一戸建て/ig , '<span class="icon_house">一戸建て</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /マンション\(居住用\)/ig , '<span class="icon_mansion">マンション(居住用)</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /アパート\(居住用\)/ig , '<span class="icon_apart">アパート(居住用)</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /アパート\(事業用\)/ig , '<span class="icon_apart">アパート(事業用)</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /アパート（居住用）/ig , '<span class="icon_apart">アパート(居住用)</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /アパート（事業用）/ig , '<span class="icon_apart">アパート(事業用)</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /貸家\(居住用\)/ig , '<span class="icon_rent">貸家(居住用)</span>' )  );
	$("#box_osusume").html(  $("#box_osusume").html().replace( /　/ig , ' ' )  );
});

//写真リサイズ
jQuery.event.add(window, "load", function(){
    var fw = 192;        //fixed width
    var fh = 144;        //fixed height
    var sl = '.eswsImageArea img'; //selector
    $(sl).each(function(){
        var w = $(this).width();
        var h = $(this).height();
        if (w >= h) {
            $(this).width(fw);
        } else {
            $(this).height(fh);
        }
    });
});

$(document).ready(
	function(){
	$('div#box_utility ul').innerfade ({
	animationtype: 'fade', // アニメーションの種類（slide or fade：デフォルト）
	speed: 'slow', // フェイドスピード（ミリ秒 or slow,normal：デフォルト,fast）
	timeout: 3000, // フェイドにかかる時間（ミリ秒、2000：デフォルト）
	type: 'sequence', // スライドショーの種類（sequence：デフォルト or random）
	containerheight: '1.6em' //囲んだ要素の高さ、auto：デフォルト
	});
} );


