<tal:block metal:use-macro="python:here.getFormsTool().getForm('site_admin_template').macros['page']">

<h1 metal:fill-slot="title" i18n:translate="">Arrange portlets - Front page</h1>

<tal:block metal:fill-slot="section" tal:define="site_url here/getSitePath">

<div class="tabbedmenu">
<ul>
	<li><a tal:attributes="href string:${site_url}/admin_leftportlets_html" i18n:translate="">Left side</a></li>
	<li class="currenttab"><a tal:attributes="href string:${site_url}/admin_frontportlets_html" i18n:translate="">Front page</a></li>
	<li><a tal:attributes="href string:${site_url}/admin_rightportlets_html" i18n:translate="">Right side</a></li>
</ul>
</div>

<script type="text/javascript">
<!--
function add()
{
	var selectleft = document.frmportlets.available;
	var selectright = document.frmportlets.portlets;
	var i;
	for(i = 0; i < selectleft.options.length; i++)
	{
		if(selectleft.options[i].selected)
		{
			var o = document.createElement( "option");
			o.text = selectleft.options[i].text;
			o.value = selectleft.options[i].value;
			selectright.options[selectright.options.length] = o;
			selectleft.remove(i);
			i--;
		}
	}
}
function remove()
{
	var selectleft = document.frmportlets.available;
	var selectright = document.frmportlets.portlets;
	var i;
	for( i = 0; i < selectright.options.length; i++)
	{
		if(selectright.options[i].selected)
		{
			var o = document.createElement( "option");
			o.text = selectright.options[i].text;
			o.value = selectright.options[i].value;
			selectleft.options[selectleft.options.length] = o;
			selectright.remove(i);
			i--;
		}
	}
}
function moveup()
{
	var selectright = document.frmportlets.portlets;
	var i;
	for( i = 0; i < selectright.options.length; i++)
	{
		if(selectright.options[i].selected && (i > 0))
		{
			var o1 = document.createElement( "option");
			o1.text = selectright.options[i-1].text;
			o1.value = selectright.options[i-1].value;
			var o2 = document.createElement( "option");
			o2.text = selectright.options[i].text;
			o2.value = selectright.options[i].value;
			selectright.options[i-1] = o2;
			selectright.options[i] = o1;
			selectright.options[i-1].selected = true;
		}
	}
}
function movedown()
{
	var selectright = document.frmportlets.portlets;
	var i;
	for( i = selectright.options.length-1; i >= 0; i--)
	{
		if(selectright.options[i].selected && (i < selectright.options.length-1))
		{
			var o1 = document.createElement( "option");
			o1.text = selectright.options[i].text;
			o1.value = selectright.options[i].value;
			var o2 = document.createElement( "option");
			o2.text = selectright.options[i+1].text;
			o2.value = selectright.options[i+1].value;
			selectright.options[i] = o2;
			selectright.options[i+1] = o1;
			selectright.options[i+1].selected = true;
		}
	}
}
function dosubmit()
{
	var selectright = document.frmportlets.portlets;
	var i;
	for( i = 0; i < selectright.options.length; i++)
	{
		selectright.options[i].selected = true;
	}
}
// -->
</script>

<p i18n:translate="" class="cleaner">
	This page allows you to establish the list of portlets displayed in the middle part of
	this portal's front page. The portlet(s) must already exist - if you want to define new ones, choose the 
	appropriate link from the administration menu.
</p>
<form name="frmportlets" method="post" tal:attributes="action string:${site_url}/admin_frontportlets">
<table border="0" cellspacing="4" cellpadding="4">
<tr>
	<td i18n:translate="">Available portlets:</td>
	<td></td>
	<td i18n:translate="">Current front page portlets:</td>
	<td></td>
</tr>
<tr>
	<td>
		<select name="available" size="10" multiple="multiple">
			<option tal:repeat="item here/get_available_center_portlets_objects"
					tal:attributes="value item/id">
				<span tal:replace="item/title_or_id" /> (<span i18n:translate="" tal:omit-tag="" tal:content="item/get_type_label" />)
			</option>
		</select>
	</td>
	<td valign="middle">
		<input type="button" value="Add ->" i18n:attributes="value" onclick="javascript:add();"/>
		<br /><br />
		<input type="button" value="<- Remove" i18n:attributes="value" onclick="javascript:remove();" />
	</td>
	<td>
		<select name="portlets" size="10" multiple="multiple">
			<option tal:repeat="item here/get_center_portlets_objects"
					tal:attributes="value item/id">
				<span tal:replace="item/title_or_id" /> (<span i18n:translate="" tal:omit-tag="" tal:content="item/get_type_label" />)
			</option>
		</select>
	</td>
	<td valign="middle">
		<input type="button" value="Move Up" i18n:attributes="value" onclick="javascript:moveup();" />
		<br /><br />
		<input type="button" value="Move Down" i18n:attributes="value" onclick="javascript:movedown();" />
	</td>
</tr>
<tr>
	<td colspan="4" align="center">
		<input type="submit" value="Save changes" i18n:attributes="value" onclick="javascript:dosubmit();" />
	</td>
</tr>
</table>
</form>
</tal:block>

</tal:block>
