function ArekorePopup(){this.attrs=["ap:banner","title","href","cite","datetime"];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=500;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={fixAttrsArray:function(){if(!AP.attrs.length){return}var B=AP.attrs;var A=B.length;AP.attrs={};for(var C=0;C<A;C++){AP.attrs[C]=B[C]}},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(){AP.fixAttrsArray();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){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,N=[];for(var J=0;J<F.childNodes.length;J++){var K=F.childNodes[J];if(K.runtimeStyle){K.runtimeStyle.filter="progid:DXImageTransform.Microsoft.DropShadow(offX="+H+", offY="+H+', color="black")';K.style.width=K.offsetWidth+"px";K.style.height=K.offsetHeight+"px"}else{N[J]=K.cloneNode(true);AP.setAttr(N[J],"class",AP.getAttr(N[J],"class")+" AP-shadow");var D=(AP.getAttr(K,"class")=="ap-banner")?0:H;N[J].style.top=(K.offsetTop+D)+"px";N[J].style.left=(K.offsetLeft+D)+"px";N[J].style.width=(K.offsetWidth)+"px"}}for(var J=0;J<N.length;J++){F.appendChild(N[J])}}for(var E in AP.richStyleImages){var G=E.split("_")[0];if(G=="body"&&C){var I=F;var M={}}else{if(G=="simple"&&!C){var I=AP.curPopup;var M={}}else{if(G=="angle"&&C){var I=AP.createElement("div");var M={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(I,"id","AP-"+E.replace(/_/g,"-"))}else{if(G=="rect"&&C){var I=AP.createElement("div");var L=E.split("_")[1];var M={top:(L.match(/left|right/))?C:(L=="top")?0:"auto",bottom:(L.match(/left|right/))?C:(L=="bottom")?0:"auto",left:(L.match(/top|bottom/))?C:(L=="left")?0:"auto",right:(L.match(/top|bottom/))?C:(L=="right")?0:"auto",width:(L.match(/left|right/))?C:(document.all)?F.offsetWidth:"auto",height:(L.match(/top|bottom/))?C:(document.all)?F.offsetHeight:"auto"};AP.setAttr(I,"id","AP-"+E.replace(/_/g,"-"))}else{continue}}}}for(var B in M){I.style[B]=M[B]+(!isNaN(M[B])?"px":"")}if(I.runtimeStyle&&AP.richStyleUseAILoader){I.runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+AP.cssDir+AP.richStyleImages[E]+'", sizingMethod="scale")'}else{I.style.backgroundImage="url("+AP.cssDir+AP.richStyleImages[E]+")"}if(I!=AP.curPopup&&I!=F){AP.curPopup.appendChild(I)}}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(H){H.stopPropagation();if(H.target.nodeName.toLowerCase()=="ul"&&H.target.runtimeStyle&&AP.richStyleUseAILoader){for(var E=0;E<H.target.childNodes.length;E++){var G=H.target.childNodes[E];if(G.firstChild.nodeType!=1&&G.firstChild.nodeName.toLowerCase()!="a"){continue}var D=H.target.parentNode.offsetTop+AP.richStyleEdgeWidth+G.offsetTop;var A=D+G.offsetHeight;var B=AP.getAttr(G.firstChild,"href");if(H.pageY>D&&H.pageY<A&&B){var F=(H.shiftKey)?"_blank":AP.getAttr(G.firstChild,"target");if(!F){F=AP.getAttr(AP.getElements("base")[0],"target")}if(!F){F="_self"}window.open(B,F);return}}}var C=(H.target.nodeType==1)?H.target.nodeName:H.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(window.opera&&A=="class"){return E.className}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(window.opera&&A=="class"){C.className=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 D=document.documentElement;var C=(window.scrollX)?window.scrollX:(D.scrollLeft)?D.scrollLeft:AP.oBODY.scrollLeft;var A=(window.scrollY)?window.scrollY:(D.scrollTop)?D.scrollTop:AP.oBODY.scrollTop;AP.windowW=(window.innerWidth)?window.innerWidth:D.offsetWidth;AP.windowH=(window.innerHeight)?window.innerHeight:D.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);