/* 50/50 method of finding webbrowser and DOM */
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

// ---------------------------------------------------------------------------
// Mailfunction created by Joakim
function mailto (topdomain, domain, user) {
	location = 'mailto:' + user + '@' + domain + '.' + topdomain;
}
// ---------------------------------------------------------------------------
// Allows us to easily access a DIV
function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}
// ---------------------------------------------------------------------------


// Layer functions

// ---------------------------------------------------------------------------
function layerVisible(LayerName) {
    if (ns4) {
        if (LayerName.style.visibility == "hidden") { return false; }
    }else if (ns6) {
        if (LayerName.style.visibility=="hidden") { return false; }
    }else{
        if (LayerName.style.visibility=="hidden") { return false; }
    }

    // False events did not trigger //
    return true;

}
// ----------------------------------------------------------------------------
function showDiv(divID_as_a_string) {
    //get a reference as above ...
    myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        window.alert('Nothing works in this browser');
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM & proprietary DOM
        myReference.style.visibility = 'visible';
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'show';
        } else {
            window.alert('Nothing works in this browser');
            return false; //don't go any further
        }
    }
    return true;
}
// ----------------------------------------------------------------------------
function hideDiv(divID_as_a_string) {
	var myReference = getRefToDiv(divID_as_a_string);
	if( !myReference ) { window.alert('Err...'); return; }
	if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
		if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
			window.alert('Err...'); return; } }
}
// ----------------------------------------------------------------------------
function toggleDiv(strDivID) {
    if (!layerVisible(getRefToDiv(strDivID))) {
        showDiv((strDivID));
    }else{
        hideDiv((strDivID));
    }
}
// ----------------------------------------------------------------------------