/**
 * kareg.de file: main.js
 *  
 * @copyright (C) 2006 web-prinz.de (mih)
 * @author Michael Hansen <webmaster@web-prinz.de>
 * @package kareg.de
 * @version 1.0.0
 */



/**
 * open a popup window
 *
 * Opens a file in a popup window with defined width and height. The window will
 * always been displayed in the center of the viewport.
 *
 * @param file   string the file you want to display
 * @param width  int    window width
 * @param height int    window height
 * @param params string here you can define your own window settings
 */

function openPopup(file, name, pWidth, pHeight, params) {
    if ( screen.availWidth > pWidth ) {
        moveX = (screen.availWidth - pWidth) / 2;
    } else {
        pWidth = screen.availWidth;
        moveX = 0;
    }

    if ( screen.availHeight > pHeight ) {
        moveY = (screen.availHeight - pHeight) / 2;
    } else {
        pHeight = screen.availHeight;
        moveY = 0;
    }

    if (params != '') {
        window.open(file, name, params + ', width=' + pWidth + ', ' +
                'height=' + pHeight + ', top=' + moveY + ', left=' + moveX);
    } else {
        window.open(file, name, 'scrollbars=no, resizable=no, toolbar=no, ' +
                'menubar=no, location=no, width=' + pWidth + ', ' +
                'height=' + pHeight + ', top=' + moveY + ', left=' + moveX);
    }
} // end of function openPopup


/**
 * hide and show container referenced by id
 *
 * @param id container for DOM element
 */
 
function swapContentWithImage(id) {
    if (document.getElementById) {
        var elem = document.getElementById(id);
        var img  = document.getElementById('arrow_' + id);
    } else if(document.all && !document.getElementById) {
        var elem = document.all[id];
        var img  = document.all['arrow_' + i];
    } else {
        return false;
    }
     
    if (elem.style.display == "block") {
        elem.style.display = "none";
        img.src = 'images/icons/plus.jpg';
    } else {
        elem.style.display = "block";
        img.src = 'images/icons/minus.gif';
    }
    
}  // end of function swapContentWithImage


/**
 * hide and show container referenced by id
 *
 * @param id container for DOM element
 */
 
function swapContent(id) {
    if (document.getElementById) {
        var elem = document.getElementById(id);
    } else if(document.all && !document.getElementById) {
        var elem = document.all[id];
    } else {
        return false;
    }
     
    if (elem.style.display == "block") {
        elem.style.display = "none";
    } else {
        elem.style.display = "block";
    }
    
}  // end of function swapContent
