
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight-header_h-footer_h;
	} else { 
		pageHeight = yScroll-header_h-footer_h;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	//alert(windowHeight+':'+header_h+':'+footer_h);
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,(windowHeight-header_h-footer_h)) 
	return arrayPageSize;
}


//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function setFlashTag(_swf,_param){
	var myTag= '<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%" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+_swf+'" />'
				+'<param name="quality" value="high" />'
				+'<param name="bgcolor" value="#000000" />'
				+'<param name="FlashVars" value="'+_param+'" />'
				+'<embed src="'+_swf+'" quality="high" FlashVars="'+_param+'" bgcolor="#000000" width="100%" height="100%" name="overlayFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	return myTag;
}
function setGetFlash(_margin_top,_lang){
	if(_lang == 'ja'){
		var myTag= '<div style="padding-top:'+_margin_top+'px;width:600px;margin:auto;"><P>このサイトは<A HREF="http://www.macromedia.com/software/flash/" TARGET="_new">Macromedia<SUP>&reg;</SUP> Flash<SUP>TM</SUP></A> を使用しておりますので、ご覧頂くにはの最新版のダウンロードが必要です。</P><P><A HREF="http://www.macromedia.com/go/getflashplayer" style="float:left;margin:5px 15px 0 0;"><IMG SRC="http://www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" WIDTH="88" HEIGHT="31" BORDER="0" alt="Flash Playerのダウンロード"></A>Flashプラグインのダウンロードはするには、下記アドレスをクリックして下さい。<br /><A HREF="http://www.macromedia.com/go/getflashplayer">http://www.macromedia.com/go/getflashplayer</a></P></div>';
	}else{
		var myTag= '<div style="padding-top:'+_margin_top+'px;width:600px;margin:auto;"><P>This web site makes use of <A HREF="http://www.macromedia.com/software/flash/" TARGET="_new">Macromedia<SUP>&reg;</SUP> Flash<SUP>TM</SUP></A> software. You have an old version of Macromedia Flash Player that cannot play the content we&#39;ve created. </P><P><A HREF="http://www.macromedia.com/go/getflashplayer" style="float:left;margin:5px 15px 0 0;"><IMG SRC="http://www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" WIDTH="88" HEIGHT="31" BORDER="0"></A>  Why not download and install the latest version now? It will only take a moment.<br /><A HREF="http://www.macromedia.com/go/getflashplayer">http://www.macromedia.com/go/getflashplayer</a> </P></div>';
	}
	return myTag;
}
function showCenterFlash(_id,_swf,_param){
	getWindowMargin();
	if(navigator.appName.indexOf("Microsoft") != -1){
		var br = "ie";
	}else{
		var br = "other";
	}
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	
	//var objBody = document.body;
	//var objOverlay = document.createElement("div");
	var flash_container = document.getElementById(_id);
	flash_container.style.display = 'block';
	//objOverlay.style.zIndex = '200';
 	flash_container.style.width = '900px';
	flash_container.style.height = (arrayPageSize[1] + 'px');
	if (hasReqestedVersion) {
		var flashTag = setFlashTag(_swf,_param);
	}else{
		if(_param.indexOf('LANG=ja') >= 0){
			var lang = 'ja';
		}
		var flashTag = setGetFlash(arrayPageSize[1]/2,lang);
		flash_container.style.color ='#FFFFFF';
	}
	flash_container.innerHTML = flashTag;
	flash_container.style.display = 'block';
}
function showFixingFlash(_id,_swf,_param,_w,_h){
	var flash_container = document.getElementById(_id);
	flash_container.style.display = 'block';
	 flash_container.style.width = _w + 'px';
	flash_container.style.height = _h + 'px';
	if (hasReqestedVersion) {
		var flashTag = setFlashTag(_swf,_param);
	}else if(Number(_h) > 50){
		var flashTag = setGetFlash();
	}
	flash_container.innerHTML = flashTag;
	flash_container.style.display = 'block';
}
function showFullFlash(_id,_swf,_param,_w,_h){
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	
	
	var flash_container = document.getElementById(_id);
	flash_container.style.display = 'block';
	flash_container.style.width = _w;
	flash_container.style.height = (arrayPageSize[1] + 'px');
	if (hasReqestedVersion) {
		var flashTag = setFlashTag(_swf,_param);
		//document.body.innerHTML =flashTag;
	}else{
		var flashTag = setGetFlash();
	}
	flash_container.innerHTML = flashTag;
	flash_container.style.display = 'block';

}

//
var header_h = 0;
var footer_h = 0;
function getWindowMargin(){
	header_h = document.getElementById('middle').offsetTop;
	header_h += Number(document.getElementById('middle').style.paddingTop);
	header_h += Number(document.getElementById('middlewrap').style.paddingTop);
	if(document.getElementById('header-flash')){
		header_h +=  parseInt(document.getElementById('header-flash').style.height);
	}
	footer_h =40;
}

window.onresize = function(){
	if(navigator.appName.indexOf("Microsoft") != -1){
		var br = "ie";
	}else{
		var br = "other";
	}
	var arrayPageSize = getPageSize();
	//var arrayPageScroll = getPageScroll();
	var stage_h = arrayPageSize[3]<425?425:arrayPageSize[3];
	document.getElementById('center-flash').style.height = stage_h + 'px';
}
//
/*
	バージョンチェックをするよ
*/
//
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);