function baseset(){
	var def_url ='http://moyashimon.noitamina.tv/blogparts/';
	var swf_url = def_url+'base.swf';
	var html = '<div id="kamoshi_box" style="position:relative;width:160px;height:350px;"><div id="kamoshi_overlay" style="position:absolute;"><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="160" height="350" id="baseFlash" align="middle">';
	html += '<param name="allowScriptAccess" value="always" />';
	html += '<param name="movie" value="' + swf_url + '" /><param name="wmode" value="opaque" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><embed src="' + swf_url + '" quality="high" bgcolor="#FFFFFF" wmode="opaque" width="160" height="350" name="baseFlash" id="baseFlash" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	html += '</object></div></div>';
	document.write(html);
}
baseset();


function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		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){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
		if(windowHeight < document.documentElement.scrollHeight){
			windowHeight = document.documentElement.scrollHeight;
		}
		if(windowHeight < document.body.scrollHeight){
			windowHeight = document.body.scrollHeight;
		}
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		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 showFlash(objLink){
	//alert("root");
	btnFunc("false");
	
	var sobjBody = document.body;
	var sanchors = document.getElementsByTagName("div");
	var divcheck = true;
	//for (var i=0; i<sanchors.length; i++){
		//var sanchor = sanchors[i];
		//if (sanchor.getAttribute("id") == "overlayFlash"){
			//sobjBody.removeChild(sanchor);
			//divcheck = false;
		//}
	//}
	//alert("root1");
	
	
	
	if(divcheck == true){
	//alert("root2");
	var myurl ="http://moyashimon.noitamina.tv/blogparts/";
	var file = myurl+"overlay.swf";
	var ver = "8,0,0,0";
	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= '<embed src="'+file+'" 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" base="'+myurl+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	objOverlay.setAttribute('id','overlay');
	//objOverlay.onclick = function () {hideFlash(); return false;}
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';//(arrayPageScroll[1] + 'px');//'100px';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '100';
 	objOverlay.style.width = '100%';
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	//for (var i=0; i<sanchors.length; i++){
		//var sanchor = sanchors[i];
		//if (sanchor.getAttribute("id") == "kamoshi_box"){
			//objBody.appendChild(objOverlay);
			//objBody.insertBefore(objOverlay, sanchor);
			//kamoshiPos(getElemPos(sanchor).x,getElemPos(sanchor).y);
		//}
//	}
	
	//window.document.overlayFlash.onclick = function () {hideFlash(); return false;}
	}
	//hideFlash();
}

function hideFlash(){
	var objBody = document.body;		
	var anchors = document.getElementsByTagName("div");

	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("id") == "overlay"){
			objBody.removeChild(anchor);
			btnFunc("true");
		}
	}
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}

function getMyPos(){
	//alert("test");
	var sanchors = document.getElementsByTagName("div");
	for (var i=0; i<sanchors.length; i++){
		var sanchor = sanchors[i];
		if (sanchor.getAttribute("id") == "kamoshi_overlay"){
			//alert(getElemPos(sanchor).x+":"+getElemPos(sanchor).y);
			kamoshiPos(getElemPos(sanchor).x,getElemPos(sanchor).y);
		}
	}
}
function getElemPos(elem){
	var elemPos = new Object();
	elemPos.x = 0;
	elemPos.y = 0;
	while(elem){
	elemPos.x += elem.offsetLeft;
	elemPos.y += elem.offsetTop;
	elem = elem.offsetParent;
	}
	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != "undefined") {
	elemPos.x += document.body.leftMargin;
	elemPos.y += document.body.topMargin;
	}
	return elemPos;
}
function kamoshiPos(posX,posY){
	target = window.document.getElementById('overlayFlash');
	//alert(target)
	//alert(posX+":"+posY);
	if(target != null){
		target.SetVariable("_level0.posX",posX);
		target.SetVariable("_level0.posY",posY);
	}
	window.document.overlayFlash.SetVariable("_level0.posX",posX);
	window.document.overlayFlash.SetVariable("_level0.posY",posY);
	//alert(posX+":"+posY);
}

function btnFunc(stat){
	//alert("stat");
	//window.document.baseFlash.SetVariable("_level0.path",stat);
}