function submitLink(theForm, theProduct, theName, theValue) {

    document.MyForm.downloadfile.value = theValue;
    document.MyForm.submit();

    if (theProduct != '') {
        window.location = "/" + theProduct + "/thanks/?downloadfile=" + theValue;
    }
    else {
        var loc = window.location.toString();
        window.location = loc + "?downloadfile=" + theValue;
    }
    window.open("http://www.codetwo.pl/downloads/" + theValue);
}

function Trademarks(depth) {
    window.open("http://www.codetwo.pl/giegieo/znaki-towarowe/", "", "height=250,width=450,location=0,menubar=0,status=0,toolbar=0,resizeable=1,scrollbars=1");
}

function wyslijMaila(uzytkownik, serwer, subject, event) {
    location.href = "mai" + "lto:" + uzytkownik + "@" + serwer + "?" + "subject=" + subject;
    event.returnValue = false;
    if (event.preventDefault)
        event.preventDefault();
}

function ValidateFormData() {
    var name = document.getElementById('id_name');
    var email = document.getElementById('id_email');
    var mail_body = document.getElementById('id_body');

    if (name.value == '' || email.value == '' || mail_body.value == '') {
        alert('Przed wysłaniem wiadomości wypełnij wszystkie pola.');
        return false;
    }

    if (!IsSmtpAddress(email.value)) {
        email.select();
        alert("Podaj poprawny adres e-mail.");
        return false;
    }
}
/*
Sprawdza czy adres maila smtp jest poprawny
*/
function IsSmtpAddress(address) {
    if (address.length == 0)
        return false;

    // Musi byc malpa
    var atPos = address.indexOf("@");
    if (-1 == atPos) return false;

    // Musi po malpie byc kropka
    var dotPos = address.indexOf(".", atPos + 1);
    if (-1 == dotPos) return false;

    // Kropka nie moze być ostatnim znakiem
    dotPos = address.lastIndexOf(".");
    if (dotPos == address.length - 1)
        return false;

    var exp = new RegExp("[/$&^%={}() \\\\]");
    if (-1 != address.search(exp))
        return false;

    return true;
}
