// JQUERY FUNCTIONs
$(document).ready(function() {

    $('#next_postaw').hide();
    $('#next_postaw_cou_show').hide();
    $('#td_prize2').hide();
    $('#td_prize3').hide();

    $('#rate').keyup(
        function()
        {
            var rate = parseFloat($('#rate').attr('value').replace(/,/,"."));
            var max_rate = parseFloat($('#max_rate').attr('value'));
            var course = parseFloat($('#course').attr('value').replace(/,/,"."));
            var prize = Math.round(rate * course * 100) / 100;

            if(isNaN(prize))
            {
                $('#prize span').html('0');
            }
            else
            {
                $('#prize span').html(prize);
            }

            if (rate > max_rate)
            {
                $('#td_prize1').hide();
                $('#td_prize3').show();
                $('#next_dalej').hide();
            }
            else
            {
                $('#td_prize1').show();
                $('#td_prize3').hide();
                $('#next_dalej').show();
            }

            if (prize > 500000)
            {
                $('#td_prize1').hide();
                $('#td_prize2').show();
                $('#next_dalej').hide();
            }
            else
            {
                $('#td_prize1').show();
                $('#td_prize2').hide();
                if (rate > max_rate)
                {
                    $('#next_dalej').hide();
                }
                else
                {
                    $('#next_dalej').show();
                }
            }
        }
    );

    $('#next_dalej td input').click(
        function()
        {
            $('#next_dalej').hide();
            $('#next_postaw_cou_show').show();
            $('#next_postaw').show();
        }
    );

    $('#next_postaw td input + input').click(
        function()
        {
            $('#next_dalej').show();
            $('#next_postaw_cou_show').hide();
            $('#next_postaw').hide();
        }
    );
        
    $('.gotourl').hover(
        function()
        {
            $(this).css('background', '#dee2a0');
        },
        function()
        {
            $(this).css('background', '#dce2dc');
        }
    );
        
    $('#shoubox_send').click(
        function () 
        {
            setTimeout(function () {$('#shoubox_comment').attr('value','')},100);
        }
    );
});

function mailtoAdmin()
{
    parent.location.href = "mailto:admin@postawkupon.pl";
}
function mailtoMarketing()
{
    parent.location.href = "mailto:marketing@postawkupon.pl";
}
function mailtoInfo()
{
    parent.location.href = "mailto:info@postawkupon.pl";
}

var valid_ok = 0;
function valid_form()
{
    if (valid_ok == 1) return true;
    return false;
}
