
function mycarousel_itemLoadCallback(carousel, state)
{
// Since we get all URLs in one file, we simply add all items
// at once and set the size accordingly.
if (state != 'init')
return;
carousel_itemAddCallback(carousel,carousel.first, carousel.last);
/*
jQuery.get('dynamic_ajax.txt', function(data) {
mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
});
*/
};
function carousel_itemAddCallback(carousel,first, last)
{ 
var numOfDays = 21;
var offset = -7;
var dayCount = 0;
//alert("scheduleDate" + $("#scheduleDate").attr("numericaldate"));
for (var i=0; i < numOfDays; i++)
{
var menuItem = new ScheduleTab();
menuItem.date.setDate(new Date().getDate() + i + offset);
menuItem.setTabId(i + 1);
// Pull main schedule html
var html = menuItem.getHtml();
carousel.add(i+1, html);	
//$("#menu").append(html);
dayCount++;
}
carousel.size(dayCount);
}	
function updateSchedule() {
}
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
scroll:7,
start:8,
itemLoadCallback: mycarousel_itemLoadCallback
});
var storedDate = $("#scheduleDate").attr("numericaldate");
if ( storedDate != "empty") {
var selectedTab = $(".scheduleTab[numericdate='" + storedDate + "']");
//select the new tag
$(selectedTab).addClass("id");
$(selectedTab).attr("id", "selected");
$(selectedTab).attr("class","scheduleTabSelected");
} 
$(".scheduleTab").click(function () {
//deselect the old selected tab
$("#selected").removeAttr("id");
$(".scheduleTabSelected").attr("class","scheduleTab" );
//select the new tag
$(this).addClass("id");
$(this).attr("id", "selected");
$(this).attr("class","scheduleTabSelected");
//set tabid
var tabId = $(this).attr("tabid");
$("#scheduleBdy2").attr("tabid",tabId);
//alert("date to be passed " + $(this).attr("numericdate"));
//load the schedule with the selected date
loadScheduleTab($(this).attr("numericdate"));
});
});
