/**=========================================

 filename:  init.page.top.js
 create:    2009/
 copyright: 

　ページ初期化

=========================================**/
(function(){
$(function()
{
	/**
	 * Shadowbox初期化
	 */
	Shadowbox.init({
		language:   "ja",
		players:    ['html' , 'iframe']
	});
	
	/**
	 * 各ロールオーバー処理
	 *
	 */
	if ($('#topNews').is('img')) window.cushion.addRollActionById("topNews");
	if ($('#grobalNavImg1').is('img')) window.cushion.addRollActionById("grobalNavImg1");
	if ($('#grobalNavImg2').is('img')) window.cushion.addRollActionById("grobalNavImg2");
	if ($('#grobalNavImg3').is('img')) window.cushion.addRollActionById("grobalNavImg3");
	if ($('#grobalNavImg4').is('img')) window.cushion.addRollActionById("grobalNavImg4");
	
	window.cushion.addRollActionById("topAdmission");
	window.cushion.addRollActionById("topVisit");
	
	/**
	 * 
	 * 
	 */
	//window.cushion.initTextSize();
	
	//
	if( top_assigned_obj.shop_info_content_text ) top_assigned_obj.shop_info_content_text = encodeURIComponent($( "<div>" ).html( top_assigned_obj.shop_info_content_text ).text());
	if( top_assigned_obj.shop_info_content_title_text ) top_assigned_obj.shop_info_content_title_text = encodeURIComponent($( "<div>" ).html( top_assigned_obj.shop_info_content_title_text ).text());
	if( top_assigned_obj.space_nbsp ) top_assigned_obj.space_nbsp = encodeURIComponent($( "<div>" ).html( top_assigned_obj.space_nbsp ).text());
	if( top_assigned_obj.space_emsp ) top_assigned_obj.space_emsp = encodeURIComponent($( "<div>" ).html( top_assigned_obj.space_emsp ).text());
	if( top_assigned_obj.space_ensp ) top_assigned_obj.space_ensp = encodeURIComponent($( "<div>" ).html( top_assigned_obj.space_ensp ).text());
	if( top_assigned_obj.space_thinsp ) top_assigned_obj.space_thinsp = encodeURIComponent($( "<div>" ).html( top_assigned_obj.space_thinsp ).text());
	/**
	 * flashへパラメータを渡す
	 *
	 */
	var flashvars = top_assigned_obj;
	var params = {};
	var attributes = {};
	$( "#attentionFlashPlayer" ).css( "display", "block" );
	swfobject.embedSWF( top_assigned_obj.top_swf_pass, "flashArea", "980", "417", "9.0.47", "", flashvars, params, attributes);
	
	
	/**
	 * flash スクロール中にページスクロールを止める
	 * 
	 * 
	 */
	var wheelEnabled = true;
	function wheel(event)
	{
		var delta = 0;
		if (!event)/** For IE. **/
		{
			event = window.event;
		}
		if (event.wheelDelta)/** IE/Opera. **/
		{ 
			delta = event.wheelDelta/120;
			if (window.opera)
			{
				delta = -delta;
			}else
			if (event.detail)/** Mozilla case. **/
			{ 
				delta = -event.detail / 3;
			}
		}
		/** If delta is nonzero, handle it.
		* Basically, delta is now positive if wheel was scrolled up,
		* and negative, if wheel was scrolled down.
		*/
		if( !wheelEnabled )
		{
			if (event.preventDefault)
			{
				event.preventDefault();
			}
			event.returnValue = false;
		}
	}
	/**
	 * flash から呼ばれる
	 * @param {Object} enabled
	 */
	window.wheelEnebled = function ( enabled )
	{
		wheelEnabled = enabled;
	}
	if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);
	window.onmousewheel = document.onmousewheel = wheel;
	
	
	//20110414 campaign
	//window.utils.getInfoes();
	
	//20140418
	if( window.monthly_news_length != 0 )
	{
		$( "#whatsNewArea" ).css( "display",  "block");
		/*var hei = $( "#whatsNewArea ul" ).height()-3;*/
		var hei = $( "#whatsNewArea ul" ).height();
		if( hei < 45 ) hei = 45;
		$( ".whatsNewsImgBox" )
		.css( "width", "105px" )
		.css( "height", hei)
		.css( "border-right","1px dotted #ff9029" );
		/*.css( "border", "3px solid #f08200" );*/
		$( ".whatsNewsListBox table" ).attr( "height",  (hei+6) + "px" );
	}
		
})

})();

//Flashから叩く用
function callClickHandler(id){
	var targetID = "#" + id;
	if($(targetID).attr("onclick")){
		var click = $(targetID).attr("onclick");
		var ref = {href:$(targetID).attr("href")};
		createDelegate(click, ref)();
	}else{
		$(targetID).click();
	}
}

function createDelegate(func, ref){
	var delegate = function(){
		return func.apply(ref, arguments);
	};
	delegate.func = func;
	delegate.ref = ref;
	return delegate; 
}

