
/*
 * This class is used to drag the title bar over the title picture.
 * It only works on cool browsers. :)
 */
var dragger = {
    rules: [],
    offset: 0,
    minHeight: 53,
    maxHeight: 150,
    currentMove: null,
    currentUp: null,

    init: function() {
        if (this.rules.length == 0) {
            var sheet = document.getElementById('titleStyle').sheet;
            if (sheet) {
                for (var k=0, rule; rule=sheet.cssRules[k]; k++) {
                    this.rules[rule.selectorText] = rule.style;
                }
                this.maxHeight = parseInt(this.rules['.logo'].maxHeight, 10);
                return true;
            }
            return false;
        }
        return true;
    },

    start: function(event) {
        if (!document.addEventListener) return;
        if (!this.init()) return;
        if (event.button != 0) return;

        var startpos = event.clientY + window.scrollY;
        this.offset = parseInt(this.rules['.title'].height, 10) - startpos;
        this.rules['.logo img'].cursor = 'n-resize';

        var closureThis = this;
        this.currentMove = function(evt) { closureThis.doMouseMove(evt) };
        this.currentUp =  function(evt) { closureThis.doMouseUp(evt) };
        
        document.addEventListener("mousemove", this.currentMove, true);
        document.addEventListener("mouseup", this.currentUp, true);
        event.preventDefault();
    },
    
    doMouseMove: function(event) {
        var y = event.clientY + window.scrollY + this.offset;
        if (y < this.minHeight) y = this.minHeight;
        if (y > this.maxHeight) y = this.maxHeight;

        this.rules['.title'].height = y + 'px';
        this.rules['.logo'].height = y + 'px';
        this.rules['.logo img'].marginTop = (y - this.minHeight) + 'px';
        this.rules['.titletag'].top = (y - this.minHeight + 28) + 'px';
    },

    doMouseUp: function(event) {
        this.rules['.logo img'].cursor = 'auto';
        document.removeEventListener("mousemove", this.currentMove, true);
        document.removeEventListener("mouseup", this.currentUp, true);
    }
}


function setReplyTo(id) {
    document.forms['postcomment']['cmtReplyTo'].value = id;
}

