/*
	overLayFlash JS: Fullsize FLash Overlays 
	Core code from Ken Murayama むらけん - http://www.muraken.biz
*/
//
// 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;
	}
}


// OverRay部分 //

function showFlash(objLink){
	var file = "http://design10.jp/midicronica/midicronica.swf"; 
	var ver = "8,0,0,0"; 
//	var file = objLink.href; //
//	var ver = objLink.ver; //
	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= '<div id="flash"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+'" width="100%" height="243" id="overlayFlash" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+file+'" /><param name="quality" value="high" /><param name="salign" value="lt" /><param name="wmode" value="transparent" /><param name="FlashVars" value="br='+br+'" /><embed src="'+file+'" quality="high" salign="lt" swLiveConnect=true wmode="transparent" FlashVars="br='+br+'" width="100%" height="243" name="overlayFlash" id="overlayFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>';
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'block';
	objOverlay.onclick = function () {hideFlash(); return false;}
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = Math.floor( Math.random() * 400 );
	//objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '200';
 	objOverlay.style.width = '100%';
	objOverlay.style.height = '243px';
	//objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
	window.document.overlayFlash.onclick = function () {hideFlash(); return false;}
	objOverlay.style.display = 'block';
}

// クリック時に削除 //

function hideFlash(){
	var objBody = document.body;
	objBody.removeChild(objBody.firstChild);
	//window.open("http://ameblo.jp/jigokuiki/", '_blank');
}


function initoverLayFlash(){
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");
	// loop through all anchor tags
	showFlash(this); 
	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 addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}
addLoadEvent(initoverLayFlash);

// 配列の宣言 
var imgSrc = new Array();

// 要素への代入 
imgSrc[0] = "001" ;
imgSrc[1] = "114" ;
imgSrc[2] = "181" ;
imgSrc[3] = "462" ;
imgSrc[4] = "560" ;
imgSrc[5] = "563" ;
imgSrc[6] = "601" ;
imgSrc[7] = "634" ;
imgSrc[8] = "666" ;
imgSrc[9] = "716" ;
imgSrc[10] = "808" ;
imgSrc[11] = "818" ;
imgSrc[12] = "894" ;
imgSrc[13] = "967" ;
imgSrc[14] = "216" ;

var rand = Math.floor( Math.random() * 15 );
document.write( '<a href="javascript:initoverLayFlash();"><img src="http://design10.jp/midicronica/img/'+imgSrc[rand]+'.jpg" /></a>' );