var site_url = "http://www.square-enix.co.jp/fm/fm2089/bp/";

var swf_url = site_url + "bp_fm2089.swf";
var swf_url2 = site_url + "fm_story.swf";
var news_text = "http://www.square-enix.co.jp/fm/fm2089/cgi-bin/bp/data/bp_news.txt";

//Connection ID
var dobj = new Date();
var dnum = dobj.getTime();
var str;
var flvars =
'txt_url='+news_text+'&lc_id='+dnum+'&st1=http://www.square-enix.co.jp/fm/fm2089/bp/fm_1rainsan.swf&st2=http://www.square-enix.co.jp/fm/fm2089/bp/fm_2graykun.swf&st3=http://www.square-enix.co.jp/fm/fm2089/bp/fm_3nmou.swf';

//Visible
var flash_layer = false;

str  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="140" height="220" id="bp_fm2089" align="middle">';
str += '<param name="allowScriptAccess" value="always" />';
str += '<param name="movie" value="'+swf_url+'" />';
str += '<param name="quality" value="high" />';
str += '<param name=FlashVars value="'+flvars+'" />';
str += '<param name="wmode" value="transparent" />';
str += '<embed src="'+swf_url+'" quality="high" width="140" height="220" ';
str += 'FlashVars="'+flvars+'" ';
str += 'name="bp_fm2089" align="middle" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
str += '</object>';

document.open();
document.write(str);
document.close;

function css1_compat(){
	if (document.compatMode) return (document.compatMode=="CSS1Compat");
	return 0;
}
function doc_body(){
	if (css1_compat()) return document.documentElement;
	if (document.body) return document.body;
	return 0;
}

//Layer Set
function set_layer(){
	var obj, ww, st, ht;
	ww = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
	ht = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
	st = document.body.scrollTop || document.documentElement.scrollTop;
	lf = document.body.scrollLeft || document.documentElement.scrollLeft;

	obj = document.getElementById('fm2089flash').style;
	obj.left = lf+'px';
	obj.top = st+'px';
	if (flash_layer) {
		obj.width = ww+'px';
		obj.height = ht+'px';
	} else {
		obj.width = '1px';
		obj.height = '1px';
	}
}

//Layer ON/OFF
function show_layer(f){
	flash_layer = f;
	set_layer();
}

//Create Layer
window.onload = function() {
	var htm;
	
	htm = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="flalayer" align="middle">';
	htm += '<param name="allowScriptAccess" value="always" />';
	htm += '<param name="movie" value="'+swf_url2+'" />';
	htm += '<param name="quality" value="high" />';
	htm += '<param name=FlashVars value="lc_id='+dnum+'" />';
	htm += '<param name="wmode" value="transparent" />';
	htm += '<embed src="'+swf_url2+'" quality="high" width="100%" height="100%" ';
	htm += 'FlashVars="lc_id='+dnum+'" ';
	htm += 'name="flalayer" align="middle" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	htm += '</object>';
	
	var ele = document.createElement('div');
	ele.setAttribute('id','fm2089flash');
	ele.innerHTML = htm;
	ele.style.position = 'absolute';
	ele.style.width='800px';
	ele.style.height='480px';
	ele.style.visibility = 'visible';
	document.body.appendChild(ele);

	//Window Resize
	window.onresize = function(){
		set_layer();
	}
	window.onscroll = window.onresize;
	set_layer();
}

//Flash Start
function start_flash(){
	flash_layer = true;
	set_layer();
}
//Flash END
function end_flash(){
	flash_layer = false;
	set_layer();
}
