/*
	overLayFlash JS: Fullsize FLash Overlays 
	by Ken Murayama むらけん - http://www.muraken.biz

	
	本スクリプトの利用、あるいは利用できないことによって発生した損失や損害に対してむらけんならびにF-siteは一切責任を負いません。
	自由に改変、利用してもらって構いません。
	但し転載する場合は、引用元を明記し、リンクを張ってください。


	+ prototype.js対応、バグフィックス etc. by (桜ヶ丘 sakuragaoka@chocobanana.jp) 2010
*/

Event.observe(window, 'load', function(){
	var ver = '8,0,0,0';
	var file = 'fla.swf';
	var flaWidth = '482';
	var flaHeight = '296';
	var elem = $('dq-flash');
	var elem2 = $('shade');

	if(navigator.appName.indexOf("Microsoft") != -1 && typeof document.body.style.maxHeight == "undefined"){
		// ie6
		var br = "ie";
	}else{
		// ie6以外では出力しない
		return false;
	}
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	var flaTag = '<div id="fla"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' +
		ver +
		'" width="100%" height="100%" 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="bgcolor" value="#ffffff" /><param name="FlashVars" value="br=' +
		br +
		'" /><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="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>';

	Event.observe(elem2, 'click', function(){
		hideFlash(elem2, elem);
	});

	Element.update(elem, flaTag);
	elem.style.display = 'block';

	elem2.style.display = 'block';
	elem2.style.position = 'absolute';
	elem2.style.width = '100%';
	elem2.style.height = (arrayPageSize[1] + 'px');
	elem2.style.left = '0';
	elem2.style.top = '0';
	elem2.style.zIndex = '100';
	elem2.style.backgroundColor = '#000000';
	Element.setOpacity(elem2, 0.60);

	$('fla').style.position = 'absolute';
	$('fla').style.width = flaWidth + 'px';
	$('fla').style.height = flaHeight + 'px';
	$('fla').style.left = Math.floor((arrayPageSize[2] - flaWidth) / 2) + 'px';
	$('fla').style.top = Math.floor((arrayPageSize[3] - flaHeight) / 2) + 'px';
	$('fla').style.zIndex = '200';
});

function hideFlash(e,e2){
	Element.update(e, '');
	Element.update(e2, '');
	e.style.display = 'none';
	e2.style.display = 'none';
	return false;
}


// 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;
}
