var SmartHoverBox=new Class({Implements:Options,options:{boxTimer:1000,yOffset:-10,xOffset:-10,smartBoxSuffix:"_smarthbox",smartBoxClose:"smarthbox_close",lockY:"",lockX:""},initialize:function(a){this.setOptions(a);this.pos=[];this.smartBoxes=$$("[id$="+this.options.smartBoxSuffix+"]");this.closeElem=$(document.body).getElements("."+this.options.smartBoxClose);this.closeElem.addEvent("click",function(b){b.preventDefault();this.closeBox()}.bind(this)).setStyle("cursor","pointer");this.smartBoxes.setStyle("display","none");this.showHideBox();this.closeBox()},showHideBox:function(){this.smartBoxes.each(function(a){this.getCurrentBox(a);a.addEvent("mouseleave",function(){this.closeBoxTimer()}.bind(this));a.addEvent("mouseenter",function(){$clear(this.delay)}.bind(this));$(this.currentBox).addEvent("mouseleave",function(){this.closeBoxTimer()}.bind(this));$(this.currentBox).addEvent("mouseenter",function(){this.getCurrentBox(a);$clear(this.delay);this.smartBoxes.setStyle("display","none");a.setStyles({display:"block",position:"absolute"}).setStyle("z-index","1000000");this.positioning(a,this.currentBox)}.bind(this)).setStyle("cursor","pointer")}.bind(this))},closeBoxTimer:function(){this.hideEm=function(){this.closeBox()}.bind(this);this.delay=this.hideEm.delay(this.options.boxTimer)},closeBox:function(){this.smartBoxes.setStyle("display","none")},positioning:function(b,a){this.pos.windowSize=$(window).getSize();this.pos.windowScroll=$(window).getScroll();this.pos.boxSize=b.getSize();this.pos.inputPOS=$(a).getCoordinates();this.pos.inputCOOR=$(a).getPosition();this.pos.inputSize=$(a).getSize();this.pos.halfWindowY=this.pos.windowSize.y/2;this.pos.halfWindowX=this.pos.windowSize.x/2;this.pos.inputBottomPOS=this.pos.inputPOS.top+this.pos.inputSize.y;this.pos.inputBottomPOSAdjust=this.pos.inputBottomPOS-this.pos.windowScroll.y;this.pos.inputLeftPOS=this.pos.inputPOS.left+this.options.xOffset;this.pos.inputRightPOS=this.pos.inputPOS.right;this.pos.leftOffset=this.pos.inputCOOR.x+this.options.xOffset;if(this.pos.halfWindowY<this.pos.inputBottomPOSAdjust&&this.options.lockY=="none"||this.options.lockY=="top"){b.setStyle("top",this.pos.inputPOS.top-this.pos.boxSize.y-this.options.yOffset);if(this.pos.inputLeftPOS<this.pos.halfWindowX&&this.options.lockX=="none"||this.options.lockX=="left"){b.setStyle("left",this.pos.leftOffset)}else{b.setStyle("left",(this.pos.inputPOS.right-this.pos.boxSize.x)-this.options.xOffset)}}else{b.setStyle("top",this.pos.inputBottomPOS+this.options.yOffset);if(this.pos.inputLeftPOS<this.pos.halfWindowX&&this.options.lockX=="none"||this.options.lockX=="left"){b.setStyle("left",this.pos.leftOffset)}else{b.setStyle("left",(this.pos.inputPOS.right-this.pos.boxSize.x)-this.options.xOffset)}}},getCurrentBox:function(a){this.currentBox=a.getProperty("id");this.currentBox=this.currentBox.replace(""+this.options.smartBoxSuffix+"","")}});