var audio = null; var tkawasemi; function kawasemi(){ var ckawasemi = 1; kawasemiimg = new Array(4); kawasemiimg[1] = "./css/img/kawasemi_01.png"; kawasemiimg[2] = "./css/img/kawasemi_02.png"; kawasemiimg[3] = "./css/img/kawasemi_01.png"; kawasemiimg[4] = "./css/img/kawasemi_02.png"; kawasemiUP(); function kawasemiUP(){ tkawasemi = setTimeout(kawasemiUP,500); document.kawasemi.src = kawasemiimg[ckawasemi]; ckawasemi = ckawasemi + 1; if( ckawasemi > 4 ){ ckawasemi = 1; } } } function sound(){ audio = new Audio(); audio.autoplay = false; audio.loop = true; if (audio.canPlayType) { var playMsg = audio.canPlayType('audio/mpeg'); if ( "" != playMsg) { audio.src = "./sound/kawasemi.mp3"; } playMsg = audio.canPlayType('audio/wav; codecs="1"'); if ( "" != playMsg) { audio.src = "./sound/kawasemi.wav"; } audio.load(); } } /* マウスオーバー・アウト */ function soundsmartRollover() { document.kawasemi.onmouseover = function() { audio.play(); kawasemi(); } document.kawasemi.onmouseout = function() { audio.pause(); clearTimeout(tkawasemi); document.kawasemi.src = kawasemiimg[1]; } } /* オンロード時に動作 */ if(window.addEventListener) { window.addEventListener('load', sound, false); window.addEventListener('load', soundsmartRollover, false); } else { window.attachEvent("onload", sound); window.attachEvent("onload", soundsmartRollover); }