<cfoutput>

	<cfif form.submode eq "edit">

		<script language="JavaScript">
			function submitformview()
			{
			document.myformview.submit();
			}
		</script>

		<form action="#request.cgiPath#" method="post" name="myformview" id="myformview" style="display:inline;">
			
			<a href="javascript: submitformview()">View Menu</a>
			
			<input type="hidden" name="mode" value="viewmenu">
			<input type="hidden" name="submode" value="view">

		</form><br>

	<cfelse>
		
		<script language="JavaScript">
			function submitformedit()
			{
			document.myformedit.submit();
			}
		</script>

		<form action="#request.cgiPath#" method="post" name="myformedit" id="myformedit" style="display:inline;">
			
			<a href="javascript: submitformedit()">Edit Menu</a>
			
			<input type="hidden" name="mode" value="editmenu">
			<input type="hidden" name="submode" value="edit">

		</form><br>

	</cfif>

</cfoutput>

<cfif form.submode eq "view">

	<h3>Current menu</h3>
	
	<cfquery name="get_items" datasource="#application.datasource#">
		SELECT	    Name, Price, ItemID
	    FROM	    Items
		WHERE		ParentItemID = 0
	</cfquery>
	
	<cfloop query="get_items">
		
		<cfoutput>#get_items.Name# - #dollarformat(get_items.Price)#<br></cfoutput>
		
		<cfmodule template="#application.wwwrootprefix#modules/get_children_of_item_id.cfm" sending_ItemID=#get_items.ID# looper=0>
	
	</cfloop>

<cfelseif form.mode eq "edit">

	<h3>Edit menu</h3>
	
	<cfquery name="get_items" datasource="#application.datasource#">
		SELECT	    Name, Price, ItemID
	    FROM	    Items
		WHERE		ParentItemID = 0
	</cfquery>
	
	<cfoutput query="get_items">
		
		#get_items.Name# - #dollarformat(get_items.Price)#
		
		<script language="JavaScript">
			function submitformedit#get_items.ID#()
			{
			document.myformedit#get_items.ID#.submit();
			}
		</script>
		
		<form action="index.cfm" method="post" name="myformedit#get_items.ID#" id="myformedit#get_items.ID#" style="display:inline;">
			
			<a href="javascript: submitformedit#get_items.ID#()">Edit</a>
			
			<input type="hidden" name="item_form_submitted" value="0">
			<input type="hidden" name="mode" value="items">
			<input type="hidden" name="submode" value="edit">
			<input type="hidden" name="chip" value="#get_items.ID#">
		
		</form>
		
		<script language="JavaScript">
			function submitformdelitem#get_items.ID#()
			{
			document.myformdelitem#get_items.ID#.submit();
			}
		</script>
		
		<form action="#request.cgiPath#" method="post" name="myformdelitem#get_items.ID#" id="myformdelitem#get_items.ID#" style="display:inline;">
			
			<a href="javascript: submitformdelitem#get_items.ID#()">delete</a><br>
			
			<input type="hidden" name="mode" value="viewmenu">
			<input type="hidden" name="submode" value="delitem">
			<input type="hidden" name="chip" value="#get_items.ID#">
		
		</form>
	
		<script language="JavaScript">
			function submitforminsertchild#get_items.ID#()
			{
			document.myforminsertchild#get_items.ID#.submit();
			}
		</script>
		
		<form action="#request.cgiPath#" method="post" name="myforminsertchild#get_items.ID#" id="myforminsertchild#get_items.ID#" style="display:inline;">
			
			Name:<input name="Name" size="6">Price:<input name="Price" value="0" size="3"><a href="javascript: submitforminsertchild#get_items.ID#()">add here</a>
			
			<input type="hidden" name="mode" value="insert">
			<input type="hidden" name="chip" value="#get_items.ID#">
		
		</form><br>
		
		<cfmodule template="#application.wwwrootprefix#modules/get_children_of_item_id_with_add.cfm" sending_ItemID=#ItemID# looper=0>

		<hr width="100%" align="left">
	
	</cfoutput>
	
	<cfoutput>

		<script language="JavaScript">
			function submitforminsertroot()
			{
			document.myforminsertroot.submit();
			}
		</script>
		
		<form action="#request.cgiPath#" method="post" name="myforminsertroot" id="myforminsertroot" style="display:inline;">
			
			Name:<input name="Name" size="6">Price:<input name="Price" value="0" size="3"><a href="javascript: submitforminsertroot()">Add Main Item</a>
			
			<input type="hidden" name="mode" value="viewmenu">
			<input type="hidden" name="submode" value="insert">
			<input type="hidden" name="chip" value="0">
		
		</form>
	
	</cfoutput><br>

<cfelseif form.submode eq "insert">
	
	<cfquery name="insert_item" datasource="#application.datasource#">
		INSERT INTO		    Items
								(
									Name,
									Price,
									ParentItemID,
									AddedOn
								)
	    VALUES
								(
									'#form.Name#',
									'#form.Price#',
									'#form.chip#',
									 #createODBCDateTime(now())#
								)	    
	</cfquery>
	
	<cfoutput>
	
		<form action="#request.cgiPath#" method="post" name="go_page" id="go_page">
			<input type="hidden" name="mode" value="update">
		</form>
		
		<script type="text/JavaScript" language="JavaScript">  
			document.go_page.submit();  
		</script>
	
	</cfoutput>

<cfelseif mode eq "delitem">
	
	<cfquery name="delete all" datasource="#application.datasource#">
		DELETE FROM		    Items
		WHERE				ID=#chip#
	</cfquery>
	
	<cfoutput>
	
		<form action="#request.cgiPath#" method="post" name="go_page" id="go_page">
			<input type="hidden" name="mode" value="viewmenu">
			<input type="hidden" name="submode" value="view">
		</form>
		
		<script type="text/JavaScript" language="JavaScript">  
			document.go_page.submit();  
		</script>
	
	</cfoutput>

<cfelse>

	no mode!<br>

</cfif>