mozz.boxSetup = new Class(
{
    // the constructor
    init: function (bg, wrap, box)
    {
        // init vars
        var vars = new Array('bg', 'wrap', 'box');
        
        // set up new classes
        this.pos = new util.position();
        this.events = new util.events();
        this.unique = new util.unique();
        
        // save for later use
        this.uid = this.unique.createUniqueObject(document);
        document[this.uid] = this;
        
        // loop through the objects to use them
        for (var i = 0; i < vars.length; i ++)
        {
            var temp = eval(vars[i]);
            temp.honey = new mozz.honey();
            temp.honey.init($(temp.name));
            if (temp.className) $(temp.name).className = temp.className;
        }
        // set up the bg to full height
        $(bg.name).style.height = this.pos.getHeight(true) + 'px';
        
        // set up the resize checker
        eval('var func = function() {document.' + this.uid + '.moveBox()}');
        this.events.add(window, 'resize', func);
        
        // store the constructors
        this.bg = bg;
        this.wrap = wrap;
        this.box = box;
        
        // store for later use
        this.catchScroll = false;
    },
    
    showBox: function()
    {
        // set up the bg to full height
        $(this.bg.name).style.height = this.pos.getHeight(true) + 'px';
        
        // show the important stuff
        this.bg.honey.setChange({type: 'fade', max: '30', min: '0', direction: 'out', remove: true, frames: 20});
        this.wrap.honey.setChange({type: 'fade', max: '100', min: '0', direction: 'out', remove: true, frames: 30});
        
        // catch any scrolling attempt
        eval('var func = function() {document.' + this.uid + '.checkScroll()}');
        this.catchScroll = setInterval(func, 400);
        
        // return false
        return false;
    },
    
    hideBox: function(hideBg)
    {
        // make sure hideBg exists
        hideBg = (typeof(hideBg) == 'undefined') ? true : hideBg;
        
        // show the important stuff
        if (hideBg) this.bg.honey.setChange({type: 'fade', max: '30', min: '0', direction: 'in', remove: true, frames: 20});
        this.wrap.honey.setChange({type: 'fade', max: '100', min: '0', direction: 'in', remove: true, frames: 30});
        
        // cancel the scrolling moves
        clearInterval(this.catchScroll);
    },
    
    moveBox: function(e, isInstant)
    {
        if (typeof($(this.wrap.name).style.opacity) != 'undefined' && $(this.wrap.name).style.opacity > 0.9 && $(this.bg.name).style.display == 'block')
        {
            // init vars
            var mid = this.pos.getMidPoint();
            var max = Math.floor(mid.height - (this.box.height / 2));
            var min = $(this.box.name).style.marginTop;
            min = min != '' ? parseInt(min) : 0;
            
            this.box.honey.setChange({type: 'move', max: max, min: min, direction: max > min ? 'out' : 'in', frames: 15, debug: true});
        }
    },
    
    // check to see if we are scrolling
    checkScroll: function()
    {
        // init vars
        var scroll = this.pos.getScrollPos();
        
        // check for change
        if (typeof(this.scrollPos) != 'undefined' && scroll != this.scrollPos)
            this.moveBox();
        
        // setup a store if needed
        this.scrollPos = scroll;
    }
});