function darkhorse_runevent($type, $link)
{
    global $session;
    $from = $link;
    $gameret = substr($link, 0, -1);
    $session['user']['specialinc'] = "module:darkhorse";
    require_once "lib/sanitize.php";
    $iname = get_module_setting("tavernname");
    rawoutput("<span style='color: #787878'>");
    output_notl("`c`b%s`b`c", $iname);
    $op = httpget('op');
    switch ($op) {
        case "":
        case "search":
            darkhorse_checkday();
            output("A cluster of trees nearby looks familiar...");
            output("You're sure you've seen this place before.");
            output("As you approach the grove, a strange mist creeps in around you; your mind begins to buzz, and you're no longer sure exactly how you got here.");
            if (darkhorse_tavernmount()) {
                require_once "lib/mountname.php";
                list($name, $lcname) = getmountname();
                output("%s`0 seems to have known the way, however.", $name);
            }
            output("`n`nThe mist clears, and before you is a log building with smoke trailing from its chimney.");
            output("A sign over the door says `7\"%s.\"`0", $iname);
            addnav("Enter the tavern", $from . "op=tavern");
            addnav("Leave this place", $from . "op=leaveleave");
            break;
        case "tavern":
            darkhorse_checkday();
            output("You stand near the entrance of the tavern and survey the scene before you.");
            output("Whereas most taverns are noisy and raucous, this one is quiet and nearly empty.");
            output("In the corner, an old man plays with some dice.");
            output("You notice that the tables have been etched on by previous adventurers who have found this place before, and behind the bar, a stick of an old man hobbles around, polishing glasses, as though there were anyone here to use them.");
            addnav("Talk to the old man", $from . "op=oldman");
            addnav("Talk to the bartender", $from . "op=bartender");
            // Special case here.  go and see if the comment area is blocked and
            // if so, don't put the link in.
            $args = modulehook("blockcommentarea", array("section" => "darkhorse"));
            if (!isset($args['block']) || $args['block'] != 'yes') {
                addnav("Examine the tables", $from . "op=tables");
            }
            addnav("Exit the tavern", $from . "op=leave");
            break;
        case "tables":
            require_once "lib/commentary.php";
            addcommentary();
            commentdisplay("You examine the etchings in the table:`n`n", "darkhorse", "Add your own etching:");
            addnav("Return to the Main Room", $from . "op=tavern");
            break;
        case "bartender":
            darkhorse_bartender($from);
            break;
        case "oldman":
            darkhorse_checkday();
            addnav("Old Man");
            modulehook("darkhorsegame", array("return" => $gameret));
            output("The old man looks up at you, his eyes sunken and hollow.");
            output("His red eyes make it seem that he may have been crying recently so you ask him what is bothering him.");
            if ($session['user']['sex'] == SEX_MALE) {
                output("\"`7Aah, I met an adventurer in the woods, and figured I'd play a little game with her, but she won and took almost all of my money.`0\"`n`n");
            } else {
                output("\"`7Aah, I met an adventurer in the woods, and figured I'd play a little game with him, but he won and took almost all of my money.`0\"`n`n");
            }
            $c = navcount();
            if ($c != 0) {
                output("`0\"`7Say... why not do an old man a favor and let me try to win some of it back from you?");
                if ($c > 1) {
                    output(" I can play several games!`0\"");
                } else {
                    output(" Shall we play a game?`0\"");
                }
            }
            $session['user']['specialmisc'] = "";
            addnav("Return to the Main Room", $from . "op=tavern");
            break;
        case "leave":
            output("You duck out of the tavern, and wander into the thick foliage around you.");
            output("That strange mist revisits you, making your mind buzz.");
            output("The mist clears, and you find yourself again where you were before the mist first covered you.");
            if (!darkhorse_tavernmount()) {
                output(" How exactly you got to the tavern is not exactly clear.");
            }
            $session['user']['specialinc'] = "";
            break;
        case "leaveleave":
            output("You decide that the tavern holds no appeal for you today.");
            $session['user']['specialinc'] = "";
            break;
    }
    rawoutput("</span>");
}
$setrace = httpget("setrace");
if ($setrace != "") {
    $vname = getsetting("villagename", LOCATION_FIELDS);
    //in case the module wants to reference it this way.
    $session['user']['race'] = $setrace;
    // Set the person to the main village/capital by default
    $session['user']['location'] = $vname;
    modulehook("setrace");
    addnav("Carry On");
    addnav("Continue", "newday.php?continue=1{$resline}");
} else {
    output("Where do you recall growing up?`n`n");
    addnav("Identify Yourself");
    modulehook("chooserace");
}
if (navcount() == 0) {
    clearoutput();
    page_header("No Races Installed");
    output("No races were installed in this game.");
    output("So we'll call you a 'human' and get on with it.");
    if ($session['user']['superuser'] & (SU_MEGAUSER | SU_MANAGE_MODULES)) {
        output("You should go into the module manager off of the super user grotto, install and activate some races.");
    } else {
        output("You might want to ask your admin to install some races, they're really quite fun.");
    }
    $session['user']['race'] = "Human";
    addnav("Continue", "newday.php?continue=1{$resline}");
    page_footer();
} else {
    page_header("A little history about yourself");
    page_footer();