<script src="{$smarty.const.SITE_URL}/includes/DragDrop/prototype.js" type="text/javascript"></script>
<script src="{$smarty.const.SITE_URL}/includes/DragDrop/scriptaculous.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="{$smarty.const.SITE_URL}/includes/ajax/ajax.js"></script>
{literal}
<script language="javascript">
function subMenu(id,value)
{
        {/literal}
		document.getElementById("sub_div").innerHTML="<strong style='color:#990000'>Sub Menu adding...</strong>";
		var req1 = newXMLHttpRequest();
		req1.onreadystatechange = getReadyStateHandler(req1, serverResponse2);
		str="cms_id="+id+"&section_id="+value;
		req1.open("POST", "{makeLink mod=cms pg=link}act=addsub_menu{/makeLink}&"+Math.random());
		{literal}
		req1.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		req1.send(str);
}

function serverResponse2(_var) {

	document.getElementById('sub_div').innerHTML=_var;
}

</script>
{/literal}
<style type="text/css">
{literal}
.handle {
	cursor:move;
}
{/literal}
</style>
<table width="80%" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td>{messageBox}</td>
  </tr>
</table>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr>
      <td width="3%">&nbsp;</td>
      <td width="30%" valign="top">
        <table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" class=naBrdr> 
          <tr> 
            <td><table width="98%" align="center"> 
                <tr> 
                  <td nowrap class="naH1">Link Area</td> 
                  <td align="right"><!--<a href="{makeLink mod=$smarty.request.mod pg=link}act=addlink_area&area={$smarty.request.area}{/makeLink}">Add Link Area</a>--></td>
                </tr> 
              </table></td> 
          </tr> 
           
        </table>      
        <br /><table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" class=naBrdr> 
           
		  
          
        </table>
        <br />
<br />
		
		<br />
		
	  </td>
      <td width="3%">&nbsp;</td>
      <td width="61%" valign="top">
	     {if count($LINK_LIST) > 0}
			<form action="" method="post" style="margin:0px;" name="orderFrm">
			<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" class=naBrdr> 
			  <tr> 
				<td height="30"><table width="98%" align="center"> 
					<tr> 
					  <td nowrap class="naH1">Order {$smarty.request.area} menu - drag and drop to order </td> 
					  <td align="right" nowrap><a href="../{makeLink}{/makeLink}" target="_blank">Preview</a></td>
					</tr> 
				  </table></td> 
			  </tr> 
			  <tr>
				<td class="naGrid1" height="1"><div></div></td>
			  </tr>
			  <tr> 
				<td>
					<table border="0" width="100%" cellpadding="5" cellspacing="0">
						<tr>
							<td width="20" nowrap="nowrap" class="naGridTitle" height="24" align="center">&nbsp;</td>
							<td width="20" nowrap="nowrap" class="naGridTitle" height="24" align="center">&nbsp;</td>
							<td nowrap="nowrap" class="naGridTitle" height="24" align="left">Link Title</td>
							<td width="20" nowrap="nowrap" class="naGridTitle" align="center">#</td>
					  </tr>
				  </table>
					<div id="linkOrder">
					  {foreach from=$LINK_LIST item=row name=linklist}
					   <div id="test_{$row->id}">
						  <table border="0" width="100%" cellpadding="0" cellspacing="0">
							<tr class="naGrid1">
							  <td width="20" valign="middle" height="24" align="center"><a class="linkOneActive" href="{makeLink mod=$smarty.request.mod pg=link}area={$smarty.request.area}&cms_id={$smarty.request.cms_id}&id={$row->id}&parent_id={$smarty.request.parent_id}{/makeLink}"><img title="Edit" alt="Edit" src="{$GLOBAL.tpl_url}/images/grid/icon.edit.gif" border="0" /></a></td>
							  <td width="20" valign="middle" height="24" align="center"><a class="linkOneActive" href="{makeLink mod=$smarty.request.mod pg=link}area={$smarty.request.area}&cms_id={$smarty.request.cms_id}&id={$row->id}&act=delete&parent_id={$smarty.request.parent_id}{/makeLink}" onclick="javascript: return confirm('Are you sure to delete?')"><img title="Delete" alt="Delete" src="{$GLOBAL.tpl_url}/images/grid/icon.delete.gif" border="0" /></a></td>
							  <td valign="middle" height="24" align="left" class="handle">{$row->title}</td>
							  <td width="20" nowrap="nowrap" align="center"><span>{$row->position}</span></td>
							  <td width="10"><a class="linkOneActive" href="{makeLink mod=`$smarty.request.mod` pg=`$smarty.request.pg`}act=list&parent_id={$row->id}&limit={$smarty.request.limit}&id={$smarty.request.id}&sId={$smarty.request.sId}&fId={$smarty.request.fId}&area={$smarty.request.area}&cat_parent_id={$smarty.request.cat_parent_id}{/makeLink}"><img src="{$GLOBAL.tpl_url}/images/grid/explore_next_level.gif" alt="Edit" border="0" {popup text="[Click here to explore the child level menu]" fgcolor="#eeffaa" width="340"}></a></td>
							</tr>
						</table>
					   </div>
				  {/foreach}
				</div>
				</td>
			  </tr>
			  <tr><td class="naGridTitle"></td></tr>
			  <tr>
			  	<td height="30" align="center"><input type="submit" name="Submit" value="Save Changes" class="naBtn" />
				<input type="hidden" name="act" value="sort" /><input type="hidden" name="sortOrder" value="" />
				{if $STORE_AREA_FLAG eq '1'}
				<input type="hidden" name="hid_menudetails" value="{$LINK_LIST}" />
				<input type="submit" name="btn_updateexisting" value="Update Menu for all Existing Stores" class="naBtn" />
				{/if}
				</td>
			  </tr>
			</table></form><div id="aa"></div>
	  {/if}
	  {else}
	    {/if}
	  </td>
      <td width="3%">&nbsp;</td>
    </tr>
	
	 
</table>
 <script type="text/javascript">
 {literal}
 // <![CDATA[
   Sortable.create("linkOrder",
	 {tag:'div',onUpdate:saveOrder,dropOnEmpty:true,containment:["linkOrder"],handle:'handle',constraint:false});
 // ]]>
 function saveOrder() {
 	document.orderFrm.Submit.style.color = "#FF0000";
 	document.orderFrm.sortOrder.value = Sortable.serialize('linkOrder');
 }
 {/literal}
 </script>