﻿
function SetWaterMark(txt, evt, defaultText) {
    if (txt.value.length == 0 && evt.type == "blur") {
        txt.style.color = "gray";
        txt.value = defaultText;
    }

    if (txt.value == defaultText && evt.type == "focus") {
        txt.style.color = "black";
        txt.value = "";
    }
}

function HideLoginBox() {
    document.getElementById('globalMask').style.display = 'none';
    document.getElementById('loginbox').style.display = 'none';
    document.getElementById('loginbox').className = '';
}

function ShowLoginBox(classname) {
    document.getElementById('globalMask').style.display = 'block';

    var divLog = document.getElementById('loginbox');
    divLog.style.display = 'block';
    divLog.className = classname;

    var h2Header = document.getElementById('h2Header');

    var value = "Pacjent";
    if (classname == "loginnurse") {
        value = "Pielegniarka";
    }
    else if (classname == "logindoctor")
    {
        value = "Lekarz";
    }
    h2Header.innerHTML = "Zaloguj się jako<strong>"+value+"</strong><span></span>";


}
function openCalendar(controlId) {
    var ctrl = document.getElementById(controlId);
    openPopupWindow('/_controls/calendar/datePicker.aspx?date=' + ctrl.value + '&controlId=' + controlId, 'calendar', 200, 200, null, null);
}

function openListWindow(url, name) {
    openPopupWindow(url, name, 700, 600);
}

function openPopupWindow(url, name, width, height, posX, posY) {
    var sFeatures = 'status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=0,width=' + width + ',height=' + height;

    if (posX == null) {
        var leftPos = (screen.width - width) / 2;
        var topPos = (screen.height - height) / 2;

        sFeatures += ',left=' + leftPos + ',top=' + topPos;
    }
    else
        sFeatures += ',left=' + posX + ',top=' + posY;

    return window.open(url, name, sFeatures, true);
}

function isEmpty(str) {
    if (str == null) return true;
    if (str.length == 0) return true;

    for (var i = 0; i < str.length; i++) {
        if (str.charAt(i) != ' ')
            return false;
    }

    return true;
}

