function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

function redirect(url) {
    document.location.href = url;
}

function warning() {
    if (isRestricted(document.location.href)) {
       redirect('http://video.elfox.net/warning/?back=' + escape(document.location.href));
    }
}

function getElement(id) {
    return document.getElementById(id);
}

function isRestricted(url) {
    return ((url.match('load/3') || url.match('load/3')) && readCookie('accept') == null);
}