/**
 * Some JavaScript functions to improve look and feel
 *
 * <p>Without this script the page is still functional</p>
 *
 * @package Yord_nl
 * @author Marc Kortleven <mkortleven@refdag.nl>
 * @version $Id: default_bottom.js,v 1.3 2004/09/03 14:38:19 mkortleven Exp $
 */

/**
 * Store timeout handles
 */
myTimeout = new Array
/**
 * Store status of elements
 */
myStatus = new Array();

function createBookmark()
{
    var url = location.href;
    var title = document.title;
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title);
    } else if(window.opera && window.print) { // Opera Hotlist
        return true;
    }
}

function setHomepage(link)
{
    link.style.behavior='url(#default#homepage)';
    link.setHomePage('http://yord.nl/');
}

/**
 * Extend child
 */
function ExtendChild(theElement, theType)
{
    myChildDivs = theElement.getElementsByTagName('DIV');
    for (i = 0; i < myChildDivs.length; i++) {
        myChild = myChildDivs.item(i);
        if (myTimeout[myChild.id] && (myTimeout[myChild.id] != 0)) {
            clearTimeout(myTimeout[myChild.id]);
            myTimeout[myChild.id] = 0;
        }
        if (myChild.id.match(/_extend_div_id$/)) {
            if (theType == 'toggle') {
                if (myStatus[myChild.id] && (myStatus[myChild.id] == 'visible')) {
                    myStatus[myChild.id] = 'hiding';
                } else {
                    myStatus[myChild.id] = 'extending';
                }
                ExtendAnimator(myChild.id);
            } else if (theType == 'show') {
                if (myStatus[myChild.id] != 'visible') {
                    myStatus[myChild.id] = 'extending';
                    ExtendAnimator(myChild.id);
                }
            } else if (theType == 'hide') {
                myTimeout[myChild.id] = setTimeout("ExtendHide('" + myChild.id + "')", 5000);
            }
            break;
        }
    }
}

function ExtendHide(theId)
{
    myStatus[theId] = 'hiding';
    ExtendAnimator(theId);
}

/**
 * Extend or hide elements with little steps
 */
function ExtendAnimator(theId)
{
    myElement = document.getElementById(theId);
    myContentElement = myElement.firstChild;
    if (myStatus[theId] == 'extending') {
        if (myElement.style.display != 'block') {
            myElement.style.display = 'block';
            myHeight = 0;
        } else {
            myHeight = parseInt(myElement.style.height.replace(/^([0-9\.-]+)[^0-9\.-]*/,'$1')) + 4;
        }
        myElement.style.height = myHeight + 'px';
        if (myHeight < myContentElement.offsetHeight) {
            setTimeout("ExtendAnimator('" + theId + "')", 20);
        } else {
            myStatus[myChild.id] = 'visible';
            HeightAdjust();
        }
    } else if (myStatus[theId] == 'hiding') {
        myHeight = parseInt(myElement.style.height.replace(/^([0-9\.-]+)[^0-9\.-]*/,'$1')) - 4;
        if (myHeight >= 0) {
            myElement.style.height = myHeight + 'px';
            setTimeout("ExtendAnimator('" + theId + "')", 20);
        } else {
            myElement.style.display = 'none';
            myStatus[myChild.id] = 'hidden';
            HeightAdjust();
        }
    }
}
