/*
 * SRMedia
 *
 * (C) 2006 
 * ZOPYX Limited & Co. KG
 * Charlottenstr. 37/1, D-72070 Tübingen, Germany
 * info@zopyx.com, www.zopyx.com 
*/


/* POPUP HANDLING */


// find all links inside the content area and check their 'popup' attribute.
// The attr refers to a method that open the URL inside a new window under some
// fixed conditions (width, height, left, right)

function fixatePopupLinks(){

    var contentarea = document.getElementById('region-content');
    if (! contentarea) {
        contentarea = document.getElementById('main');
        if (! contentarea)          {
            return false;
        }
    }

    links = contentarea.getElementsByTagName('a');

    for (i=0; i < links.length; i++) {
        var link = links[i];
        var v = link.getAttribute('popup');
        var href = link.getAttribute('href');

        if (v == 'popupTargetBlank') {
            // special target: open link with target=_blank
            link.setAttribute('target', '_blank');
        } else if (v == 'popupNewWindowNormal') {
            // open link through onclick handler
            var s = 'popupNewWindowNormal("' + href + '")';
//            link.setAttribute('href', 'javascript: void(0)');
            link.setAttribute('href', 'javascript: ' + s);
//            link.setAttribute('onclick', s);
        } 
    }
}

// register as Plohn onload handler

try {
    registerPloneFunction(fixatePopupLinks);
} catch (e) {};



// open URL inside a new window
function popupNewWindowNormal(url) {
    var win = window.open(url, "Popup", "width=800, height=640, left=0, top=0");
}


function popupNewWindowEcho(url) {
    var win = window.open(url, "Echo Voting", "width=800, height=640, left=0, top=0");
}