<?php

error_reporting(0);
//header("Content-Type: application/xhtml+xml; charset=utf-8;");
require_once 'appinclude.php';
require_once 'jDateFunctions.php';
include_once 'inc/header.php';
$bBornAfterSunset = NULL;
$profileDesign = NULL;
$displayCurrent = NULL;
$displayLink = NULL;
$birthday = NULL;
$success = false;
updateJDateProfile();
?>
	<?php 
switch ($_REQUEST['msg']) {
    case 'randompage':
        ?>
            <fb:success>
                <fb:message>You have arived at a random page in the 'Jewish Dates' application.</fb:message>
                If you are trying to upgrade your profile with 'Jewish Dates' you have been succesful.
                You can now go on your merry way. <br />
                If you have come here to change your settings, prefrences or registered birthday or would like to find the Hewbrew birthdays of your friends
                please visit the <a href="./">Application home page</a>.
            </fb:success>
        <?php 
        break;
    case 'profile':
        ?>
            <fb:success>
            $nextAction = 'create';
        }
        break;
    case 'edit':
        $rec = DateRecord::findById('DateRecord', $_REQUEST['id']);
        $nextAction = "update";
        if (!$rec) {
            $action = 'show';
        }
        break;
    case 'update':
        $rec = DateRecord::findById('DateRecord', $_REQUEST[$_REQUEST['hashNameSpace'] . 'id']);
        $rec->update($_REQUEST);
        if ($rec->save()) {
            updateJDateProfile(false);
            $action = 'show';
        } else {
            $action = 'edit';
            $nextAction = 'update';
        }
        break;
    case 'delete':
        $rec = DateRecord::findById('DateRecord', $_REQUEST['id']);
        if ($rec && $rec->delete()) {
            updateJDateProfile(false);
            actionRedirect('index');
        }
        $action = 'show';
        break;
}
include 'views/template.php';