/**
 * ex. openWin('file.ext','mywin',640,480,1);
 */
function openWin(Url,Name,Width,Height,Scroll) {
    if (navigator.appVersion>='4') {
        var windowW = Width;
        var windowH = Height;
        var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
        var windowY = Math.ceil( (window.screen.height - windowH) / 2 );
        new_window = window.open(Url,Name,'left='+windowX+',top='+windowY+',width='+Width+',height='+Height+',scrollbars='+Scroll+',location=no,menubar=no,toolbar=no,status=0,statusbar=0,copyhistory=no');
        new_window.focus();
    } else {
        new_window = window.open(Url,Name,'width='+Width+',height='+Height+',scrollbars='+Scroll+',location=no,menubar=no,toolbar=no,status=0,statusbar=0');
        new_window.focus();
    }
}

/**
 * XHTML strict fix for links with target.
 * target="_blank" is replaced by rel="external" and forced back to target by this script.
 */
function externalLinks() {
    if (!document.getElementsByTagName){ return };
    var anchors = document.getElementsByTagName('a');
    for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external') {
            anchor.target = '_blank';
        }
    }
}

/**
 * disallow the page to be framed
 */
if (window.self != window.top){ 
    top.location.replace(window.location.pathname); 
}

window.onload=externalLinks;

