/*
***************************************************
	HOME用関数
	Atsushi Yamazaki(at4@jc4.so-net.ne.jp)
***************************************************
	2009/03/17	初版
	2011/01/23	大幅改訂
***************************************************
*/

var imgWidth 	= 950;
var imgHeight	= 475;
var imgPadding	= 15;

var blockHeight			= 0;
var divPaddingWidth		= 8;
var divPaddingHeight	= 4;

var home_container;
var caption_title, caption_year;
var block_title, block_year;

// キャプション背景のサイズ設定
function setBlockSize() {
	blockHeight	= Math.max(caption_title.offsetHeight, caption_year.offsetHeight);
	blockHeight	+= divPaddingHeight * 2;
	
	// プロパティの設定
	// setDivPositionで使用するため
	block_title.width	= caption_title.offsetWidth + divPaddingWidth * 5;
	block_title.height	= blockHeight;
	
	block_year.width	= caption_year.offsetWidth + divPaddingWidth * 2;
	block_year.height	= blockHeight;
	
	// 実際の値の設定
	block_title.style.width		= block_title.width + 'px';
	block_title.style.height	= block_title.height + 'px';
	
	block_year.style.width		= block_year.width + 'px';
	block_year.style.height		= block_year.height + 'px';
}

// キャプション全体の移動
function setDivPosition() {

	// 座標算出
	titleLeft	= imgWidth - block_year.width - 1 - block_title.width;
	titleTop	= imgHeight - imgPadding - block_title.height;
	
	yearLeft	= imgWidth - block_year.width;
	yearTop		= imgHeight - imgPadding - block_year.height;
	
	// 各要素の配置
	block_title.style.left	= titleLeft + 'px';
	block_title.style.top	= titleTop + 'px';
	
	block_year.style.left	= yearLeft + 'px';
	block_year.style.top	= yearTop + 'px';
	
	caption_title.style.left	= titleLeft + divPaddingWidth*4 + 'px';
	caption_title.style.top		= titleTop + divPaddingHeight + 'px';
	
	caption_year.style.left		= yearLeft + divPaddingWidth + 'px';
	caption_year.style.top		= yearTop + divPaddingHeight + 'px';
}

function init() {
	home_container	= document.getElementById('home_container');
	caption_title	= document.getElementById('caption_title');
	caption_year	= document.getElementById('caption_year');
	block_title		= document.getElementById('block_title');
	block_year		= document.getElementById('block_year');
	
	setBlockSize();
	setDivPosition();
}

window.onload = init;
