(function() { var DIR = 'http://blog.osaka-ue.ac.jp/blogparts/'; var $id=function(i){return document.getElementById(i)}; var $create=function(t){return document.createElement(t)}; var $append=function(t,d){t.appendChild(d)}; var $remove=function(t,d){t.removeChild(d)}; var addEvent=(function(){if(window.addEventListener){return function(e,t,f,c){e.addEventListener(t,f,c);return true;};}else if(window.attachEvent){return function(e,t,f){var r=e.attachEvent('on'+t,f);return r;};}else{return function(e,t,f){e['on'+t]=f;};}})(); var removeEvent=(function(){if(window.removeEventListener){return function(e,t,f,c){e.removeEventListener(t,f,c);return true;};}else if(window.detachEvent){return function(e,t,f){var r=e.detachEvent('on'+t,f);return r;};}else{return function(e,t,f){e['on'+t]=null;};}})(); var getflash=function(swf,id,w,h,mode,vars){return '';}; var getInnerSize=(function(){var W=window,D=document,w=0,h=0,u='undefined';if(typeof W.innerHeight!=u){return function(){h=W.innerHeight;w=W.innerWidth;if(D.height>h){w-=16;}return {width:w,height:h};}}else if(typeof D.documentElement.clientHeight!=u){return function(){h=h=D.documentElement.clientHeight||D.body.clientHeight;w=D.documentElement.clientWidth||D.body.clientWidth;return {width:w,height:h};}}})(); var getElementPosition=function(t){var y=0;var x=0;while(t){y+=t.offsetTop;x+=t.offsetLeft;t=t.offsetParent;}return {top:y,left:x};}; var addDomLoadedEvent=(function(){var T=true,F=false,d=document,fn;if(d.addEventListener){return function(f){d.addEventListener('DOMContentLoaded',f,F);return T;}}else if(/msie/.test(navigator.userAgent.toLowerCase())){return function(f){if(!fn){fn=[f];}else if(f){fn.push(f);}try{document.documentElement.doScroll('left');}catch(er){setTimeout(arguments.callee,0);return;}var f;while(f=fn.shift()){f();}}}else{return function(f){window.onload=f;}}})(); var nekobp,sanpo; var w=160,h=366; var turn; var timer; function init() { writeCSS(); writeBP(); } function writeCSS() { document.write(''); } function writeBP() { document.write('
'); nekobp = $id("dkdnekobp"); var st = nekobp.style; st.width = w+"px"; st.height = h+"px"; var param = "count=36770"; nekobp.innerHTML = getflash(DIR + 'bp.swf','externalnakobp',w,h,'transparent',param); } function writeNeko() { var cx = getInnerSize().width * 0.5; var p = getElementPosition(nekobp); turn = cx < p.left ? "right" : "left"; sanpo = $create('div'); var st = sanpo.style; st.position = 'absolute'; st.top = p.top + 'px'; st.left = p.left + 'px'; st.width = w+"px"; st.height = "220px"; st.zIndex = 652000; var param = "dir=" + DIR + "&turn=" + turn; sanpo.innerHTML = getflash(DIR + 'sanpo_' + turn + '.swf','externalnekosanpo','100%','100%','transparent', param); $append(document.body, sanpo); } function syncPosition() { var p = getElementPosition(nekobp); var st = sanpo.style; st.top = p.top + 'px'; st.left = p.left + 'px'; } function jump() { clearInterval(timer); timer = setInterval(move, 30); } function move() { var x = parseInt(sanpo.style.left); x += (turn == 'left') ? 2 : -4; sanpo.style.left = x + 'px'; var w = parseInt(sanpo.style.width); if (w <= 360) { sanpo.style.width = (w + 3) + 'px'; } } function unload() { clearInterval(timer); removeEvent(window, 'resize', syncPosition); removeEvent(window, 'unload', unload); $remove(document.body, sanpo); } addDomLoadedEvent(function() { writeNeko(); timer = setInterval(syncPosition, 50); window.dkdNekoBP = {jump:jump}; addEvent(window, 'resize', syncPosition); addEvent(window, 'unload', unload); }); init(); })();