// サイズ変更処理
var FS_enabled = false;
var FS_object = null;
var FS_embed = null;


/**
 * ステージサイズ変更処理に関する初期化処理
 * id : ステージに使用しているタグのID
 */
function FS_initialize( id ){
/** Safariで「namedItem」がサポートされていない
	FS_object = document.getElementsByTagName("object").namedItem( id );
	FS_embed = document.getElementsByTagName("embed").namedItem( id );
*/
	FS_object = document.getElementsByTagName("object")[id];
	FS_embed = document.getElementsByTagName("embed")[id];

	FS_enabled = ( FS_object != null || FS_embed != null );
	if( FS_object )
		FS_object.style.display = "block";
	if( FS_embed )
		FS_embed.style.display = "block";
	return FS_enabled;
}

/**
 * Flashのステージサイズ変更処理
 * width : ステージの幅
 * height: ステージの高さ
 */
function FS_setSize( width , height ){
	if( !FS_enabled || width < 1 || height < 1 ) return false;
	
	if( FS_object ){
		FS_object.getAttributeNode("width").value = width;
		FS_object.getAttributeNode("height").value = height;
	}
	if( FS_embed ){
		FS_embed.getAttributeNode("width").value = width;
		FS_embed.getAttributeNode("height").value = height;
	}
	return true;
}

/**
 * ウインドウのリサイズイベント処理
 */
var resize = function() {
	var width = getWidth();
	var height = getHeight();

//	if(height<768){
	if(height<644){
		height = "644px";
	}
//	if( width<1024 ) {
	if( width<995 ) {
		width = "995px";
	}
	FS_setSize(width, height);
};

/**
 * 表示領域の幅を取得
 */
function getWidth() {
	if( document.documentElement.clientWidth ) {
		// for IE
		return document.documentElement.clientWidth;
	} else {
		// for Safari, Firefox
		return document.body.clientWidth;
	}
}

/**
 * 表示領域の高さを取得
 */
function getHeight() {
	if( document.documentElement.clientHeight ) {
		// for IE
		return document.documentElement.clientHeight;
	} else {
		// for Safari, Firefox
		return document.body.clientHeight;
	}
}

/**
 * ウインドウリサイズイベント設定処理
 * window.onloadイベントから呼び出すこと
 */
function FS_setEvent() {
	FS_initialize( "flashContents" );
	if( document.all ) {
		// for IE
		window.attachEvent( "onresize", resize );
	} else {
		window.onresize = resize;
	}
}
