﻿// Gui login display effects
// Developed for the Clay Center for the Arts and Sciences of west Virginia

// 20070425 - Nick - Initial creation

function submitSearch() {
    var si = window.document.getElementById('txtGuiSearch');
    si.value = cleanTags(si.value);
    if (si && si.value.length > 0) return true;
    alert('Please enter the terms for which you wish to search.');
    return false;
}

function submitLogin() {
    var ui = window.document.getElementById('txtUsername');
    var pi = window.document.getElementById('txtPassword');
    
    if ((pi && ui) && (ui.value.length > 0 && pi.value.length > 0)) return true;
    alert('You must enter a username and password to login.');
    return false;
}

setLabels();
userLabel();
passLabel();
function setLabels() {
    var ul = window.document.getElementById('lblUser');
    var pl = window.document.getElementById('lblPass');
    if (ul && pl) {
        ul.style.border = 'solid 1px #000000';
        pl.style.border = 'solid 1px #000000';
        ul.style.backgroundColor = '#FFFFFF';
        pl.style.backgroundColor = '#FFFFFF';
        ul.style.color = '#CDCBCB';
        pl.style.color = '#CDCBCB';
    }
}
function userBlur() {
    var ui = window.document.getElementById('txtUsername');
    if (ui && ui.value.length <= 0) userLabel();
    else ui.value = cleanTags(ui.value);
    passInput();
}
function passBlur() {
    var pi = window.document.getElementById('txtPassword');
    if (pi && pi.value.length <= 0) passLabel();
    else pi.value = cleanTags(pi.value);
}
function userLabel() {
    var ul = window.document.getElementById('lblUser');
    var ui = window.document.getElementById('txtUsername');
    if (ui && ul) {
        hide(ui);
        show(ul);
    }
}
function userInput() {
    var ul = window.document.getElementById('lblUser');
    var ui = window.document.getElementById('txtUsername');
    if (ui && ul) {
        hide(ul);
        show(ui);
    }
}
function passLabel() {
    var pl = window.document.getElementById('lblPass');
    var pi = window.document.getElementById('txtPassword');
    if (pi && pl) {
        hide(pi);
        show(pl);
    }
}
function passInput() {
    var pl = window.document.getElementById('lblPass');
    var pi = window.document.getElementById('txtPassword');
    if (pi && pl) {
        hide(pl);
        show(pi);
    }
}
function hide(e) {
    if (e) {
        e.style.display = 'none';
    }
}
function show(e) {
    if (e) {
        e.style.display = 'block';
        e.focus();
    }
}

function cleanTags(value) {
    return value.replace(/(<)|(>)|(<[^>]*>)/,'');
}