var isWin9X = (navigator.appVersion.toLowerCase().indexOf('windows 98')+1);
var isIE    = (navigator.appName.toLowerCase().indexOf('internet explorer')+1?1:0);
var isOpera = (navigator.userAgent.toLowerCase().indexOf('opera')+1?1:0);
if (isOpera) isIE = false;
var isSafari = (navigator.appVersion.toLowerCase().indexOf('safari')+1?1:0);

var hirahiraTimer;
var hirahiraLayer;
var html = '';
html += '<DIV style="width:160px;height:256px;overflow:hidden; zindex:1;" >';
html += '<OBJECT ';
html += ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
html += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ';
html += ' width="160px" height="256px" id="mymio_clock_flash" align="middle" > ';
html += ' <PARAM name="movie"             value="http://www.brother.co.jp/jp/mymio/special/mao/flash/mymio_clock.swf" /> ';
html += ' <PARAM name="allowScriptAccess" value="always"      /> '; 
html += ' <PARAM name="quality"           value="high"        />';
html += ' <PARAM name="wmode"             value="transparent" />';
html += ' <PARAM name="bgcolor"           value="#FFFFFF"     />';
html += ' <EMBED ';
html += '  src="http://www.brother.co.jp/jp/mymio/special/mao/flash/mymio_clock.swf" ';
html += '  quality="high" bgcolor="#FFF" ';
html += '  width=160px" height="256px" name="mymio_clock_flash" align="middle" ';
html += '  allowScriptAccess="always" type="application/x-shockwave-flash" wmode="transparent" ';
html += '  pluginspage="http://www.macromedia.com/go/getflashplayer" ';
html += ' /> ';
html += '</OBJECT>';
html += '</DIV>';

document.write( html );

function justAction(){
	if( document.body.hirahira ){
		return false;
	}
	hirahiraTimer = window.setInterval( function(){
		hirahiraHide();
	}, 45000 );
	hirahiraShow();
	return false;
}

function hirahiraHide(){
	document.body.removeChild( hirahiraLayer );
	document.body.hirahira = false;
	window.clearInterval( hirahiraTimer );
	return false;
}

function hirahiraShow(){

	if( document.body.hirahira ){
		return false;
	}
	document.body.hirahira = true;

	var html2 = '';
	html2 += '<OBJECT ';
	html2 += ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	html2 += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ';
	html2 += ' width="2048px" height="1024px" id="hirahira_flash" align="middle" > ';
	html2 += ' <PARAM name="movie"   value="http://www.brother.co.jp/jp/mymio/special/mao/flash/hirahira.swf" /> ';
	html2 += ' <PARAM name="wmode" value="transparent" />';
	html2 += ' <PARAM name="quality" value="high"    /> ';
	html2 += ' <PARAM name="bgcolor" value="#FFFFFF" /> ';
	html2 += ' <EMBED ';
	html2 += '  src="http://www.brother.co.jp/jp/mymio/special/mao/flash/hirahira.swf" ';
	html2 += '  quality="high" bgcolor="#FFF" ';
	html2 += '  width="2048px" height="1024px" name="hirahira_flash" align="middle" ';
	html2 += '  type="application/x-shockwave-flash" wmode="transparent" ';
	html2 += '  pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	html2 += ' /> ';
	html2 += '</OBJECT>';

	var screen = getScreenSize();
	var scroll = getScrollPosition();
	
	hirahiraLayer = document.createElement( 'div' );
	hirahiraLayer.innerHTML      = html2;
	hirahiraLayer.style.overflow = 'hidden';
	hirahiraLayer.style.position = 'absolute';
	hirahiraLayer.style.width    = screen.x + 'px';
	hirahiraLayer.style.height   = screen.y + 'px';
	hirahiraLayer.style.top      = scroll.y + 'px';
	hirahiraLayer.style.left     = scroll.x + 'px';
	hirahiraLayer.style.zIndex   = '99';

	document.body.appendChild( hirahiraLayer );
	return false;
}

function hirahiraScroll(){
	if( document.body.hirahira ){
		var scroll     = getScrollPosition();
		var hiraWidth  = Number( hirahiraLayer.style.width.replace ( 'px', '' ) );
		var hiraHeight = Number( hirahiraLayer.style.height.replace( 'px', '' ) );
		if( scroll.y + hiraHeight < document.body.offsetHeight ){
			hirahiraLayer.style.top  = scroll.y + 'px';
		}
		if( scroll.x + hiraWidth  < document.body.offsetWidth  ){
			hirahiraLayer.style.left = scroll.x + 'px';
		}
		return false;
	}
	return false;
}

function hirahiraResize(){
	if( document.body.hirahira ){
		var screen = getScreenSize();
		hirahiraLayer.style.width  = screen.x + 'px';
		hirahiraLayer.style.height = screen.y + 'px';
		return false;
	}
	return false;
}

try{
	window.addEventListener( 'scroll', hirahiraScroll, false );  
	window.addEventListener( 'resize', hirahiraResize, false );  
}catch(e){  
	window.attachEvent( 'onscroll', hirahiraScroll );  
	window.attachEvent( 'onresize', hirahiraResize );  
}  

function getScreenSize() {
	var obj = new Object();
	if (!isSafari && !isOpera) {
		obj.x = document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth;
		obj.y = document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight;
	} else {
		obj.x = window.innerWidth;
		obj.y = window.innerHeight;
	}
	obj.mx = parseInt((obj.x)/2);
	obj.my = parseInt((obj.y)/2);
	return obj;
}

function getScrollPosition() {
	var obj = new Object();
	obj.x = document.documentElement.scrollLeft || document.body.scrollLeft;
	obj.y = document.documentElement.scrollTop || document.body.scrollTop;
	return obj;
}

