<%@ include file="/includes.jsp" %>
<html:html >
	<head>
		<title>Edit Event</title>
		<link rel="stylesheet" href="../webapp.css" type="text/css" />
		<webapp:forEach id="module" items="${webapp.modules}">
			<logic:notEmpty name="module" property="moduleInfo.styleSheet">
				<link rel="stylesheet" href="${module.moduleInfo.styleSheet}" type="text/css" />
			</logic:notEmpty>
			<logic:notEmpty name="module" property="moduleInfo.javaScript">
				<script src="${module.moduleInfo.javaScript}" type="text/javascript"></script>
			</logic:notEmpty>
		</webapp:forEach>
		<script src="../webapp.js" type="text/javascript"></script>
		<%-- JS CALENDAR --%>
		<style type="text/css">@import url(../jscalendar/skins/aqua/theme.css);</style>
		<script type="text/javascript" src="../jscalendar/calendar.js"></script>
		<script type="text/javascript" src="../jscalendar/lang/calendar-en.js"></script>
		<script type="text/javascript" src="../jscalendar/calendar-setup.js"></script>
		<%-- END JS CALENDAR --%>
		<%-- JS tools --%>
		<script type="text/javascript" src="../anchorPosition.js"></script>
		<script type="text/javascript" src="../popupWindow.js"></script>
		<script type="text/javascript" src="../colorPicker2.js"></script>
	</head>
	<body style="margin: 0 0 0 0">
		<table cellpadding="0" cellspacing="0" height="100%" width="100%">
			<!-- CONTENT -->
			<tr>
				<td valign="top" class="moduleContentArea" align="center">
					<tiles:insertTemplate template="tiles/editEventLayout.jsp"/>
				</td>
			</tr>
			<!-- END CONTENT -->
			<!-- ERRORS -->
			<logic:messagesPresent>
				<tr>
					<td align="center" class="error">
						<html:messages id="error">
							<bean:write name="error"/><br/>
						</html:messages>
					</td>
				</tr>
			</logic:messagesPresent>
			<!--END ERRORS -->
			<tr height="1">
				<td align="center" class="pageFooter" colspan="2">
					Logged in as '<bean:write name="webapp" property="currentUser.username"/>' | Copyright &#169; <a href="http://www.ardeo.com/" target="_blank">Ardeo</a> 2000-2006 | Version: <bean:write name="webapp" property="version"/>
				</td>
			</tr>
		</table>
	</body>	
</html:html>
<script type="text/javascript">
	//<!--

	//if(unsavedData) 
	unsavedHint();
	
	//The following checks for date input boxes and binds then to the javascript popup calendar
	var buttonFields = document.getElementsByTagName("img");
	for(var i = 0; i < buttonFields.length; i++) {
		var triggerId = buttonFields[i].id;
		var triggerIndex = triggerId.indexOf("_DateTrigger");
		if(triggerIndex != -1) {
			var inputId = triggerId.substring(0, triggerIndex);
			Calendar.setup({
				inputField : inputId ,         // ID of the input field
				ifFormat    : "%d/%m/%Y",    // the date format
				button      : triggerId,       // ID of the button
				singleClick : true,
				onUpdate : dateChanged,
				firstDay : 1,
				electric : false
			});
		}
	}
	
	function dateChanged(calendar) { 
		//if(dateChangeHandler) {
			//dateChangeHandler(calendar);
		//}
	}

	
	
	function unsavedHint() {
		var saveButton = document.getElementById('saveDataButton');
		if(saveButton) {
			saveButton.style.backgroundColor = 'red';
			saveButton.style.color = 'white';
			if(!(document.title.lastIndexOf('*') == document.title.length - 1)) {
				document.title += " *";
			}
		}
	}
	
	function dataEntered(e) {
		var saveButton = document.getElementById('saveDataButton');
		if(saveButton) {
			if(unsavedData) return;
			if(!e) {
				e = event;
			}
	
			var o = e.target || e.srcElement;
			var tagName =  o.tagName;
			if(tagName && ( tagName == "INPUT" || tagName == "TEXTAREA" || tagName ==  "SELECT" || tagName ==  "OPTION")) {
				unsavedData = true;
				unsavedHint();
			}
		}
	}

	function dataGuard() {
		var saveButton = document.getElementById('saveDataButton');
		if(saveButton && unsavedData) {
			return window.confirm("You have unsaved data. Are you sure?");
		}
		return true;
	}
	
	document.body.onclick = dataEntered;
	//-->
</script>