﻿var horton = {
    popfeaturestring: new Template('width=#{w},height=#{h},top=#{posy},left=#{posx},location=#{location},menubar=#{menubar},resizable=#{resizable},scrollbars=#{scrollbars},status=#{status},toolbar=#{toolbar}'),
    popwindefaults: { 'w': 800, 'h': 600, 'posx': 0, 'posy': 0, 'location': 'no', 'menubar': 'no', 'resizable': 'yes', 'scrollbars': 'yes', 'status': 'no', 'toolbar': 'no' },
    popwindowname: 'popout',
    popout: function(anchor) {
        return window.open(
            encodeURI(anchor.href),
            horton.popwindowname,
            horton.popfeaturestring.evaluate(Object.extend(Object.clone(horton.popwindefaults), anchor.rel.evalJSON(true))),
            true
        );
    }
};
$('page').observe('click', function(e) { //delegation
    var retvalue, elem = e.findElement('a.haspopout');
    if (retvalue = !!elem) {
        e.stop();
        elem.blur();
        horton.popout(elem).focus();
    }
    return !retvalue
});