
var BlogPartsPath='http://www.truefortune.jp/blogparts/b_p.swf';
var LayerPartsPath='http://www.truefortune.jp/blogparts/tfResult.swf';
var vartexturl='http://www.truefortune.jp/blogparts/result.txt';
var lastFlashID = "";

function BlogPPrint(){
	var html='';
	html+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" WIDTH="160" HEIGHT="260" id="b_p" ALIGN="">';
	html+='<param name="allowScriptAccess" value="always" />';
	html+='<param name="movie" value="'+BlogPartsPath+'" />';
	html+='<param name="wmode" value="transparent" />';
	html+='<param name="quality" value="high" />';
	html+='<param name="bgcolor" value="#ffffff" />';
	html+='<EMBED src="'+BlogPartsPath+'" quality="high" allowScriptAccess="always" wmode="transparent" bgcolor="#FFFFFF" WIDTH="160" HEIGHT="260" NAME="b_p" ALIGN="middle" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">';
	html+='</object>';
	document.write(html);
}

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;
}

function getPageSize(){
	var xScroll, yScroll;
	if( lastFlashID != "" ){
		var objOverlay = document.getElementById( lastFlashID );
		objOverlay.style.height = "100%";
		objOverlay.style.width = "100%";
	}

	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+20;
		windowHeight = document.body.clientHeight;
	}

	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function showOverlayFlash( swfname, swfver,randnum ){
	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 myTag='';
	myTag+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="overlayFlash" align="middle">';
	myTag+='<param name="allowScriptAccess" value="always" />';
	myTag+='<param name="movie" value="'+LayerPartsPath+'?varrand='+randnum+'&vartexturl='+vartexturl+'" />';
	myTag+='<param name="quality" value="high" />';
	myTag+='<param name="salign" value="lt" />';
	myTag+='<param name="wmode" value="transparent" />';
	myTag+='<param name="bgcolor" value="#ffffff" />';
	myTag+='<param name="FlashVars" value="br='+br+'" />';
	myTag+='<embed src="'+LayerPartsPath+'?varrand='+randnum+'&vartexturl='+vartexturl+'" quality="high" salign="lt" swLiveConnect=true wmode="transparent" bgcolor="#ffffff" FlashVars="br='+br+'" width="100%" height="100%" name="overlayFlash" id="overlayFlash" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	var ret_idname = "overlay_"+LayerPartsPath;
	ret_idname = ret_idname.replace( ".", "_" );
	ret_idname = ret_idname.replace( "/", "_" );

	objOverlay.setAttribute( 'id', ret_idname );
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
//	objOverlay.style.top = '0';
	objOverlay.style.top = arrayPageScroll[1];
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '200';
 	objOverlay.style.width = '105%';
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objBody.style.overflow="hidden";
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
	objOverlay.style.display = 'block';

	lastFlashID = ret_idname;

	window.onresize = resizeHandler;

	var div = function(self){
		return {
			setPosition : function(){
				arrayPageScroll = getPageScroll();
				self.style.position = 'absolute';
				self.style.top  = arrayPageScroll[1] + 'px';
			}
		};
	}(document.getElementById(lastFlashID));

	window.onscroll=function(){
		div.setPosition();
	};

	//return ret_idname;
}

function resizeHandler(){
	if( lastFlashID == "" ){
		return;
	}
	var objOverlay = document.getElementById( lastFlashID );
	var arrayPageSize = getPageSize();
	objOverlay.style.height = (arrayPageSize[1] + 'px');
}

function showOverlayFlash9( swfname ,randnum ){
	return showOverlayFlash( swfname, "9,0,0,0" ,randnum );
}

function hideOverlayFlash( id ){
	if( id == undefined || id == "" ){
		id = lastFlashID;
	}

	var objOverlay = document.getElementById( id );
	var objBody = document.body;
	var objOverlayParent = objOverlay.parentNode
	objOverlayParent.removeChild( objOverlay );
	objBody.style.overflow="auto";

	// ƒŠƒZƒbƒg.
	if( id == lastFlashID ){
		lastFlashID = "";
	}
}

BlogPPrint();

