<%@ Page Title="" Language="C#" MasterPageFile="~/Wijmo.Master" AutoEventWireup="true" CodeBehind="CustomEditEvent.aspx.cs" Inherits="ControlExplorer.C1EventsCalendar.CustomEditEvent" %>

<%@ Register Assembly="C1.Web.Wijmo.Controls.4" Namespace="C1.Web.Wijmo.Controls.C1EventsCalendar"
	TagPrefix="wijmo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<script type="text/javascript">
		var eventData;
		function saveEvent() {
			var evcal = $("#<%= C1EventCalendar1.ClientID %>");
			eventData.subject = $("#<%=TextBox1.ClientID%>").val();

			if (!eventData.prevData) {
				// add new event
				evcal.c1eventscalendar("addEvent", eventData,
					function () { /*alert("Event added.") */ },
					function (err) { alert("(Add event) Error:" + err) });
			} else {
				evcal.c1eventscalendar("updateEvent", eventData,
				function () { /*alert("Event updated.") */ },
					function (err) { alert("(Update event) Error:" + err) });
			}
			$("#<%=Panel1.ClientID%>").parent().hide();
		}

		function cancel() {
			$("#<%=Panel1.ClientID%>").parent().hide();
		}

		function deleteEvent() {
			var evcal = $("#<%= C1EventCalendar1.ClientID %>");
			eventData.subject = $("#<%=TextBox1.ClientID%>").val();

			if (eventData.prevData) {
				evcal.c1eventscalendar("deleteEvent", eventData,
				function () { /*alert("Event deleted.") */ },
					function (err) { alert("(Delete event) Error:" + err) });
			}
			$("#<%=Panel1.ClientID%>").parent().hide();
		}

		function beforeShowDialog(e, args) {
			eventData = args.data;
			$("#<%=Label1.ClientID%>").text(eventData.prevData ? "<%= Resources.C1EventsCalendar.CustomEditEvent_EditCaption %>" : "<%= Resources.C1EventsCalendar.CustomEditEvent_AddCaption %>");
			$("#<%=TextBox1.ClientID%>").val(eventData.subject);
			if (eventData.prevData) {
				$("#delButton").show();
			} else {
				$("#delButton").hide();
			}
			return true;
		}

	</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<wijmo:C1EventsCalendar runat="server" ID="C1EventCalendar1" OnClientBeforeEditEventDialogShow="beforeShowDialog" Width="100%">
		<EventDialogTemplate>
			<asp:Panel ID="Panel1" runat="server" CssClass="ui-widget-content ui-corner-all" HorizontalAlign="Center" Height="150" Width ="300" BorderColor="Black" BorderWidth="1">
				<br /><br />
				<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
				<br /><br />
				<asp:Label ID="Label2" runat="server" Text="<%$ Resources:C1EventsCalendar, CustomEditEvent_SubjectLabel %>"></asp:Label><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
				<br /><br />
				<input id="saveButton" type="button" onclick = "saveEvent();" value="<%= Resources.C1EventsCalendar.CustomEditEvent_SaveText %>" /><input id="cancelButton" type="button" onclick="	cancel();" value="<%= Resources.C1EventsCalendar.CustomEditEvent_CancelText %>" /><input id="delButton" type="button" onclick="deleteEvent();" value="<%= Resources.C1EventsCalendar.CustomEditEvent_DeleteText %>" />
			</asp:Panel>
		</EventDialogTemplate>
	</wijmo:C1EventsCalendar>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ControlOptions" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Description" runat="server">
	<p><%= Resources.C1EventsCalendar.CustomEditEvent_Text0 %></p>
</asp:Content>
