var dispnum = 0;
var message = "";

$(function(){
	$('.rollover').rollover();
	$('#main_2_1_1 img').rollover();


	$("#map1 area").mouseout(function(){
		$("#map_area").attr("src","img/top/map/map.jpg");
	});

	$("#map1 area").mouseover(function(){

		$("#map_area").attr("src","img/top/map/map_" + $(this).attr("id") + ".jpg");
	});

	displist();
	setInterval("displist()",12000);
	setTimeout("billboard_change()",5000);

});


function displist(){

	$("#sokuholine div").fadeOut(700,function(){
		if(dispnum >4){dispnum = 0;}

		$(this).html($("#sokuhodata ul li:eq(" + dispnum + ")").html())
			.css({"left":"400px","display":"inline-block"})
			.animate({"left":"0px"},"slow");
		dispnum=dispnum + 1;
	});
}

function billboard_change(){

	$("#header_3").fadeOut(1000);

	$("#header_4_1_1 img").click(function(){
		$val = $(this).attr('src');
		if($val == "img/top/ad/openhouse_big.jpg"){
			document.location = "http://myhome.ejoho.co.jp/openhouse/";
		}
	});

	$("#header_4_1_1").mouseover(function(){
		$("header_4_1_2 div").trigger("pause",true);
	});
	$("#header_4_1_1").mouseout(function(){
		$("header_4_1_2 div").trigger("pause",false);
	});
	$('#header_4_1_2 div').carouFredSel({
		prev: '#carousel_up', //id="prev"をもつDOM要素にprevを設定
		next: '#carousel_down',//id="next"をもつDOM要素にprevを設定
		direction: "up",
		scroll:{
			items:1,
			duration:1000,
			pauseDuration:2000,
			pauseOnHover:true
		},
		items:{
			visible:4,
			minimum:2
		},
		height:310,

		auto:{

			pauseDuration:7000, //画像が切り替わる間隔(ミリ秒)
			onAfter:function(oldItems, newItems){
				//alert(newItems);
				var id = newItems.eq(0).attr("id");
				$("#header_4_1_1 img").animate({opacity:0.5},100)
						.attr("src", "img/top/ad/" + id + "_big.jpg")
						.animate({opacity:1},100);
			}
		}
	});

	$(".carousel_item").mouseover(function(){

		var v = $(this).attr("id");

		$("#header_4_1_1 img").animate({opacity:0.5},100)
			.attr("src", "img/top/ad/" + v + "_big.jpg")
			.animate({opacity:1},100);
		$("header_4_1_2 div").trigger("pause",true);
	});

	$(".carousel_item").mouseout(function(){
		$("header_4_1_2 div").trigger("pause",false);
	});
}



function newYear(){

	message = "";

	Date = new Date();
    M = Date.getMonth() + 1;
	D = Date.getDate();

	if (M == 12 && D >26)
	{
		message = "<div id='announce'>【お知らせ】年内の営業は28日まで。新年は1月5日より営業しております。</div>";
	}
	else if( M == 1 && D < 10)
	{
		message = "<div id='announce'>【お知らせ】あけましておめでとうございます。新年は1月5日より営業しております。</div>";
	}

	$("header").append(message);
}
