/* 
===================================================== 
レイヤ制御
===================================================== 
*/
var eventTimer;
var restScroll=0;

function Scroll(base,move){
	var obj_base  = getElemPosition(base);
	var elem_move = document.getElementById(move);
	var obj_move  = getElemPosition(elem_move);

	restScroll = obj_move.y-obj_base.y;
	eventTimer = setInterval(setScrollPosition,10);
}
function setScrollPosition() {
	var moveValue=0;
	if(Math.abs(restScroll)>80){
		moveValue = (restScroll>0)?20:-20;
	}else{
		moveValue = Math.round(restScroll/4);
	}
	parent.scrollBy(0,moveValue);
	restScroll = (restScroll>0)?restScroll-moveValue:restScroll-moveValue;
	if(moveValue==0){
		clearInterval(eventTimer);
		restScroll=0;
	}
}
function getElemPosition(elem) {
	var obj = new Object();
	obj.x = elem.offsetLeft;
	obj.y = elem.offsetTop;
	while(elem.offsetParent) {
		elem = elem.offsetParent;
		obj.x += elem.offsetLeft;
		obj.y += elem.offsetTop;
	}
	return obj;
}
/* 
===================================================== 
プリロードおよびイメージチェンジ
===================================================== 
*/
	images = new Array();

	images[01] = new Image(); images[01].src = "/common/img/tkj_g_header/sitemap_off.gif";
	images[02] = new Image(); images[02].src = "/common/img/tkj_g_header/sitemap_on.gif";
	images[03] = new Image(); images[03].src = "/common/img/tkj_g_header/contact_off.gif";
	images[04] = new Image(); images[04].src = "/common/img/tkj_g_header/contact_on.gif";
	images[05] = new Image(); images[05].src = "/common/img/tkj_g_header/advance_search_off.gif";
	images[06] = new Image(); images[06].src = "/common/img/tkj_g_header/advance_search_on.gif";
	images[07] = new Image(); images[07].src = "/common/img/tkj_g_header/search_off.gif";
	images[08] = new Image(); images[08].src = "/common/img/tkj_g_header/search_on.gif";
	images[09] = new Image(); images[09].src = "/common/img/detail/about_hangata.gif";
	images[10] = new Image(); images[10].src = "/common/img/detail/about_hangata_on.gif";
	images[11] = new Image(); images[11].src = "/common/img/detail/buy_online.gif";
	images[12] = new Image(); images[12].src = "/common/img/detail/buy_online_on.gif";
	images[13] = new Image(); images[13].src = "/common/img/detail/btn_sample_read.gif";
	images[14] = new Image(); images[14].src = "/common/img/detail/btn_sample_read_on.gif";
	images[15] = new Image(); images[15].src = "/common/img/detail/btn_sample_listen.gif";
	images[16] = new Image(); images[16].src = "/common/img/detail/btn_sample_listen_on.gif";
	images[17] = new Image(); images[17].src = "/common/img/detail/btn_sample_movie.gif";
	images[18] = new Image(); images[18].src = "/common/img/detail/btn_sample_movie_on.gif";
	images[19] = new Image(); images[19].src = "/common/img/detail/btn_index_next.gif";
	images[20] = new Image(); images[20].src = "/common/img/detail/btn_index_next_on.gif";
	images[21] = new Image(); images[21].src = "/common/img/detail/btn_fontsize_s.gif";
	images[22] = new Image(); images[22].src = "/common/img/detail/btn_fontsize_s_over.gif";
	images[23] = new Image(); images[23].src = "/common/img/detail/btn_fontsize_m.gif";
	images[24] = new Image(); images[24].src = "/common/img/detail/btn_fontsize_m_over.gif";
	images[25] = new Image(); images[25].src = "/common/img/detail/btn_fontsize_l.gif";
	images[26] = new Image(); images[26].src = "/common/img/detail/btn_fontsize_l_over.gif";
	images[27] = new Image(); images[27].src = "/common/img/detail/buy_online_suggest.gif";
	images[28] = new Image(); images[28].src = "/common/img/detail/buy_online_suggest_on.gif";
	images[29] = new Image(); images[29].src = "/common/img/btn_search_result_buy.gif";
	images[30] = new Image(); images[30].src = "/common/img/btn_search_result_buy_on.gif";
	images[31] = new Image(); images[31].src = "/common/img/searchindex/submit_search.gif";
	images[32] = new Image(); images[32].src = "/common/img/searchindex/submit_search_on.gif";

	images[33] = new Image(); images[33].src = "/common/img/detail/btn_index_close.gif";
	images[34] = new Image(); images[34].src = "/common/img/detail/btn_index_close_on.gif";
	
	
	function ChangeImage(obj,suf) {
		eval("document." + obj + ".src = images[suf].src");
	}

	function fNWin(fUrl, fX, fY, fScBar){
		newWin = window.open (fUrl+".html","","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+fScBar+",resizable=0,width="+fX+",height="+fY); 
		newWin.focus()
	}

/* 
===================================================== 
フォントサイズ変更
===================================================== 
*/

	function setFont(id, s)
	{
		var o = document.getElementById(id);
		if (o) o.style.fontSize = s;
	}

	var FontSize = new Array (
		new Array ( 's' , '0') , new Array ( 'm' , '1') , new Array ( 'l' , '0') 
	)
	
	var ElementSize = {
		'detail_price'           : ['12px', '14px', '16px'],
		'detail_specification'   : ['9px', '11px', '13px'],
		'detail_shopping_notice' : ['8px', '10px', '12px'],
		'detail_buy_comment'     : ['8px', '10px', '12px'],
		'detail_genre'           : ['10px', '12px', '14px'],
		'detail_title'           : ['22px', '24px', '26px'],
		'detail_subtitle'        : ['14px', '16px', '18px'],
		'detail_main_author'     : ['12px', '14px', '16px'],
		'detail_aori'            : ['10px', '12px', '14px'],
		'detail_introduction'    : ['10px', '12px', '14px'],
		'detail_news'            : ['10px', '12px', '14px'],
		'detail_campaign'        : ['10px', '12px', '14px'],
		'detail_index'           : ['10px', '12px', '14px'],
                'detail_index_next'      : ['10px', '12px', '14px'],
		'detail_master'          : ['9px', '11px', '13px'],
		'detail_master_list'     : ['9px', '11px', '13px'],
		'detail_ranking'         : ['10px', '12px', '14px'],
		'detail_ranking_comment' : ['8px', '10px', '12px']
	};
	
	function setFonts(S)  { 
		for (key in ElementSize)
			setFont(key, ElementSize[key][S]);

		for (i=0;i<FontSize.length;i++){
			 if(i != S ){
				FontSize[i][1] = 0
			}
			else {
				FontSize[i][1] = 1
			}
		}

		var Str
		Str = '<ul id="fch"><li>'
		if( S != 0 ){
			Str = Str + '<a href="javascript:setFonts(\'0\')" OnMouseOver="ChangeImage(\'fontsize_s\',22)" OnMouseOut="ChangeImage(\'fontsize_s\',21)"><img src="/common/img/detail/btn_fontsize_s.gif" alt="フォントサイズ：小" title="フォントサイズ：小" name="fontsize_s"></a></li>' }
		else {
			Str = Str +	'<img src="/common/img/detail/btn_fontsize_s_on.gif" alt="フォントサイズ：小" title="フォントサイズ：小" name="fontsize_s"></li>'
		}
		if( S != 1 ){
			Str = Str +'<li><a href="javascript:setFonts(\'1\')" OnMouseOver="ChangeImage(\'fontsize_m\',24)" OnMouseOut="ChangeImage(\'fontsize_m\',23)"><img src="/common/img/detail/btn_fontsize_m.gif" alt="フォントサイズ：中" title="フォントサイズ：中" name="fontsize_m"></a></li>'
		}
		else {
			Str = Str +'<li><img src="/common/img/detail/btn_fontsize_m_on.gif" alt="フォントサイズ：中" title="フォントサイズ：中" name="fontsize_m"></li>'
		}
		if( S != 2 ){
			Str = Str +'<li><a href="javascript:setFonts(\'2\')" OnMouseOver="ChangeImage(\'fontsize_l\',26)" OnMouseOut="ChangeImage(\'fontsize_l\',25)"><img src="/common/img/detail/btn_fontsize_l.gif" alt="フォントサイズ：大" title="フォントサイズ：大" name="fontsize_l"></a></li></ul>'
		}
		else {
			Str = Str +'<li><img src="/common/img/detail/btn_fontsize_l_on.gif" alt="フォントサイズ：大" title="フォントサイズ：大" name="fontsize_l"></li></ul>'
		}
		document.getElementById('float_font_changer').innerHTML = Str
	}
/* 
===================================================== 
EOF
===================================================== 
*/
