function showElement(id)
{
    el = document.getElementById(id);
    el.style.display = '';
}

function hideElement(id)
{
    el = document.getElementById(id);
    el.style.display = 'none';
}

function showhide(id)
{
    el = document.getElementById(id);
    if (el.style.display == '') {
        hideElement(id);
    } else if (el.style.display == 'none') {
        showElement(id)
    }
}
function setStatus() {
    var msg = "ABC - na wszystko mamy meble";
    top.document.title=msg;
    window.status = msg;
}

function checkRequired() {
    if (document.getElementById("nick").value == '') {
        return document.getElementById("nick");
    }
    if ((document.getElementById("contact").checked == true) && (document.getElementById("email").value == '')) {
        return document.getElementById("email");
    }
    return null;
}

function validEmail()
{
    var invalidcheck=0;
    var str = document.getElementById("email").value;
    var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
    {
        return true;
    } else
    {
        return false;
    }
}

function checkSubmit()
{
    var msg = '';
    var emptyemail = false;

    if (document.getElementById("contact").checked == true)
    {
        if (document.getElementById("email").value == '')
        {
            emptyemail = true;
        }
    }
    if ((checkField = checkRequired()) != null)
    {
            msg = msg + "Proszę wypełnić wymagane pola.\n";
            checkField.focus();
    }
    if (document.getElementById("email").value != '')
    {
        if (!validEmail()) { msg = msg + "Adres email jest niepoprawny.\n"; }
    }
    if (msg != '')
    {
        alert(msg);
        return false;
    } else
    {
        if (document.getElementById("rate2") && document.getElementById("rate2").value == -1)
        {
            if (confirm("Nie oceniliście Państwo treści.\nCzy powrócić, aby umożliwić wystawienie oceny? (Anuluj zatwierdza komentarz bez oceny)"))
            {
                return false;
            } else
            {
                return true;
            }
        }
        return true;
    }
}

//validates form for Bezplatny Start
function openForm(program, file) {    
    iWidth = 350;
    iHeight = 500;
    iLeft = (screen.width - iWidth) / 2;
    iTop = (screen.height - iHeight) / 2 - 50;
    window.open("CTrialForm.php?program=" + program + "&program_file=" + file + "&sth_else", "trial", "height="+iHeight+",width="+iWidth+",top="+iTop+",left="+iLeft+",toolbar=no,scrollbars=no,fullscreen=no,resizable=no,status=no");
}
// form for Demo version
function openDemo(program, number) {
var PopUpX = (screen.width/2)-150;
var PopUpY = (screen.height/2)-200;
var pos = "left="+PopUpX+",top="+PopUpY;
    window.open("CDemoForm.php?program=" + program + "&id=" + number + "&sth_else", "Demo");
}

