// Miscellaneous support functions

// Verifies validity of e-mail address, passed as the field, not the value
function isEmail(fld) {
    var str = fld.value;
    var pat = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(pat)) {
        return false;
    }
    return true;
}

// Hides a div element content via the div id passed as parameter
function HideContent(d) {
    if(d.length < 1) return;
    document.getElementById(d).style.display = "none";
}

// Shows a div element content via the div id passed as parameter
function ShowContent(d) {
    if(d.length < 1) return;
    document.getElementById(d).style.display = "block";
}

// Replaces content of one div (d2) with another (d1) (both passed as parameters)
function SwapDiv(d1, d2) {
    if((d1.length < 1) || (d2.length < 1)) return;
    document.getElementById(d2).innerHTML = document.getElementById(d1).innerHTML;
}