// this is a file which holds various javascript helper functions
// these are free to use without any restrictions
// date: August 20, 2008
// author: Marcel Koek

// this function pops up a question (confirmtext) and when ok is pressed goes to given location ( redirect )
function confirmation( confirmtext, redirect ) {
    var answer = confirm( confirmtext );
    if ( answer ) {
        window.location = redirect;
        return true;
    } else {
        return false;
    }
}

// switch the visibility of an element (victim) depending on the state of a checkbox (aggressor)
function switchVisibility( victim, aggressor ) {
    victim.style.visibility = aggressor.checked?'visible':'hidden';
}

// switch the opacity and disabled-ness of an element (victim) depending on the state of a checkbox (aggressor)
function switchOpacityCheckbox( victim, aggressor ) {
    var cFF = aggressor.checked?'1':'0.4';
    var cIE = aggressor.checked?'100':'40';
    var dis = aggressor.checked?false:true;

    // enable / disable form element
    victim.disabled = dis;

    // for Firefox it would be
    victim.style.opacity = cFF;
    // for IE it would be
    victim.filters.alpha.opacity = cIE;
    // from CSS3 these properties will be the same
}

// switch the opacity of an element (victim) depending on the state of another element (aggressor) (has to be true or false)
function switchOpacity( victim, aggressor ) {
    var cFF = aggressor?'1':'0.4';
    var cIE = aggressor?'100':'40';

    // for Firefox it would be
    victim.style.opacity = cFF;
    // for IE it would be
    victim.filters.alpha.opacity = cIE;
    // from CSS3 these properties will be the same
}

// change the size property of an element
function changeSizeInput( victim, sz ) {
    victim.size = sz;
}

// get menu button image in front when mouse hovers over it
//function mouseOverMenu( field ) {
//    field.style.zIndex = 1;
//}
// put menu back when mouse is gone
//function mouseOutMenu( field ) {
//    field.style.zIndex = 0;
//}

// put specified menu button on top when loading page
function raiseMenuButton( id ) {
    document.getElementById( id ).style.zIndex = 1;
 }
 
// check the height of the div with id 'mainContent' and adjust to a minimum height if necessary
function minHeightMainContent() {
    var eNB = document.getElementById( 'newsBar' );
    var eMC = document.getElementById( 'mainContent' );
    var hNB = eNB.clientHeight;
    eMC.style.minHeight = (hNB-50)+'px';
 }


function expandItem( victim ) {
    var victimObject = document.getElementById( victim );
    var victimStyle = victimObject.getAttribute( "style" );
    var victimStyleIE6 = victimObject.style.display;
    if ( victimStyle == "display: none;" || victimStyleIE6 == "none" ) {
        victimObject.style.display = "block";
        victimObject.setAttribute( "style", "display: block;" );
    } else {
        victimObject.style.display = "none";
        victimObject.setAttribute( "style", "display: none;" );
    }
    //alert( victimStyleIE6 );
}





