$(function () {
    if (pripnout == 'inherit') {
        $("#cookiesPanel").prependTo("body").show();
    }
    $(window).on('load', function () {
        if (typeof $.uniform !== 'undefined') {
            $.uniform.restore("#nezbytne, #reklamni, #analyticke");
        }
    });
	
    function CookiesReload() {
        if (typeof reload !== 'undefined' && reload == 1) {
            new_location = location.href.replace('?orsigo_cookies_v2_force', '');
            //window.location.href = new_location;
        }
    }

    $(document).on('click', '#cookiesPanel #ShowCustom', function () {
        $('#cookiesPanel #cookies_custom').show();
		$("#cookiesPanel #ShowCustom").fadeOut();
        $('#cookiesPanel #AcceptCustomDiv').show();
    });

    $(document).on('click', '#cookiesPanel #AcceptAll', function () {
        $.ajax
        ({
            async: true,
            cache: false,
            url: cookies_ajax_url,
            data: {
                'id_guest': cookies_id_guest,
                'reklamni': 1,
                'analyticke': 1,
                'click_type': 'all'
            },
            type: 'post',
            success: function (result) {

            }, error: function (result, status) {

            }
        });

        SetcksCookiesEu();
        $('#cookiesPanel').slideUp(1000);
		CookiesReload();
    });
	
    $(document).on('click', '#cookiesPanel #CloseAll', function () {
        $.ajax
        ({
            async: true,
            cache: false,
            url: cookies_ajax_url,
            data: {
                'id_guest': cookies_id_guest,
                'reklamni': 0,
                'analyticke': 0,
                'click_type': 'custom'
            },
            type: 'post',
            success: function (result) {

            }, error: function (result, status) {

            }
        });

        SetcksCookiesEu();
        $('#cookiesPanel').slideUp(1000);
		CookiesReload();
    });
	

    $(document).on('click', '#cookiesPanel #AcceptCustom', function () {
        reklamni = parseInt($("#reklamni:checked").val());
        if (isNaN(reklamni)) {
            reklamni = 0;
        }
        analyticke = parseInt($("#analyticke:checked").val());
        if (isNaN(analyticke)) {
            analyticke = 0;
        }

        $.ajax
        ({
            async: true,
            cache: false,
            url: cookies_ajax_url,
            data: {
                'id_guest': cookies_id_guest,
                'reklamni': reklamni,
                'analyticke': analyticke,
                'click_type': 'custom'
            },
            type: 'post',
            success: function (result) {

            }, error: function (result, status) {

            }
        });

        SetcksCookiesEu();
        $('#cookiesPanel').slideUp(1000);
		CookiesReload();

    });

});