// ****************************
// Popup functions
// ****************************

// the functions in this file require the supplementary library lib.js
// These defaults should be changed the way it best fits your site
//var _POPUP_FEATURES = '';
var _POPUP_FEATURES = 'location=0,statusbar=1,scrollbars=1,menubar=0,width=700,height=600,resizable=1';

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow;
    
    theWindow = null;
    theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function help_popup(from) {
    // pops up a help window at the center of the screen
    var position = "right";
    
    if (position == "center") {
            _width  = 700;
            _height = 600;
            _left   = (screen.width-_width)/2;
            _top    = (screen.height-(_height+110))/2; 
    }
    if (position == "right") {
            _width  = 500;
            _height = (screen.height);
            _left   = (screen.width - _width);
            _top    = 0;
    }
    
    features = 'location=0,statusbar=1,scrollbars=1,menubar=0,' + 
               'width=' + _width + ',height=' + _height + ',resizable=1' +
               ',left=' + _left + ',top=' + _top;
    
    window.open(from, '_blank', features);
    return false;
}

function event_popup(e) {
    // to be passed as an event listener
    // pops up a window grabbing the url from the event source's href
    link_popup(e.currentTarget);
    e.preventDefault();
}

function event_popup_features(features) {
    // generates an event listener similar to event_popup, but allowing window features
    return function(e) { link_popup(e.currentTarget, features); e.preventDefault() }
}

// ****************************
// Switch basic/pro menu functions
// ****************************

function switchMode (mode) {
  if (mode > 0) {	
    if (mode == 1) {		
      // van basic naar pro
      linkSwitch = "<a class='icon icon_switch' href='frames_promenu.php' onclick='switchMode(2)' target='frameMain' title='Open Promenu'>Promenu</a>";
    } else {
      // van pro naar basic
      linkSwitch = "<a class='icon icon_switch' href='basicmenu.php' onclick='switchMode(1)' target='frameMain' title='Open Basicmenu'>Basicmenu</a>";
    }  
    document.getElementById('switch').innerHTML = linkSwitch;
  }
}