/**=========================================

 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();
	
	
	/**
	 * 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;
	
	
	
	
	
})

})();

//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; 
}
