public function getNextOccurance()
 {
     $ahebdate = explode("/", strGregToHeb($this->data['originalDate'], false, $this->data['night']));
     return dateThisYear($ahebdate);
 }
echo $id;
?>
" size="normal" linked="true" style="float:left" />
      <div class="theInfo">
      	<fb:if-can-see uid="<?php 
echo $id;
?>
" what="profile">
          <h4>Birthday Info:</h4>
          <div class="row">
          	<label>Jewish Birthday:</label>
            <span class="value"><?php 
echo strGregToHeb($birthday, true);
?>
 - <?php 
echo strGregToHeb($birthday, false);
?>
</span>
          </div>
          <div class="row">
          	<label>Next Occurance:</label>
            <span class="value"><?php 
echo dateThisYear($ahebdate);
?>
</span>
          </div>
          <h4>Actions:</h4>
          <div class="row">
            <b><a href="http://www.facebook.com/inbox/?compose&id=<?php 
echo $id;
?>
require_once 'appinclude.php';
require_once 'jDateFunctions.php';
$allUsers = true;
$activeDate = isset($_REQUEST['date']) ? strtotime($_REQUEST['date']) : strtotime("now");
$title = "Its your friend's Jewish Birthday";
$message = "Today (%1\$s) is %2\$s's Jewish Birthday. \n" . "You can buy %3\$s a Jewish Gift at http://www.judaism.com/index.asp?aref=mplotkin \n" . "or send %3\$s a message on Facebook at http://apps.facebook.com/jewishdates/birthdayInfo.php?id=%4\$s\n\n" . 'If you do not wish to receive these messages. Please set your preferences at http://apps.facebook.com/jewishdates/messageSettings.php.';
$messageHTML = 'Today (%1$s) is <a href="http://apps.facebook.com/jewishdates/birthdayInfo.php?id=%4$s">%2$s</a>\'s Jewish Birthday. ' . '<br />You can buy %3$s a <a href="http://www.judaism.com/index.asp?aref=mplotkin">Jewish Gift</a> ' . ' or send %3$s <a href="http://apps.facebook.com/jewishdates/birthdayInfo.php?id=%4$s">a message on Facebook</a>.<br /><br />' . '	<hr />  ' . 'Support Chabad Of New Paltz & the Jewish Facebook applications and win 10 Thousand $$$.<br>' . '<a href=http://www.JewPaltz.com/raffle>Buy a raffle ticket or ten NOW</a>.';
$one_line_story = array('{*actor*} has {*ammount*} friends whose <a href="http://apps.facebook.com/jewishdates/">Jewish Birthdays</a> are today({*today*}).', '{*actor*} has friends whose <a href="http://apps.facebook.com/jewishdates/">Jewish Birthdays</a> are today({*today*}).');
$short_story = array(array('template_title' => '{*actor*} has {*ammount*} friends whose <a href="http://apps.facebook.com/jewishdates/">Jewish Birthdays</a> are today({*today*}).', 'template_body' => 'You can add your <a href="http://apps.facebook.com/jewishdates/">Jewish Birthday</a>, the current Hebrew Date and other <a href="http://apps.facebook.com/jewishdates/">Jewish Dates</a> to your profile and get notified about your friends\' Jewish Bithdays with the <a href="http://apps.facebook.com/jewishdates/">Jewish Date Application</a>.'), array('template_title' => '{*actor*} has friends whose Jewish Birthdays are today({*today*}).', 'template_body' => 'You can add your <a href="http://apps.facebook.com/jewishdates/">Jewish Birthday</a>, the current Hebrew Date and other <a href="http://apps.facebook.com/jewishdates/">Jewish Dates</a> to your profile and get notified about your friends\' Jewish Bithdays with the <a href="http://apps.facebook.com/jewishdates/">Jewish Date Application</a>.'));
$full_story = $short_story;
$templateBundleId = $facebook->api_client->feed_registerTemplateBundle($one_line_story, $short_story, $full_story);
$picture = 'http://www2.newpaltz.edu/~plotkinm/php/facebook/jewishdates/Icon75x75.gif';
$pLink = 'http://apps.facebook.com/jewishdates/supportChabadOfNewPaltz.php';
//generate coresponding dates
$cDates = array();
$aTodayHebrew = explode("/", strGregToHeb(date("M d, Y", $activeDate)));
for ($i = 10; $i < 70; $i++) {
    $cdate = date("F d, Y", strtotime(jdtogregorian(jewishtojd($aTodayHebrew[0], $aTodayHebrew[1], $aTodayHebrew[2] - $i))));
    $cDates[$i] = $cdate;
}
$cDatesStr = join("','", $cDates);
$activeDateStr = date("l M d, Y", $activeDate);
$iLimit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 0;
$iStopLimit = isset($_REQUEST['toLimit']) ? $_REQUEST['toLimit'] : 300;
$sql = "SELECT * FROM fbUsers WHERE sessionId is not null AND `current`=1 AND appId='{$appapikey}' " . ($allUsers ? "" : "AND id='{$user}'") . " Limit {$iLimit}, {$iStopLimit}";
trace($sql . '<br />Time Started: ');
$conn = dbConnect();
$results = mysql_query($sql, $conn);
$i = 0;
$actualPosts = 0;
?>
function updateJDateProfile($updateDB = true)
{
    global $facebook;
    global $bBornAfterSunset, $profileDesign, $displayCurrent, $displayLink, $birthday, $success;
    dbConnect();
    if (isset($_POST["Submit"]) && $_POST["Submit"] == "Submit" && $updateDB) {
        $strBornAfterSunset = "";
        if (isset($_POST["chkSunset"]) && $_POST["chkSunset"] == "on") {
            $strBornAfterSunset = "true";
        } else {
            $strBornAfterSunset = "false";
        }
        $profileDesign = isset($_POST["profileDesign"]) ? $_POST["profileDesign"] : 1;
        $displayCurrent = isset($_REQUEST["chkToday"]);
        $displayLink = isset($_REQUEST["chkExplanation"]);
        $sql = "UPDATE fbJewishDates SET BornAtNight={$strBornAfterSunset}, style={$profileDesign}, displayLink='{$displayLink}', displayCurrent='{$displayCurrent}' WHERE uid={$facebook->user}";
        mysql_query($sql) or die("You must un-install and re-install this app");
        $success = true;
    }
    $sql = "SELECT BornAtNight, Birthday, style, displayCurrent, displayLink FROM fbJewishDates WHERE uid='{$facebook->user}'";
    $results = mysql_query($sql);
    if (!($rs = mysql_fetch_assoc($results))) {
        addBirthdayRecord();
        $results = mysql_query($sql);
        $rs = mysql_fetch_assoc($results);
    }
    mysql_close();
    $bBornAfterSunset = $rs['BornAtNight'];
    $profileDesign = $rs['style'];
    $displayCurrent = $rs['displayCurrent'];
    $displayLink = $rs['displayLink'];
    $birthday = date("M d, Y", strtotime($rs['Birthday']));
    //$userInfo = $facebook->api_client->fql_query("SELECT birthday FROM user WHERE uid=$user");
    //$birthday = $userInfo[0]['birthday'];
    $fbml = printJewishBirthday($birthday, $bBornAfterSunset, $profileDesign, $displayCurrent, $displayLink);
    $mobileFBML = $fbml;
    $mainFBML = $fbml;
    $ahebdate = explode("/", strGregToHeb($birthday, false, $bornAtNight));
    $info_fields = array(array('field' => 'My Hebrew Birthday', 'items' => array(array('label' => strGregToHeb($birthday, true, $bBornAfterSunset), 'description' => 'A kabbalisticly powerful day.', 'link' => 'http://apps.facebook.com/jewishdates/'))), array('field' => 'Next Occurence', 'items' => array(array('label' => dateThisYear($ahebdate), 'description' => 'The next gregorian date that will corespond with my Hebrew Birthday', 'link' => 'http://apps.facebook.com/jewishdates/'))));
    $moreFBML = '<b><u>Special Dates</u></b><br />';
    $specialDays = DateRecord::findByWhere('DateRecord', "uid={$facebook->user}");
    foreach ($specialDays as $friend) {
        $moreFBML .= '<div><b>' . $friend->data['title'] . ':</b>' . $friend->getHebrewDate('longeng') . ' - ' . $friend->getNextOccurance() . '</div>';
        $info_fields[] = array('field' => $friend->data['title'], 'items' => array(array('label' => $friend->getHebrewDate('longeng'), 'description' => 'Hebrew Date', 'link' => 'http://apps.facebook.com/jewishdates/'), array('label' => 'Next Occurance: ' . $friend->getNextOccurance(), 'description' => 'Gregorian Date this coming year', 'link' => 'http://apps.facebook.com/jewishdates/')));
    }
    $facebook->api_client->profile_setFBML($fbml . $moreFBML, $facebook->profileID, $fbml . $moreFBML, NULL, $mobileFBML, $mainFBML);
    $facebook->api_client->profile_setInfo('Jewish Dates', 1, $info_fields, $user);
    $refValue = "Todays Hebrew Date is:<br />" . strGregToHeb(date("M d, Y"), true);
    $facebook->api_client->fbml_setRefHandle("Today_H", $refValue);
    $facebook->api_client->fbml_setRefHandle("Message", "<fb:subtitle><a href='http://apps.facebook.com/jewishdates/'>Add this to my profile.</a></fb:subtitle>");
    //<div style='text-align:center;color:red;'>Help 'Jewish Dates'.<br />Support <a href='http://apps.facebook.com/jewishdates/supportChabadOfNewPaltz'>Chabad of New Paltz</a><hr /></div>
    $facebook->api_client->fbml_setRefHandle("Explanation", "<a href='http://www.chabad.org/library/article.asp?AID=144345'>What is a Jewish Birthday?</a>");
}