// 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.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	}
	
	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;
	}
}
var ep;
var isDisp = false;

function showFlashshaddy(objLink){
	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= '<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="shaddy" 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="gpYsc='+arrayPageScroll+'&ep='+ep+'" /><embed src="'+file+'" quality="high" salign="lt" swLiveConnect=true bgcolor="#ffffff" FlashVars="gpYsc='+arrayPageScroll+'&ep='+ep+'" width="100%" height="100%" name="shaddy" id="shaddy" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" /></object>';

	objOverlay.setAttribute('id','overlay');
	objOverlay.style.cssText ='display:block;position:absolute;top:10px;left:0px;z-index:200;width:100%;height:'+arrayPageSize[1]+'px;';
	/*objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0px';
	objOverlay.style.left = '0px';
	objOverlay.style.zIndex = '1000';
 	objOverlay.style.width = '100%';
	objOverlay.style.height = (arrayPageSize[1] + 'px');*/
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
}

function shaddyhideFlash(){
//window.alert("shaddyhideFlash");
	var objBody = document.body;
	objBody.removeChild(objBody.firstChild);
	isDisp = false;
}

function shaddyflashalive(fla){
	if (fla != "http://www.blogpeta.jp/swf/shaddy/pop.swf") return;
	var anchor = document.createElement("a");
	anchor.setAttribute("href",fla);
	anchor.setAttribute("rel","overLayFlash")
	anchor.setAttribute("var","8,0,0,0");
	//	window.document.anchor.onclick = function () {showFlash(anchor); return false;}
	showFlashshaddy(anchor);
	return false;
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//

function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}

function shaddyJumpwindow(num){
	if(isDisp) return;
	ep = num;
	shaddyflashalive('http://www.blogpeta.jp/swf/shaddy/pop.swf');
	isDisp = true;
}

addLoadEvent(shaddyflashalive);
var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
+ 'width="166" '
+ 'height="375" '
+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" '
+ 'id="peta" '
+ '>'
+ '<param name="movie" value="http://www.blogpeta.jp/petaswf.php?bp=6640&nc=0" />'
+ '<param name="quality" value="high" />'
+ '<param name="allowScriptAccess" value="always" /> '
+ '<param name="swLiveConnect" value="true" /> '
+ '<param name="value" value="noscale" /> '
+ '<param name="salign" value="TL" /> '
+ '<param name="wmode" value="transparent" /> '
+ '<embed src="http://www.blogpeta.jp/petaswf.php?bp=6640&nc=0" '
+ 'name="peta" '
+ 'width="166" '
+ 'height="375" '
+ 'align="middle" '
+ 'play="true" '
+ 'loop="false" '
+ 'quality="high" '
+ 'type="application/x-shockwave-flash" '
+ 'pluginspage="http://www.macromedia.com/go/getflashplayer" '
+ 'allowScriptAccess="always" '
+ 'swLiveConnect="true" '
+ 'value="noscale" '
+ 'salign="TL" '
+ 'wmode="transparent" '
+ '>'
+ '<\/embed>'
+ '<\/object>';
document.write(oeTags);

