/**
 *  <script type="text/javascript" src="http://www.srw-tryout.jp/blogparts/blogparts.js"></script><script type="text/javascript">show_blog_parts();</script>
 */
function show_blog_parts()
{
    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,45" '
    + 'id="externalBlogParts" width="175" height="325">'
    + '<param name="movie" value="http://www.samurai3.jp/blopa/dokan.swf">'
    + '<param name="wmode" value="transparent">'
    + '<param name="quality" value="high">'
	+ '<param name="allowScriptAccess" value="always">'
    + '<embed src="http://www.samurai3.jp/blopa/dokan.swf" id="externalBlogParts" name="externalBlogParts" allowScriptAccess="always" quality="high" width="175" height="325" '
    + 'pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '
    + 'wmode="transparent" >'
    + '</object>';
    document.write(oeTags);
}

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 (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;
}


function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}


function showFlash(swf){
	var file = swf; 
	var ver = "9,0,0,45";
	if(navigator.appName.indexOf("Microsoft") != -1){
		var br = "ie";
	}else{
		var br = "other";
	}
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var objBody = document.body;
	var myTag= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
	 + 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+'" '
	 + 'id="externalOverlay" width="100%" height="100%" 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="transparent" />'
	 + '<param name="bgcolor" value="#ffffff" />'
	 + '<param name="FlashVars" value="br='+br+'&xOffset=0&yOffset='+arrayPageScroll[1]+'" />'
	 + '<embed src="'+file+'" quality="high" salign="lt" swLiveConnect=true wmode="transparent" '
	 + 'bgcolor="#ffffff" FlashVars="br='+br+'&xOffset=0&yOffset='+arrayPageScroll[1]+'" name="externalOverlay" id="externalOverlay" '
	 + 'width="100%" height="100%" align="middle" allowScriptAccess="always" '
	 + 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	 + '</object>';
	var objOverlay = null;
	if (document.getElementById("overlay")){
		objOverlay = document.getElementById("overlay");
		objOverlay.style.display = 'block';
		objOverlay.style.top = (arrayPageScroll[1] + 'px');
	} else {
		objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		//objOverlay.onclick = function () {hideFlash(); return false;}
		objOverlay.style.display = 'block';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = (arrayPageScroll[1] + 'px');
		objOverlay.style.left = '0';
		objOverlay.style.zIndex = '200';
	 	objOverlay.style.width = '100%';
		objOverlay.style.height = '100%';
		objBody.insertBefore(objOverlay, objBody.firstChild);
		/*if (!(navigator.userAgent.match('Windows') && navigator.userAgent.match('Firefox'))){
			window.document.overlayFlash.onclick = function () {hideFlash(); return false;}
		}*/
		//objOverlay.style.display = 'block';
	}
	
	objOverlay.innerHTML = myTag;
}


function hideFlash(){
	//var objBody = document.body;
	//objBody.removeChild(objBody.firstChild);
	var objOverlay = document.getElementById("overlay");
	objOverlay.style.display = 'none';
}


function initoverLayFlash(swf){
	if (!document.getElementsByTagName){ return; }
	
	var anchors = document.getElementsByTagName("a");
	// loop through all anchor tags
	showFlash(swf); 
	/*for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "overLayFlash")){
			anchor.onclick = function () {
				showFlash(this); 
				return false;
			}
		}
	}*/
}

function coolOverlay(){
	initoverLayFlash('http://www.samurai3.jp/blopa/cool.swf');
}

function badOverlay(){
	initoverLayFlash('http://www.samurai3.jp/blopa/bad.swf');
}