
// @TODO: herschrijving, zie freddy
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function copyField(from_elem, to_elem) {
    try {
        if ($jq(to_elem).val() == '') {
            $jq(to_elem).val( $jq(from_elem).val() );
        }
    } catch(e) { 
        debug(e);
    }
}

function debug(str){
    try {
        if (arguments.callee.caller.name != '') {
            str = '[' + arguments.callee.caller.name + '] ' + str;
        }
        console.debug(''+str);

    } catch(e) { } 
} // debug


function open_popup(theURL,PopupName,PopupWidth,PopupHeight,PopupFeatures) {
    var Xcoor;
    var Ycoor;
    var Popup;
    var FeaturesTotal;
    if (PopupHeight && PopupWidth) {
        if (window.screen.width > PopupWidth)
            Xcoor = (window.screen.width/2) - (PopupWidth/2);
        else
            Xcoor = 0;
        if (window.screen.height > PopupHeight)
            Ycoor = (window.screen.height/2) - (PopupHeight/2);
        else
            Ycoor = 0;
        if (PopupFeatures)
            FeaturesTotal = PopupFeatures + ",width=" + PopupWidth + ",height=" + PopupHeight + ",left=" + Xcoor + ",top=" + Ycoor + ",screenX=" + Xcoor + ",screenY=" + Ycoor;
        else
            FeaturesTotal = "width=" + PopupWidth + ",height=" + PopupHeight + ",left=" + Xcoor + ",top=" + Ycoor + ",screenX=" + Xcoor + ",screenY=" + Ycoor;
        Popup = window.open(theURL,PopupName,FeaturesTotal);
        Popup.focus;
    }
    else {
        Popup = window.open(theURL,PopupName);
        Popup.focus;
    }
    return false;
}

function setBodyBorder() {
    $jq('#header').css('borderTop', '5px solid orange');
}

function hideFlashMessage() {
    if ($jq('flash_message').length) {
        new Effect.Fade('flash_message', {duration: 3.0});
    }
}

//addLoadEvent(setBodyBorder);
addLoadEvent(hideFlashMessage);
