/**
 * index.js
 */
 
$(function(){
	resizeBG();
	init_fade();
	setTimeout('newsSlide()', 1000);
	$('#newsList').infoDisp({url:"http://suzuya-wedding.com/news/recent_json"});
});

// resizeBG
function resizeBG(){
	var df_W = 960;
	var df_H = 800;
	var wrap_W = $(window).width()-240;
	var wrap_H = $(window).height();
	var $bg_img = $('#bgImg img');
	if( wrap_W <= df_W && wrap_H <= df_H ){
		$bg_img.width(df_W).height(df_H);
	}
	else{
		if( wrap_W/wrap_H > df_W/df_H ) $bg_img.width(wrap_W).height(wrap_W*df_H/df_W);
		else $bg_img.width(wrap_H*df_W/df_H).height(wrap_H);
	}
}
$(window).resize(function(){
	resizeBG();
});

// init_fade
$('head').append('<style type="text/css">#bgImg img, #catchcopy, #bgCaption{display:none;}</style>');
function init_fade(){
	var fade_time = 1000;
	$('#bgImg img, #bgCaption').css("opacity", 0).show();
	$('#bgImg img, #bgCaption').animate({"opacity":1}, fade_time, function(){
		setTimeout(function(){ $('#catchcopy').fadeIn(fade_time); }, 1500);
	});
}

// newsSlide
function newsSlide(){
	var $wrap = $('#newsWrap');
	var $wrap_inner = $('#newsInner');
	$wrap.find('h3').css("background-position", "20px top");
	$wrap_inner.stop().animate({"height":0,"padding-bottom":0,"opacity":0}, 1000);
	$wrap.hover(
		function(){
			$wrap.find('h3').css("background-position", "20px bottom");
			var wrap_inner_height = 0;
			$('.inner').each(function(){
				if(wrap_inner_height < $(this).height() ) wrap_inner_height = $(this).height();
			});
			$wrap_inner.stop().animate({"height":wrap_inner_height,"padding-bottom":15,"opacity":1});
		},
		function(){
			$wrap.find('h3').css("background-position", "20px top");
			$wrap_inner.stop().animate({"height":0,"padding-bottom":0,"opacity":0});
		}
	);
}

