






//--------------------------------------
//  初期化
//--------------------------------------
var MY_FLASH_CONTENTS_MIN_WIDTH = 986 ;
var b100percent = false ;

var bShow = false ;
var isMSIE = /*@cc_on!@*/false ;
var isIE6 ;
var isSafari = /a/.__proto__=='//' ;




//--------------------------------------
//  初期化
//--------------------------------------
function init( )
{
	$(window).resize( xResize ) ;
	
	b100percent = ( document.all ) ? true : false ;
	
	if ( isMSIE )
	{
		isIE6 = ( typeof document.documentElement.style.maxHeight == "undefined" ) ;
	}

	$("#holderbg").click(
		function( )
		{
			xHide( ) ;
		}
	) ;
}







//--------------------------------------
//  リサイズ処理
//--------------------------------------
function xResize( )
{
	if ( bShow )
	{
		var nX = Math.floor( ( xGetWindowSizeWidth( ) - xGetFlashWidth( ) ) / 2 ) ;
		nX = Math.max( 0, nX ) ;
		
		$("#holder").attr( "style", "position:absolute;top:0;left:"+nX+"px;width:"+xGetFlashWidth( )+"px;height:"+xGetFlashHeight( )+"px;display:block" ) ;
		
		if ( xGetWindowSizeWidth( ) < MY_FLASH_CONTENTS_MIN_WIDTH )
		{
			$("#holderbg").attr( "style", "position:absolute;top:0;left:0;width:"+xGetDocumentSizeWidth( )+"px;height:"+xGetDocumentSizeHeight( )+"px;display:block" ) ;
			xShowScrollbar( "scroll" ) ;
		}
		else
		{
			$("#holderbg").attr( "style", "position:absolute;top:0;left:0;width:"+xGetWindowSizeWidth( )+"px;height:"+xGetDocumentSizeHeight( )+"px;display:block" ) ;
			xHideScrollbar( ) ;
		}
		
		if ( b100percent )
		{
			$("#externalfla").attr( "style", "width:"+xGetFlashWidth( )+"px;height:"+xGetFlashHeight( )+"px" ) ;
		}
	}
}







//--------------------------------------
//  表示
//--------------------------------------
var show_str = "" ;

function xShow( _show_str )
{
	show_str = _show_str ;
	
	bShow = true ;
	
	xHideScrollbar( ) ;
	
	$("#holderbg").attr( "style", "position:absolute;width:"+xGetDocumentSizeWidth( )+"px;height:"+xGetDocumentSizeHeight( )+"px;display:block" ) ;
	
	//if ( isIE6 )
	if ( isMSIE )
	{
		xDoShow( ) ;
	}
	else
	{
		$("#holderbg").hide( ) ;
		$("#holderbg").fadeIn( "fast", xDoShow ) ;
	}
}

function xDoShow( )
{
	var nX = Math.floor( ( xGetWindowSizeWidth( ) - xGetFlashWidth( ) ) / 2 ) ;
	nX = Math.max( 0, nX ) ;
	
	$("#holder").attr( "style", "position:absolute;top:0;left:"+nX+"px;width:"+xGetFlashWidth( )+"px;height:"+xGetFlashHeight( )+"px;display:block;" ) ;
	$("#externalfla").attr( "style", "width:"+xGetFlashWidth( )+"px;height:"+xGetFlashHeight( )+"px;display:block" ) ;
	
	setTimeout( xDoShowToFla, 1.5 * 1000 ) ;
}

function xDoShowToFla( )
{
	var player = document.all ? window['externalfla'] : document['externalfla'] ;
	player.loadContents( show_str ) ;
}







//--------------------------------------
//  非表示
//--------------------------------------

/**
 * FLASHへ閉じる旨のメッセージを送る
 */
function xHide( )
{
	var player = document.all ? window['externalfla'] : document['externalfla'] ;
	player.hideContents( ) ;
}

/**
 * FLASHから閉じてOKとの信号を受信
 */
function xDoHide( )
{
	bShow = false ;
	
	//if ( isIE6 )
	if ( isMSIE )
	{
		xHideComplete( ) ;
	}
	else
	{
		$("#holderbg").fadeOut( 1, xHideComplete ) ;
	}
}

/**
 * コンテンツを消去
 */
function xHideComplete( )
{
	var nX = Math.floor( ( xGetWindowSizeWidth( ) - xGetFlashWidth( ) ) / 2 ) ;
	nX = Math.max( 0, nX ) ;
	
	$("#holder").attr( "style", "position:absolute;top:0;left:"+nX+";width:"+xGetFlashWidth( )+"px;height:"+xGetFlashHeight( )+"px" ) ;
	$("#holderbg").attr( "style", "display:none" ) ;
	$("#externalfla").attr( "style", "width:"+xGetFlashWidth( )+"px;height:"+xGetFlashHeight( )+"px" ) ;
	
	if ( document.all )
	{
		so.write ( "holder" ) ;
	}

	xShowScrollbar( ) ;
}







//--------------------------------------
//  flashの横幅を取得
//--------------------------------------
function xGetFlashWidth( )
{
	var nW ;
	
	if ( b100percent )
	{
		nW = Math.max( MY_FLASH_CONTENTS_MIN_WIDTH, xGetWindowSizeWidth( ) ) ;
	}
	else
	{
		nW = MY_FLASH_CONTENTS_MIN_WIDTH ;
	}
	
	return nW ;
}

//--------------------------------------
//  flashの縦幅を取得
//--------------------------------------
function xGetFlashHeight( )
{
	var nH = Math.min( 680, Math.max( 630, xGetWindowSizeHeight( ) ) ) ;
	return nH ;
}







//--------------------------------------
//  documentの横幅を取得
//--------------------------------------
function xGetDocumentSizeWidth( )
{
	return $(document).width( ) ;
}

//--------------------------------------
//  documentの縦幅を取得
//--------------------------------------
function xGetDocumentSizeHeight( )
{
	return $(document).height( ) ;
}







//--------------------------------------
//  windowの横幅を取得
//--------------------------------------
function xGetWindowSizeWidth( )
{
	return $(window).width( ) ;
}

//--------------------------------------
//  windowの縦幅を取得
//--------------------------------------
function xGetWindowSizeHeight( )
{
	return $(window).height( ) ;
}







//--------------------------------------
//  横スクロールバーを消去
//--------------------------------------
function xHideScrollbar( )
{
	if ( document.all || isSafari )
	{
		if ( xGetWindowSizeWidth( ) > MY_FLASH_CONTENTS_MIN_WIDTH )
		{
			$("html").css( "overflow-x", "hidden" ) ;
		}
	}
}

//--------------------------------------
//  横スクロールバーを表示
//--------------------------------------
function xShowScrollbar( value_str )
{
	var myValue = ( ! value_str ) ? "visible" : value_str ;
	
	if ( document.all || isSafari )
	{
		$("html").css( "overflow-x", myValue ) ;
	}
}







window.onload = init ;







