/* Javascript by Daniel Cohen Gindi (c) danielgindi@gmail.com 054-5655765 */
/* Version: 2011-08-09 */
// Depends on dgTools.js
function FloatingDiv(options) {
    return this.init(options);
}
FloatingDiv.prototype = {
    init: function(options) {
        var self = this;
        options = options || {};
        var el = dgTools.$(options.element);
        if (!el) return false;
        self.cx = self.sx = options.sx;
        self.cy = self.sy = options.sy;
        el.style.zIndex = (options.zIndex != null && options.zIndex != undefined) ? options.zIndex : 9999;
        el.style.position = 'absolute';
        el.float = function() {
            var pX = (self.sx >= 0) ? 0 : window.getClientWidth();
            var pY = window.getScrollOffsets().top;
            if (self.sy < 0) pY += window.getClientHeight();
            self.cx += (pX + self.sx - self.cx) / 8;
            self.cy += (pY + self.sy - self.cy) / 8;
            el.style.left = self.cx + 'px';
            el.style.top = self.cy + 'px';
            setTimeout(function() { el.float(); }, 40);
        }
        el.float();
        return this;
    }
}


