function ArekorePopup(){this.attrs=["title","href"];this.requiredAttr={a:"title"};this.ns={xhtml1:"http://www.w3.org/1999/xhtml",xhtml2:"http://www.w3.org/2002/06/xhtml2",ap:"http://www.remus.dti.ne.jp/~a-satomi/ap"};this.safariOnly=false;this.initBeforehand=false;this.initTimeout=3000;this.popupDelay=1000;this.popupSustain=5000;this.offset={X:0,Y:20};this.useRichStyle=true;this.richStyleUseTextShadow=true;this.richStyleUseAILoader=true;this.richStyleEdgeWidth=16;this.richStyleImages={body:"body.png",rect_top:"top.png",rect_left:"left.png",rect_right:"right.png",rect_bottom:"bottom.png",angle_top_left:"top-left.png",angle_top_right:"top-right.png",angle_bottom_left:"bottom-left.png",angle_bottom_right:"bottom-right.png",simple_background:"body.png"};this.cssDir="";this.isSafari=navigator.userAgent.match("AppleWebKit");this.label="ArekorePopup";this.popupBoxId="AP-popup-parent";this.noPopupClassName="AP-noPopup";this.richStyleClassName="AP-richStyle";this.evacuate={title:"ap:ec-title",alt:"ap:ec-alt"};this.uriAttrsPtn=new RegExp("^(background|cite|classid|code|codebase|data|for|href|longdesc|src|usemap)$","i");this.version="v1.2.5";return this}ArekorePopup.prototype={launch:function(){AP.oBODY=AP.getElements("body")[0];if(!AP.oBODY||AP.safariOnly&&!AP.isSafari||!AP.findCSS()){return}if(AP.isSafari){setTimeout("AP.init()",500)}else{AP.init()}},init:function(){if(!AP.cssEnabledCheck()){return}AP.initTimer=(new Date()).getTime();AP.image.prepare();if(AP.initBeforehand){AP.scanNode.recursive(AP.oBODY)}else{AP.addEvent(AP.oBODY,"mouseover",AP.append)}AP.addEvent(AP.oBODY,"mousemove",AP.getMousePos);AP.addEvent(AP.oBODY,"click",AP.remove);AP.statusMsg.show(AP.label+" ("+AP.version+") launched."+((!AP.initBeforehand)?" wasted for init : "+(((new Date()).getTime()-AP.initTimer)/1000)+" sec.":""),100,5000)},scanNode:{recursive:function(c){var a=c.childNodes;for(var b=0;b<a.length;b++){if(a[b].nodeType!=1){continue}if(AP.scanNode.eachNode(a[b])){AP.scanNode.recursive(a[b])}}},eachNode:function(c){if(AP.initBeforehand){if((new Date()).getTime()-AP.initTimer>AP.initTimeout){return false}AP.evacuateAttr(c);AP.image.loadBanner(c)}var d=(!c.namespaceURI)?c.nodeName.toLowerCase():c.nodeName;var a=false;if(!AP.findAttr.ancestorOrSelf(c,"class",AP.noPopupClassName)){if(AP.requiredAttr[d]){a=(AP.getAttr(c,AP.revealAttr(AP.requiredAttr[d])))}else{for(var b in AP.attrs){if(AP.getAttr(c,AP.revealAttr(AP.attrs[b]))){a=true;break}}}if(a&&AP.initBeforehand){AP.addEvent(c,"mouseover",AP.append);AP.addEvent(c,"mouseout",AP.remove)}}return(AP.initBeforehand)?true:a}},addEvent:function(c,a,b){if(c.addEventListener){c.addEventListener(a,b,false)}else{if(c.attachEvent){c.attachEvent("on"+a,function(){b({type:window.event.type,target:window.event.srcElement,currentTarget:c,clientX:window.event.clientX,clientY:window.event.clientY,pageY:document.body.scrollTop+window.event.clientY,shiftKey:window.event.shiftKey,stopPropagation:function(){window.event.cancelBubble=true}})})}}},findCSS:function(){if(!AP.cssDir){var e=AP.getElements("link");var c=new RegExp("/?"+AP.label+".css$");for(var d=0;d<e.length;d++){var a=AP.getAttr(e[d],"rel");var b=AP.getAttr(e[d],"href");if(a&&b&&a.match(/stylesheet/i)&&b.match(c)){AP.cssDir=b.replace(/[^\/]+$/,"");AP.cssDir=(!AP.cssDir)?"./":AP.cssDir;AP.APcss=e[d];break}}if(!AP.cssDir){AP.statusMsg.show("Can't locate CSS : Not found <link> for \""+AP.label+'.css"',500,15000);return false}}else{if(!AP.APcss){AP.APcss=AP.createElement("link");AP.setAttr(AP.APcss,"rel","stylesheet");AP.setAttr(AP.APcss,"type","text/css");AP.setAttr(AP.APcss,"href",AP.cssDir+AP.label+".css");AP.getElements("head")[0].appendChild(AP.APcss)}}return true},cssEnabledCheck:function(){if(!document.styleSheets){return false}if(AP.APcss){AP.APcss.disabled=false}if(!AP.curPopup){AP.curPopup=AP.createElement("ins");AP.setAttr(AP.curPopup,"id",AP.popupBoxId);AP.curPopup.style.position="absolute";AP.curPopup.style.top="-10000px";AP.oBODY.appendChild(AP.curPopup);AP.addEvent(AP.curPopup,"mouseover",AP.sticky);AP.addEvent(AP.curPopup,"click",AP.command);AP.addEvent(AP.curPopup,"mouseout",AP.remove)}return(AP.curPopup.offsetTop==-10000)},image:{prepare:function(){AP.images=[];AP.useAPBanner=false;for(var b in AP.attrs){if(AP.attrs[b]=="ap:banner"){AP.useAPBanner=true;break}}if(AP.useRichStyle){for(var a in AP.richStyleImages){AP.image.preload(AP.cssDir+AP.richStyleImages[a])}}},preload:function(a){if(!a||!a.match(/(gif|png|jpe?g)$/i)){return}AP.images[a]=new Image();AP.images[a].src=a},enabledCheck:function(){var a=(AP.richStyleEdgeWidth)?"body":"simple_background";return AP.images[AP.cssDir+AP.richStyleImages[a]].complete},loadBanner:function(c,b){if(!AP.useAPBanner||!c||AP.getAttr(c,"ap:preloaded")){return}var a=(b)?AP.findAttr.ancestorOrSelf(c,"ap:banner"):AP.getAttr(c,"ap:banner");AP.image.preload(a);AP.setAttr(c,"ap:preloaded","true")},createImgNode:function(b){var a=AP.images[b];if(!a||!a.complete){return null}if(AP.isSafari){var a=AP.createElement("img");AP.setAttr(a,"src",b)}return a}},append:function(a){if(typeof AP!="object"||AP.curItem||!AP.attrs.length){return}if(AP.initBeforehand){a.stopPropagation();AP.curItem=a.currentTarget;AP.popupTimer=setTimeout("AP.popup()",AP.popupDelay)}else{AP.curItem=(a.target.nodeType==3)?a.target.parentNode:a.target;AP.evacuateAttr(AP.curItem,true);AP.image.loadBanner(AP.curItem,true);AP.addEvent(AP.curItem,"mouseout",AP.remove);AP.popupTimer=setTimeout("AP.checkNode()",AP.popupDelay)}},checkNode:function(){if(typeof AP!="object"||!AP.curItem){return}if(AP.scanNode.eachNode(AP.curItem)){AP.popup()}else{if(AP.curItem!=AP.oBODY){AP.curItem=AP.curItem.parentNode;AP.checkNode()}}},popup:function(){if(!AP.cssEnabledCheck()||!AP.curItem){return}var d=AP.createElement("ul");var h=AP.getAttr(AP.curItem,"target");var e=parseInt(AP.windowW*0.9)-AP.richStyleEdgeWidth*2;AP.curPopup.appendChild(d);for(var c in AP.attrs){var a=AP.revealAttr(AP.attrs[c]);var g=AP.getAttr(AP.curItem,a);if(!g){continue}var b=AP.createElement("li");var f=(a.match(AP.uriAttrsPtn))?AP.createAnchor(g,h):(a=="ap:banner")?AP.image.createImgNode(g):document.createTextNode(g);if(f){b.appendChild(f);d.appendChild(b);AP.setAttr(b,"class",AP.attrs[c].replace(/:/,"-"));if(b.offsetWidth>e){b.style.width=e+"px"}}}if(AP.curPopup.offsetWidth>e){d.style.width=e+"px"}AP.applyRichStyle();AP.revisePosition();AP.sustainTimer=setTimeout("AP.remove()",AP.popupSustain)},applyRichStyle:function(){if(!AP.useRichStyle||!AP.image.enabledCheck()){AP.setAttr(AP.curPopup,"class","");return}AP.setAttr(AP.curPopup,"class",AP.richStyleClassName);var f=AP.curPopup.firstChild;var c=AP.richStyleEdgeWidth;if(AP.richStyleUseTextShadow){var h=1,o=[];for(var k=0;k<f.childNodes.length;k++){var l=f.childNodes[k];if(l.runtimeStyle){l.runtimeStyle.filter="progid:DXImageTransform.Microsoft.DropShadow(offX="+h+", offY="+h+', color="black")';l.style.width=l.offsetWidth+"px";l.style.height=l.offsetHeight+"px"}else{o[k]=l.cloneNode(true);AP.setAttr(o[k],"class",AP.getAttr(o[k],"class")+" AP-shadow");var d=(AP.getAttr(l,"class")=="ap-banner")?0:h;o[k].style.top=(l.offsetTop+d)+"px";o[k].style.left=(l.offsetLeft+d)+"px";o[k].style.width=(l.offsetWidth)+"px"}}for(var k=0;k<o.length;k++){f.appendChild(o[k])}}for(var e in AP.richStyleImages){var g=e.split("_")[0];if(g=="body"&&c){var j=f;var n={}}else{if(g=="simple"&&!c){var j=AP.curPopup;var n={}}else{if(g=="angle"&&c){var j=AP.createElement("div");var n={top:(e.split("_")[1]=="top")?0:"auto",bottom:(e.split("_")[1]=="bottom")?0:"auto",left:(e.split("_")[2]=="left")?0:"auto",right:(e.split("_")[2]=="right")?0:"auto",width:c,height:c};AP.setAttr(j,"id","AP-"+e.replace(/_/g,"-"))}else{if(g=="rect"&&c){var j=AP.createElement("div");var m=e.split("_")[1];var n={top:(m.match(/left|right/))?c:(m=="top")?0:"auto",bottom:(m.match(/left|right/))?c:(m=="bottom")?0:"auto",left:(m.match(/top|bottom/))?c:(m=="left")?0:"auto",right:(m.match(/top|bottom/))?c:(m=="right")?0:"auto",width:(m.match(/left|right/))?c:(document.all)?f.offsetWidth:"auto",height:(m.match(/top|bottom/))?c:(document.all)?f.offsetHeight:"auto"};AP.setAttr(j,"id","AP-"+e.replace(/_/g,"-"))}else{continue}}}}for(var b in n){j.style[b]=n[b]+(!isNaN(n[b])?"px":"")}if(j.runtimeStyle&&AP.richStyleUseAILoader){j.runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+AP.cssDir+AP.richStyleImages[e]+'", sizingMethod="scale")'}else{j.style.backgroundImage="url("+AP.cssDir+AP.richStyleImages[e]+")"}if(j!=AP.curPopup&&j!=f){AP.curPopup.appendChild(j)}}if(AP.curPopup.runtimeStyle&&AP.richStyleUseAILoader&&c){var a=AP.curPopup.childNodes;a[0].style.width=(a[0].offsetWidth+1)+"px";a[0].style.height=(a[0].offsetHeight+1)+"px";a[1].style.width=(a[0].offsetWidth)+"px";a[2].style.height=(a[0].offsetHeight)+"px";a[3].style.height=(a[0].offsetHeight)+"px";a[3].style.left=(a[0].offsetWidth+c-1)+"px";a[4].style.width=(a[0].offsetWidth)+"px";a[4].style.top=(a[0].offsetHeight+c-1)+"px";a[6].style.left=(a[0].offsetWidth+c-1)+"px";a[7].style.top=(a[0].offsetHeight+c-1)+"px";a[8].style.top=(a[0].offsetHeight+c-1)+"px";a[8].style.left=(a[0].offsetWidth+c-1)+"px"}},revisePosition:function(){var b=AP.windowW-(AP.windowX+AP.offset.X+AP.curPopup.offsetWidth+20);var a=AP.windowH-(AP.windowY+AP.offset.Y+AP.curPopup.offsetHeight+20);AP.curPopup.style.left=(AP.mouseX+AP.offset.X+((b<0)?b:0))+"px";AP.curPopup.style.top=(AP.mouseY+AP.offset.Y+((a<0)?a:0))+"px"},sticky:function(a){clearTimeout(AP.removeTimer)},command:function(j){j.stopPropagation();if(j.target.nodeName.toLowerCase()=="ul"&&j.target.runtimeStyle&&AP.richStyleUseAILoader){for(var f=0;f<j.target.childNodes.length;f++){var h=j.target.childNodes[f];if(h.firstChild.nodeType!=1&&h.firstChild.nodeName.toLowerCase()!="a"){continue}var d=j.target.parentNode.offsetTop+AP.richStyleEdgeWidth+h.offsetTop;var a=d+h.offsetHeight;var b=AP.getAttr(h.firstChild,"href");if(j.pageY>d&&j.pageY<a&&b){var g=(j.shiftKey)?"_blank":AP.getAttr(h.firstChild,"target");if(!g){g=AP.getAttr(AP.getElements("base")[0],"target")}if(!g){g="_self"}window.open(b,g);return}}}var c=(j.target.nodeType==1)?j.target.nodeName:j.target.parentNode.nodeName;if(c.toLowerCase()!="a"&&confirm('Disable "'+AP.label+'" ?',"")){AP.attrs=[];AP.remove_()}},remove:function(b){if(typeof AP!="object"||!AP.curPopup||!AP.curItem){return}AP.curItem=null;clearTimeout(AP.popupTimer);clearTimeout(AP.sustainTimer);clearTimeout(AP.removeTimer);var a=Math.ceil(Math.log(Math.sqrt(AP.offset.X*AP.offset.X+AP.offset.Y*AP.offset.Y)+1.5)*18);AP.removeTimer=setTimeout("AP.remove_()",a)},remove_:function(){AP.curPopup.style.top="-10000px";while(AP.curPopup.firstChild){AP.curPopup.removeChild(AP.curPopup.firstChild)}},getElements:function(a){if(a.match(/:/)){var b=attr.split(":")[0];var a=attr.split(":")[1];if(document.getElementsByTagNameNS&&AP.oBODY.namespaceURI){return document.getElementsByTagNameNS(AP.ns[b],a)}else{return document.getElementsByTagName(b+":"+a)}}else{return document.getElementsByTagName(a)}},createElement:function(a){return(document.createElementNS)?document.createElementNS(AP.ns.xhtml1,a):document.createElement(a)},getAttr:function(e,a){if(!e||!a){return null}if(document.all){if(a=="href"&&e.nodeName.toLowerCase()=="img"){return null}if(a=="class"){a+="Name"}}try{var b=e.getAttribute(a)}catch(d){}if(!b&&e.getAttributeNS&&a.match(/:/)){var c=a.split(":")[0];var a=a.split(":")[1];return e.getAttributeNS(AP.ns[c],a)}else{return b}},setAttr:function(c,a,d){if(!c||!a){return}if(a.match(/:/)){var b=a.split(":")[0];var a=a.split(":")[1];if(c.setAttributeNS&&c.namespaceURI||AP.isSafari){c.setAttributeNS(AP.ns[b],a,d)}else{c.setAttribute("xmlns:"+b,AP.ns[b]);c.setAttribute(b+":"+a,d)}}else{if(a=="class"&&document.all){a+="Name"}c.setAttribute(a,d)}},evacuateAttr:function(c,a){if(!c||AP.getAttr(c,"ap:evacuated")){return}for(var b in AP.evacuate){var d=AP.getAttr(c,b);if(d){AP.setAttr(c,b,"");AP.setAttr(c,AP.evacuate[b],d);AP.setAttr(c,"ap:evacuated","true")}}if(a){AP.evacuateAttr(c.parentNode,true)}},revealAttr:function(a){return(!a)?null:(AP.evacuate[a])?AP.evacuate[a]:a},findAttr:{eachNode:function(e,a,f){if(!e||!a){return null}var d=value=AP.getAttr(e,a);if(f){d=(value==f);if(a=="class"&&value){var b=value.split(" ");for(var c in b){if(b[c]==f){d=true;break}}}}return d},ancestorOrSelf:function(c,a,d){var b=AP.findAttr.eachNode(c,a,d);return(b)?b:(c.parentNode)?AP.findAttr.ancestorOrSelf(c.parentNode,a,d):null}},createAnchor:function(b,c){if(!b){return null}var a=AP.createElement("a");AP.setAttr(a,"href",b);if(c){AP.setAttr(a,"target",c)}a.appendChild(document.createTextNode(a.href));return a},getMousePos:function(b){if(typeof AP!="object"){return}var f=document.documentElement;var c=(window.scrollX)?window.scrollX:(f.scrollLeft)?f.scrollLeft:AP.oBODY.scrollLeft;var a=(window.scrollY)?window.scrollY:(f.scrollTop)?f.scrollTop:AP.oBODY.scrollTop;AP.windowW=(window.innerWidth)?window.innerWidth:f.offsetWidth;AP.windowH=(window.innerHeight)?window.innerHeight:f.offsetHeight;AP.windowX=b.clientX-((AP.isSafari)?c:0);AP.windowY=b.clientY-((AP.isSafari)?a:0);AP.mouseX=b.clientX+((!AP.isSafari)?c:0);AP.mouseY=b.clientY+((!AP.isSafari)?a:0)},statusMsg:{set:function(){try{window.status=AP.statusMsg.msg}catch(a){}},clear:function(){try{window.status=AP.statusMsg.msg=""}catch(a){}},show:function(c,b,a){if(AP.msgTimer){clearTimeout(AP.msgTimer)}AP.statusMsg.msg=c;if(!b){AP.statusMsg.set()}else{AP.msgTimer=setTimeout("AP.statusMsg.set()",b)}if(AP.statusMsg.msg&&a){AP.msgTimer=setTimeout("AP.statusMsg.clear()",b+a)}}}};var AP=new ArekorePopup();AP.addEvent(window,"load",AP.launch);