if(Browser){
    /* Fix hover states in IE 6 and below */
    if(Browser.Engine.name == 'trident' && Browser.Engine.version < 5){
    window.addEvent('domready', function(){
        $$('li.withsub').each(function(el){
            el.addEvent('mouseenter', function(e){
                e.preventDefault();
                var origClass = el.get('class');
                el.store('default_class', origClass);
                el.set('class', origClass + ' hover');
            });

            el.addEvent('mouseleave', function(e){
                e.preventDefault();
                el.set('class', el.retrieve('default_class'));
            });
        });
    });
    }
}

// Popops for emailers
window.addEvent('domready', function(){
    $$('a.emailerpop').each(function(el){
        el.addEvent('click', function(e){
            e.preventDefault();
            var url = el.get('href');
            openPreviewWindow(url);
        });
    });
});


// Popops for emailers
window.addEvent('domready', function(){
    $$('a.emailerpop').each(function(el){
        el.addEvent('click', function(e){
            e.preventDefault();
            var url = el.get('href');
            openPreviewWindow(url);
        });
    });
});

//
function openPreviewWindow(url){
    if(url) window.open(
        url,
        'new',
        'width=600, height=600, scrollbars=yes'
    );
}

//
function openParentCloseThis(url){
    if(url){
        if(window.opener && !window.opener.closed){
            window.opener.location = url;
            window.close();
        } else {
            window.location = url;
        }
    }
    return false;
}

// Handle subscribe / unsubscribe boxes.

/**
 * Events:
 */
window.addEvent('domready', function(){
    
    $$('form.newsletter').each(function(el){

        // input box and behaviors
        // subscribe options and behaviors
        // ie ~ input element
       
        var ie = el.getElement('input.miniFormInput');
        var oe = el.getElement('div.options');
        var defCopy = 'Enter your email';

        // contracted state:
        // margin: 0px; overflow: hidden; position: static; height: 0px;

        if(ie && oe){

            var optSlide = new Fx.Slide(oe, {
                duration: 500,
                transition: Fx.Transitions.Pow.easeOut
            });

            optSlide.hide();

            ie.set('value', defCopy);
            ie.addEvent('focus', function(ev){
                // clear copy...
                if(ie.get('value') == defCopy) ie.set('value', '');
                optSlide.slideIn().chain(
                    function(){
                        ie.store('curState', 'OPEN');
                    }
                );
            });
            ie.addEvent('blur', function(ev){
                // restore copy to default...
                if(ie.get('value') == '') ie.set('value', defCopy);
            });
        }
    });
});