﻿$(document).ready(function() {

    // MPS/DPL
    $("#cookieaccept").click(function() { AllowCookies(); });
    $("#cookiereject").click(function() { ClearCookies(); });
    $(".clearcookies").click(function() { ClearCookies(); location.href = "/"; });

    // Only on MPS
    var allowed = $.cookie("allowed");
    if (allowed != undefined) {
        $("#CookieCheckBox").attr("checked", true);
    }
    else {
        $("#CookieCheckBox").attr("checked", false);
    }

    $("#CookieCheckBox").click(function() {
        if ($(this).attr("checked")) {
            AllowCookies();
        }
        else {
            ClearCookies();
        }
    });

});

function ClearCookies() {
    $.cookie("allowed", null, { path: '/' });
    $.cookie("region", null, { path: '/' });
}
function AllowCookies() {
    $.cookie("allowed", "true", { expires: 365, path: '/' });
}
function GoToRegion() {
    var region = $.cookie("region");
    if (region != undefined) {
        location.href = region;
    }
}
function SaveRegion() {
//    var allowed = $.cookie("allowed");
//    if (allowed != undefined) {
        $.cookie("region", location.href, { expires: 365, path: '/' });
//    }
}
function DisplayConsent() {
//    var allowed = $.cookie("allowed");
//    if (allowed == undefined) {
//        $("#cookies").overlay({
//            top: 260,
//            mask: {
//                color: '#fff',
//                loadSpeed: 200,
//                opacity: 0.5
//            },
//            closeOnClick: false,
//            load: true
//        });
//    }
}
