<?
require_once('control/include/user.php');
require_once('control/include/mysql.php');
require_once('control/include/functions.php');
require_once('control/include/fb.php');

ob_start();
session_start();

// SETUP MYSQL HANDLERS
$mysqldb1 = new mysql($host, $user, $pswd, $db);
$mysqldb1->connect();
$mysqldb1->select();
$mysqldb2 = new mysql($host, $user, $pswd, $db);
$mysqldb2->connect();
$mysqldb2->select();
?>
<?
$query = "
		SELECT
			t1.*
		FROM
			slideshow AS t1
		WHERE
			(SELECT status FROM slideshow_page_link WHERE page_id=(SELECT id FROM page WHERE name='".$_SESSION['page']."') AND slideshow_id=t1.id)=1 AND
			t1.status='enabled'
		ORDER BY
			t1.sequence ASC, 
            t1.name ASC";
//fb($query);
$mysqldb1->query($query);
while ($slideshow = $mysqldb1->fetchArray()) {

    $query = "
	SELECT 
		t1.* 
	FROM 
		file AS t1
	WHERE 
		t1.status='enabled' AND 
		t1.record_id=".$slideshow['id']." AND
        (SELECT status FROM slideshow_page_link WHERE page_id=(SELECT id FROM page WHERE name='".$_SESSION['page']."') AND slideshow_id=".$slideshow['id'].")=1 AND
		t1.source='slideshow' AND
		t1.type='image' 
	ORDER BY 
		t1.sequence ASC";
    //fb($query);
    $mysqldb2->query($query);
    while ($image = $mysqldb2->fetchArray()) {
        ?>
<img src="/<? print $fileDIR.$image['name']; ?>" width="<? print $_GET['width']; ?>" height="<? print $_GET['height']; ?>" />
        <?
    }
}
?>
<?
$mysqldb1->close();
$mysqldb2->close();
?>