﻿var floatingMenuId="";var minRange=600;var floatingMenu={targetX:0,targetY:0,hasInner:typeof(window.innerWidth)=="number",hasElement:typeof(document.documentElement)=="object"&&typeof(document.documentElement.clientWidth)=="number",menu:document.getElementById?document.getElementById(floatingMenuId):document.all?document.all[floatingMenuId]:document.layers[floatingMenuId]};floatingMenu.move=function(){floatingMenu.menu.style.left=floatingMenu.nextX+"px";if(floatingMenu.nextY<minRange){floatingMenu.menu.style.top=floatingMenu.nextY+"px"}};floatingMenu.computeShifts=function(){var a=document.documentElement;floatingMenu.shiftX=floatingMenu.hasInner?pageXOffset:floatingMenu.hasElement?a.scrollLeft:document.body.scrollLeft;if(floatingMenu.targetX<0){floatingMenu.shiftX+=floatingMenu.hasElement?a.clientWidth:document.body.clientWidth}floatingMenu.shiftY=floatingMenu.hasInner?pageYOffset:floatingMenu.hasElement?a.scrollTop:document.body.scrollTop;if(floatingMenu.targetY<0){if(floatingMenu.hasElement&&floatingMenu.hasInner){floatingMenu.shiftY+=a.clientHeight>window.innerHeight?window.innerHeight:a.clientHeight}else{floatingMenu.shiftY+=floatingMenu.hasElement?a.clientHeight:document.body.clientHeight}}};floatingMenu.calculateCornerX=function(){if(floatingMenu.targetX!="center"){return floatingMenu.shiftX+floatingMenu.targetX}var a=parseInt(floatingMenu.menu.offsetWidth);var b=floatingMenu.hasElement?(floatingMenu.hasInner?pageXOffset:document.documentElement.scrollLeft)+(document.documentElement.clientWidth-a)/2:document.body.scrollLeft+(document.body.clientWidth-a)/2;return b};floatingMenu.calculateCornerY=function(){if(floatingMenu.targetY!="center"){return floatingMenu.shiftY+floatingMenu.targetY}var a=parseInt(floatingMenu.menu.offsetHeight);var b=floatingMenu.hasElement&&floatingMenu.hasInner&&document.documentElement.clientHeight>window.innerHeight?window.innerHeight:document.documentElement.clientHeight;var c=floatingMenu.hasElement?(floatingMenu.hasInner?pageYOffset:document.documentElement.scrollTop)+(b-a)/2:document.body.scrollTop+(document.body.clientHeight-a)/2;return c};floatingMenu.doFloat=function(){if(!floatingMenu.menu){menu=document.getElementById?document.getElementById(floatingMenuId):document.all?document.all[floatingMenuId]:document.layers[floatingMenuId];initSecondary()}var d,b;floatingMenu.computeShifts();var c=floatingMenu.calculateCornerX();var d=(c-floatingMenu.nextX)*0.07;if(Math.abs(d)<0.5){d=c-floatingMenu.nextX}var a=floatingMenu.calculateCornerY();var b=(a-floatingMenu.nextY)*0.07;if(Math.abs(b)<0.5){b=a-floatingMenu.nextY}if(Math.abs(d)>0||Math.abs(b)>0){floatingMenu.nextX+=d;floatingMenu.nextY+=b;floatingMenu.move()}setTimeout("floatingMenu.doFloat()",20)};floatingMenu.addEvent=function(b,d,c){if(typeof b[d]!="function"||typeof b[d+"_num"]=="undefined"){b[d+"_num"]=0;if(typeof b[d]=="function"){b[d+0]=b[d];b[d+"_num"]++}b[d]=function(h){var g=true;h=(h)?h:window.event;for(var f=b[d+"_num"]-1;f>=0;f--){if(b[d+f](h)==false){g=false}}return g}}for(var a=0;a<b[d+"_num"];a++){if(b[d+a]==c){return}}b[d+b[d+"_num"]]=c;b[d+"_num"]++};floatingMenu.init=function(){floatingMenu.initSecondary();floatingMenu.doFloat()};floatingMenu.initSecondary=function(){floatingMenu.computeShifts();floatingMenu.nextX=floatingMenu.calculateCornerX();floatingMenu.nextY=floatingMenu.calculateCornerY();floatingMenu.move()};Dofloating=function(a,b){floatingMenu.menu=document.getElementById?document.getElementById(a):document.all?document.all[a]:document.layers[a];if(floatingMenu.menu==null){return}minRange=b;if(document.layers){floatingMenu.addEvent(window,"onload",floatingMenu.init)}else{floatingMenu.init();floatingMenu.addEvent(window,"onload",floatingMenu.initSecondary)}};