/* pop new windows if a rel="spawn" or rel="spawnSized" */
function spawner() {
    if (! document.getElementsByTagName) return; /* not actually used... */
    var links = document.links;
    for (var i = 0; i < links.length; i++) {
        var link = links[i];
        if (link.getAttribute('rel') == 'spawn') {
            link.target = '_blank';
        }        
        if (link.getAttribute('rel') == 'spawnSized') {
            original = link.pathname;
            coords = link.getAttribute('coords').split(',');
            width = coords[0];
            height = coords[1];
            link.setAttribute('href',
                              'javascript:spawnSized("' + original + '",' + width + ',' + height + ')');
        }
        if (link.getAttribute('rel') == 'spawnSizedDoc') {
            original = link.href;
            coords = link.getAttribute('coords').split(',');
            width = coords[0];
            height = coords[1];
            link.setAttribute('href',
                              'javascript:spawnSizedDoc("' + original + '",' + width + ',' + height + ')');
        }
    }
}
window.onload = spawner;

/* pop sized window */
function spawnSized(img, width, height) {
    window_attributes = 'scrollbars,resizable,width=' + (width + 20) + ',height=' + (height + 50);
    publication = window.open('portfolio_image.php?img=' + img,
                              'publication',
                              window_attributes);
    publication.focus();
}

function spawnSizedDoc(dest, width, height) {
    window_attributes = 'scrollbars,resizable,width=' + (width + 20) + ',height=' + (height + 50);
    publication = window.open(dest,
                              'publication',
                              window_attributes);
    publication.focus();
}
