


function AddSnipe2()
{
    var valid = true;
    var form = GET('MainForm');
    var currPrice = form['CurrentPrice'].value;
    if (currPrice) currPrice = parseFloat(currPrice.replace(/,/, ".")); else currPrice=0;
    var maxPrice = form['MaxPrice'].value;
    if (maxPrice) maxPrice = parseFloat(maxPrice.replace(/,/, ".")); else maxPrice=0;
    var shotTime = parseInt(form['ShotTime'].value, 10);
    var quantity = parseInt(form['Quantity'].value, 10);
    var amount = parseInt(form['Amount'].value, 10);

    if (!quantity
        || quantity < 1
        || quantity > amount)
    {
        alert('Proszę określić ile przedmiotów licytować');
        form.elements['Quantity'].focus();
        valid = false;
    } else if (maxPrice <= 0) {
        alert('Proszę podać cenę maksymalną');
        form.elements['MaxPrice'].focus();
        valid = false;
    } else if (Math.round(100*maxPrice) <= Math.round(100*currPrice)) {
        alert('Twoja oferta musi być większa niż obecna cena');
        form.elements['MaxPrice'].focus();
        valid = false;
    } else if (!shotTime || shotTime < 1) {
        alert('Czas licytacji zbyt krótki (min. 1 sek.)');
        form.elements['ShotTime'].focus();
        valid = false;
    } else if (shotTime > 300) {
        alert('Czas zalicytowania zbyt duży (max. 300 sekund)');
        form.elements['ShotTime'].focus();
        valid = false;
    }

    if (valid && shotTime < 4) {
        if (!confirm('Bezpieczny czas strzału to około 5 sekund. Czy kontynuować z podaną wartością (' + shotTime + ' sek.) ?')) {
            form.elements['ShotTime'].focus();
            valid = false;
        }
    }

    return valid;
}


function RemoveShot(id)
{
    if (confirm('Czy na pewno chcesz usunąć ten strzał?')) {
        document.forms['MainForm'].elements['DeleteId'].value = id;
        document.forms['MainForm'].submit();
    }
}


function GroupAction(id, action)
{
    if (action=='Edit') {		//zmiana nazwy grupy
        document.forms['MainForm'].elements['Action'].value = action;
        document.forms['MainForm'].elements['Value'].value = id;
        document.forms['MainForm'].submit();
    }
}
