function pulpcore_getCookie(name) {
    name = name + "=";
    
    var i;
    if (document.cookie.substring(0, name.length) == name) {
        i = name.length;
    }
    else {
        i = document.cookie.indexOf('; ' + name);
        if (i == -1) {
            return null;
        }
        i += name.length + 2;
    }
    
    var endIndex = document.cookie.indexOf('; ', i);
    if (endIndex == -1) {
        endIndex = document.cookie.length;
    }
    
    return unescape(document.cookie.substring(i, endIndex));
}


function pulpcore_setCookie(name, value, expireDate, path, domain, secure) {
    var expires = new Date();
    
    if (expireDate == null) {
        // Expires in 90 days
        expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000) * 90);
    }
    else {
        expires.setTime(expireDate);
    }
    
    document.cookie = 
        name + "=" + escape(value) +
    	"; expires=" + expires.toGMTString() +
    	((path) ? "; path=" + path : "") +
    	((domain) ? "; domain=" + domain : "") +
    	((secure) ? "; secure" : "");
}


function pulpcore_deleteCookie(name, path, domain) {
    document.cookie = name + "=" + 
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}


function pulpcore_hide(id) {
    document.getElementById(id).style.display = "none";
    document.getElementById(id).style.visibility = "hidden";
}


function pulpcore_show(id) {
    document.getElementById(id).style.display = "block";
    document.getElementById(id).style.visibility = "visible";
}


function pulpcore_appletLoaded() {
    pulpcore_showGame();
    
    // For Safari
    setTimeout("pulpcore_showGame();", 10);
}


function pulpcore_showGame() {
    pulpcore_hide('pulpsplash');
    pulpcore_show('pulpgame');
}


function pulpcore_insertApplet(name, archive, width, height, bgcolor, fgcolor, paintMode) {
    document.write('<applet code="' + name + '" archive="' + archive + '" width="' + width + '" height="' + height + '" MAYSCRIPT>\n');
    document.write('<param name="boxbgcolor" value="' + bgcolor + '" />\n');
    document.write('<param name="boxfgcolor" value="' + fgcolor + '" />\n');
    document.write('<param name="boxmessage" value="" />\n');
    if (paintMode != null && paintMode.length > 0) {
        document.write('<param name="ACTOR_PAINT_MODE" value="' + paintMode + '" />\n');
    }
    document.write('Oops! Java is not enabled.<br><a href="http://www.java.com/">Click to Install.</a>\n');
    document.write('</applet>\n');
}
