/**
 * Creates Sample data for calendar.
 var group = {
		 name: <Calendar / Group Name>
		 groupId: <unique calendar / Group ID>
		 events{ [
			 <Event Object 1>,
			 <Event Object 2>,
			 <Event Object 3>,
			 <Event Object 4>,
			 <Event Object 5>,
			 ...
		 ]
 }
 var event = {
	 name: <String>,
	 eventId: <String /Number>,
	 location: <String>,
	 instructor: <String>,
	 startTime: <Date>,
	 endTime: <Date>,
	 description: <String>,
	 allDay: <boolean>
 }
 */
function getCalendarData()
{
    var d = [];
    var events = [];
 
    events.push(createEvent("Sales Meeting111"				, 1		, "Conf 201 ( 35th Floor )", "John Smith, Sue, James, Dan, Lisa", createDateTime(2,20,0), createDateTime(10, 30, 0), "Discuss Monthly Sales Target", false  , getRepeatObject("month","","","", "", "", "", "","" ) ));
	events.push(createEvent("Sales Meeting"					, 2		, "Conf 201 ( 35th Floor )", "John Smith, Sue, James, Dan, Lisa", createDateTime(2,10, 0), createDateTime(10, 30, 0), "Discuss Monthly Sales Target", false));
    events.push(createEvent("Sales Meeting222"				, 3		, "Conf 201 ( 35th Floor )", "John Smith, Sue, James, Dan, Lisa", createDateTime(2,15, 0), createDateTime(16, 30, 0), "Discuss Monthly Sales Target", false));
   	events.push(createEvent("Coliding Sales Meeting1"		, 4	, "Conf 201 ( 35th Floor )", "John Smith, Sue, James, Dan, Lisa", createDateTime(4,0, 0), createDateTime(6, 30, 0), "Discuss Monthly Sales Target", false));
	events.push(createEvent("Coliding Sales Meeting2"		, 5	, "Conf 201 ( 35th Floor )", "John Smith, Sue, James, Dan, Lisa", createDateTime(3,0, 0), createDateTime(4, 30, 0), "Discuss Monthly Sales Target", false));
 
	events.push(createEvent("Discuss Application Design"	, 6	, "Conf 805, 300 Pine St, 8th Fl", "App Design Team, John, Joe, Jane, Lisa", createDateTime(23, 0, -13), createDateTime(23, 30, -8), "Discuss design and refractor of Application interface", true));
    events.push(createEvent("Sample Event "					, 7		, "Test Location", "John Smith", createDateTime(23, 0, -4), createDateTime(23, 30, 0), "Yoga is good for health", true));
	events.push(createEvent("Sales Meeting333"				, 8		, "Conf 201 ( 35th Floor )", "John Smith, Sue, James, Dan, Lisa", createDateTime(11,0, 2), createDateTime(18, 30, 2), "Discuss Monthly Sales Target", false));
    events.push(createEvent("Event can span for many days"	, 9		, "My Desk", "John Smith", createDateTime(23, 0, -6), createDateTime(23, 30, 1), "Yoga is good for health", true));
    events.push(createEvent("Any number of attributes"		, 10		, "yoga aud", "John Smith", createDateTime(23, 0, -18), createDateTime(23, 30, -18), "Yoga is good for health", true));
 
    events.push(createEvent("Web2Cal use in all business"	, 11		, "yoga aud", "John Smith", createDateTime(0, 30, -2), createDateTime(3, 30, -2), "Yoga is good for health", false));
 	events.push(createEvent("Test Event 200"				, 12	, "yoga aud", "John Smith", createDateTime(5, 0, 1), createDateTime(8, 30, 1), "Yoga is good for health", false));
    events.push(createEvent("Another Event 300"				, 13		, "yoga aud", "John Smith", createDateTime(9, 0, 2), createDateTime(12, 30, 2), "Yoga is good for health", false));
  
	events.push({
		eventName: "Christmas",
		eventId: "100",
		startTime: new Date(2010, 11, 25),
		endTime:new Date(2010, 11, 25),
		allDay: true,
		movable: false,
		resizable: false,
		showPreview:false,   //Disable click event on a event.		
		repeatEvent: {
			mode: "year",
			year: {
				date: "12/25/2010"
			}
		}
	} );
     var group = {
        name: "Category 1",
        groupId: "1",
		show:true,
        events: events, 
		color:Web2Cal.colors[13]
    };
  d.push(group);
   
    var events = [];
    
	events.push(createEvent("Morning Yoga"										, 20, "Yoga Auditorium", "Instructor1", createDateTime(15, 0, 1), createDateTime(19, 30, 1), "Morning Yoga is good for health"));
    events.push(createEvent("Event <b>HTML</b> 2"								, 21, "Event Location 2", "Instructor2", createDateTime(8, 0, -1), createDateTime(10, 30, -1), "Event Description ..."));
    events.push(createEvent("<span style='color:red'>Red Colored Event</span>"	, 22, "Event Location 3", "Instructor3", createDateTime(11, 0, 0), createDateTime(4, 45, 1), "Event Description ..."));
    events.push(createEvent("Customizable with Templates...."					, 23, "Event Location 4", "Instructor4", createDateTime(6, 0), createDateTime(10, 0), "Event Description ..."));
    events.push(createEvent("Event 5"											, 24, "Event Location 5", "Instructor5", createDateTime(7, 0), createDateTime(10, 0), "Event Description ..."));
 
    events.push(createEvent("Event 6"											, 25, "Event Location 6", "Instructor6", createDateTime(16, 0, -2), createDateTime(20, 0, -2), "Event Description ..."));
    events.push(createEvent("<b><i><span style='color:orange'>HTML Supported!!!</span></i></b>", 16, "Event Location 7", "Instructor7", createDateTime(10, 0, -3), createDateTime(15, 0, -3), "Event Description ..."));
    events.push(createEvent("Event 8"											, 26, "Event Location 8", "Instructor8", createDateTime(9, 0, -5), createDateTime(11, 15, -5), "Event Description ..."));
    events.push(createEvent("Event 9"											, 27, "Event Location 9", "Instructor9", createDateTime(9, 0, 1), createDateTime(11, 15, 1), "Event Description ..."));
  
    var group = {
        name: "Category 2",
        groupId: "2",
        events: events,
		color:Web2Cal.colors[9]
    }; 
    d.push(group);
	
	
	var events = [];
	events.push(createEvent( "event1", 41, "","", createDateTime(12, 30, 1), createDateTime(14, 15, 3), "description", false));
	events.push(createEvent( "event2", 42, "","", createDateTime(11, 0, 1), createDateTime(14, 0, 2), "description", false));
	events.push(createEvent( "event3", 43, "","", createDateTime(13, 0, 1), createDateTime(15, 30, 3), "description", false));
	events.push(createEvent( "event4", 44, "","", createDateTime(14, 0, 1), createDateTime(16, 30, 1), "description", false));
	
    var group = {
        name: "Category 3",
        groupId: "3",
        events: events,
		color:Web2Cal.colors[5]
    }; 
   d.push(group);
	
    return d;
    
}

function getRepeatObject(repeatMode, selectedWeekDays, repeatEndDate, repeatCount, repeatOnDate, repeatOnDay, mRepeatNumber, mRepeatDay, mRepeatDate, yearRepeatDate)
{
    var repeatObject = {
        mode: repeatMode,
        day: { 
            onlyWeekDays: false
        },
        week: {
            days:  selectedWeekDays 
        },
        month: {
            repeatOnDate: repeatOnDate,
            repeatOnDay: repeatOnDay,
            dayRepeatNumber: mRepeatNumber,
            repeatDay: mRepeatDay,
            repeatDate: mRepeatDate 
        }, 
		year: {
			date:yearRepeatDate
		},
        endDate: repeatEndDate
		, repeatCount: 1
    }
    return repeatObject;
}

function createDateTime(ti, h, numofDays)
{
    var dd = new Date();
    dd.setHours(ti);
    dd.setMinutes(h);
    
    var x = new UTC(dd.getTime());
    
    if (numofDays) 
    {
        x = new UTC(dd.addDays(numofDays));
    } 
    return x;
}

function createEvent(name, id, location, instructor, timestart, timeend, desc, allDay, repeatObject)
{

    if (allDay == undefined) 
        allDay = false;
    
    return {
        name: name,
        eventId: id,
        location: location,
        instructor: instructor,
        startTime: timestart.getDateObj(),
        endTime: timeend.getDateObj(),
        description: desc,
        allDay: allDay,
        repeatEvent: repeatObject,
		className: "xxxclassname"
    };
}


/**
 The idea is, group contains events. (which is similar to all other views of web2cal)
 In order to group the events to a person, specify personId value for the events.
 If you want to only display a person who has no events,
 you can provide null for start time and end time.
 Create workshift Event Object.
 Event = {
 name: <String>,
 eventId: <String /Number>,
 location: <String>,
 instructor: <String>,
 startTime: <Date>,
 endTime: <Date>,
 description: <String>,
 allDay: <boolean>,
 personId: <String /Number>,  -- Person ID for whom the event belongs
 personName: <String>, 	     -- Person Name for whom the event belongs
 eventType: <String> 	     -- Indicate if this is workshift or a workday event. WORKDAY | WORKSHIFT
 WORKDAY EVENTS are displayed along the group  ( see below )
 Workshift View Structure:
 GROUP1			<WORKDAY EVENT>
 PERSON 1	<WORKSHIFT EVENT> <WORKSHIFT EVENT> <WORKSHIFT EVENT>
 PERSON 2 	<WORKSHIFT EVENT> <WORKSHIFT EVENT> <WORKSHIFT EVENT>
 
 GROUP2			<WORKDAY EVENT>
 PERSON 1	<WORKSHIFT EVENT> <WORKSHIFT EVENT> <WORKSHIFT EVENT>
 PERSON 2 	<WORKSHIFT EVENT> <WORKSHIFT EVENT> <WORKSHIFT EVENT>
 
 }
 */
function createWorkShiftEvent(name, eventId, timestart, timeend, desc, personId, personName, eventType, repeatObject)
{
    return {
        name: name,
        eventId: eventId,
        personId: personId,
        personName: personName,
        startTime: (timestart != null) ? timestart.getDateObj() : null,
        endTime: (timeend != null) ? timeend.getDateObj() : null,
        description: desc,
        allDay: false,
        wsEventType: eventType,
		repeatEvent: repeatObject
    };
}

function getWorkshiftData()
{
    var d = new Array();
    var events = new Array();
    
    events.push(createWorkShiftEvent("Manager Workday", 1, createDateTime(6, 0, 0), createDateTime(11, 30, 0), "Manager Workday", null, null, 'workday'
	, getRepeatObject("day","","","", "", "", "", "","" ) ));
     events.push(createWorkShiftEvent("<< Joe is working >>", 200, createDateTime(8, 0, 0), createDateTime(12, 30, 1), "<< Joe is working >>", 10, "Joe", null, getRepeatObject("day","","","", "", "", "", "","" )));
    events.push(createWorkShiftEvent("<< More Events for Joe (Not repeating) >>", 201, createDateTime(16, 0, 0), createDateTime(20, 30, 0), "<< Joe is working 2 >>", 10, "Joe"));
    
    events.push(createWorkShiftEvent("", 0, null, null, "", 20, "Bill")); // Just the person name will show up coz he has no events yet. 
    var group = {
        name: "Managers",
        groupId: "100",
        events: events
    };
    
    d.push(group);
    
    var events = new Array();
    events.push(createWorkShiftEvent("Personal Trainer's Workday", 2, createDateTime(6, 0, 0), createDateTime(11, 30, 0), "Personal Trainer's Workday", null, null, 'workday'));
    events.push(createWorkShiftEvent("[[Bill is Working]]", 6, createDateTime(18, 0, 0), createDateTime(23, 30, 0), "[[Bill is Working]]", 20, "Bill"));
    
    events.push(createWorkShiftEvent("", 0, null, null, "", 40, "Tom"));// No events for Tom yet. So just display the person. Provide start time and end time as null	
    var group = {
        name: "Personal Trainers",
        groupId: "103",
        events: events
    };
    
    d.push(group);
    
    return d;
}

