
document.write('<script language="javascript" src="http://download.fujifilm.co.jp/pub/files/blogparts/3d/swfobject.js"></script>');

var FVARS_BRMI = null;
var FVARS_CVPA = encodeURIComponent(location);

//
// write3dBlogparts()
//
function write3dBlogparts(param){
	document.write('<div id="blogparts">FinePix REAL 3D　ブログパーツ | 富士フイルム</div>');
	
	FVARS_BRMI = param;
	var flashvars = { BRMI : FVARS_BRMI, CVPA : FVARS_CVPA};
	
	swfobject.embedSWF('http://download.fujifilm.co.jp/pub/files/blogparts/3d/blogparts.swf', 'blogparts', '160', '400', '9,0,115', 'http://download.fujifilm.co.jp/pub/files/blogparts/3d/blogparts.swf', flashvars, {allowScriptAccess:'always',bgcolor: '#000000', menu: 'true', wmode: 'transparent'}, {id: 'blogparts'});
}

//
// 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;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	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 pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

var obj = new Object();

function fBacktoTop() {
	var d=document;
        var scroll_left=d.body.scrollLeft || d.documentElement.scrollLeft || d.scrollX || 0;
        var scroll_top=d.body.scrollTop || d.documentElement.scrollTop || d.scrollY || 0;
        scrollTo(scroll_left/2, scroll_top/2);
        if (scroll_left>0 || scroll_top>0){
		var f=setTimeout("fBacktoTop()", 10);
        } else {
		clearTimeout(f);
        }
}

function welcome(){

	obj.x = document.documentElement.scrollLeft || document.body.scrollLeft;
	obj.y = document.documentElement.scrollTop || document.body.scrollTop;

	fBacktoTop();



	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	
	var objBody = document.body;
	var objOverlay = document.createElement("div");

	var file = "http://download.fujifilm.co.jp/pub/files/blogparts/3d/blogparts_floating.swf";
	var ver = "9,0,115";
	var w = "100%";
	var h = "100%";
	var idname = "blogparts_floating";
	var wm = "transparent";

	if(navigator.appName.indexOf("Microsoft") != -1){
		var br = "ie";
	}else{
		var br = "other";
	}
	var myTag= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+'" width="'+w+'" height="'+h+'" id="'+idname+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+file+'" /><param name="quality" value="high" /><param name="salign" value="lt" /><param name="wmode" value="'+wm+'" /><param name="bgcolor" value="#000000" /><param name="FlashVars" value="br='+br+'&BRMI=' + FVARS_BRMI + '&CVPA=' + FVARS_CVPA + '" /><embed src="'+file+'" quality="high" salign="lt" swLiveConnect=true wmode="'+wm+'" bgcolor="#000000" FlashVars="br='+br+'&BRMI=' + FVARS_BRMI + '&CVPA=' + FVARS_CVPA + '" width="'+w+'" height="'+h+'" name="'+idname+'" id="'+idname+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

	objOverlay.setAttribute('id',idname);
	//objOverlay.onclick = function () {goodbye(); return false;}
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '3000';
 	objOverlay.style.width = '100%';
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
	window.document.overlayFlash.onclick = function () {goodbye(); return false;}
	objOverlay.style.display = 'block';
}


function goodbye(){
	if (navigator.userAgent.indexOf("MSIE")!=-1) {
		btnClose();
	} else {
		idClose = setTimeout('btnClose()',200);
	}
}
 
function btnClose(){
	var objBody = document.body;
	objBody.removeChild(objBody.firstChild);
 
	window.scrollTo(obj.x,obj.y); 
}


function initoverLayFlash(){

	if (!document.getElementsByTagName){ return; }
	
	var anchors = document.getElementsByTagName("a");

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "overLayFlash")){
			anchor.onclick = function () {
				welcome(this); 
				return false;
			}
		}
		
	}
	
}


//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}



addLoadEvent(initoverLayFlash);	