<?php

require_once "../includes/inc.includes.php";
// Include necessary files
// set trackrow parameters (to be improved! OOP!)
$trackrow_param->artist = TRUE;
$trackrow_param->title = TRUE;
$trackrow_param->length = TRUE;
$trackrow_param->play = TRUE;
$trackrow_param->edit = TRUE;
$input = file_get_contents("php://input");
$tracklist = json_decode(send_query($input));
write_tracklist($tracklist, null, $level1);
        print "<table borders=\"0\">\n";
        print "<th class='brslist_level2'>Albums</th>";
        $albumlist = json_decode(get_albums());
        if ($albumlist) {
            foreach ($albumlist as $album) {
                if (isset($level1)) {
                    if (preg_match("/^" . stripslashes($level1) . "/i", $album->title)) {
                        print "<tr><td class='brslist_level1'>\n";
                        write_albumlink("browse.php?level0=al-ti&level1={$level1}&sourceid=", $album->cddbid, html_entity_decode($album->title, ENT_COMPAT, "UTF-8"), $sourceid);
                        print "</td></tr>\n";
                    }
                } else {
                    print "<tr><td class='brslist_level1'>\n";
                    write_albumlink("browse.php?level0=al-ti&level1={$level1}&sourceid=", $album->cddbid, html_entity_decode($album->title, ENT_COMPAT, "UTF-8"), $sourceid);
                    print "</td></tr>\n";
                }
            }
        }
        print "</table>\n";
        print "</div>\n";
        if (isset($sourceid)) {
            # sourceid specified?
            print "<div class='searchresults border-left'>\n";
            $tracklist = json_decode(get_album_tracks($sourceid));
            write_tracklist($tracklist);
            print "</div>\n";
        }
        print "</div>\n";
    }
}
build_footer("browse");