var btnFlag;

function changeButton(el){
	el.src = "http://dance.satoru.net/sw/" + (btnFlag ? "on" : "off") + "_button.jpg";
	if(!btnFlag){
		showFlash(el);
		setTimeout(function(){el.src = "http://dance.satoru.net/sw/on_button.jpg";btnFlag = false},800);
	}
	else {
		hideFlash()
	}
	
	
	btnFlag = !btnFlag;
	doSound();
}

function doSound(){
	document.getElementById("flsh").innerHTML = ('<object id=hoge classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0" width="1" height="1"><param name="wmode" value="transparent" /><param name="movie" value="http://dance.satoru.net/sw/switch.swf?x"></param><embed src="http://dance.satoru.net/sw/switch.swf?x" wmode="transparent" type="application/x-shockwave-flash" width="1" height="1"></embed></object>');
}

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;	} 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 pause(numberMillis) {	var now = new Date();	var exitTime = now.getTime() + numberMillis;	while (true) {		now = new Date();		if (now.getTime() > exitTime)			return;	}}function showFlash(thisobj){	//Scroll(thisobj);	
var file = "http://dance.satoru.net/sw/hoge.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= '<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="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+'" /><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" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';		objOverlay.setAttribute('id','flashoverlay');	objOverlay.style.display = 'block';	objOverlay.style.position = 'absolute';	objOverlay.style.top = '0';	objOverlay.style.left = '0'; objOverlay.style.zIndex = '10000'; 	objOverlay.style.width = '100%';	objOverlay.style.height = (arrayPageSize[1] + 'px');	objOverlay.innerHTML = myTag;	objBody.insertBefore(objOverlay, objBody.firstChild);}function hideFlash(){	var objBody = document.body;	objBody.removeChild(objBody.firstChild);}var eventTimer;var restScroll=0;function Scroll(base){    var obj_base = getElemPosition(base);    restScroll = 0-obj_base.y;    eventTimer = setInterval(setScrollPosition,5);}function setScrollPosition() {    var moveValue=0;    if(Math.abs(restScroll)>80){		moveValue = -100;    }else{        moveValue = Math.round(restScroll/10);    }    scrollBy(0,moveValue);    restScroll = (restScroll>0)?restScroll-moveValue:restScroll-moveValue;    if(moveValue==0){        clearInterval(eventTimer);        restScroll=0;    }}function getElemPosition(elem) {    var obj = new Object();    obj.x = elem.offsetLeft;    obj.y = elem.offsetTop;    while(elem.offsetParent) {        elem = elem.offsetParent;        obj.x += elem.offsetLeft;        obj.y += elem.offsetTop;    }    return obj;}


document.write('<span><img id=btn src=http://dance.satoru.net/sw/on_button.jpg style="cursor:pointer" onClick="changeButton(this)"><img width=1 height=1 src=http://dance.satoru.net/sw/off_button.jpg>');
document.write('<div id=flsh></div>');
//document.write('<font size=1>エコボタン by <a href=http://rocketstart.jp>RKST</a></font></span><br>');

