{=func:set_bouquet_edit_form=}
{=include-block:Y_Blocks.txt;head=}
<script src="/Y_Baselib.js"></script>
<script>
function do_submit(){
	show_waitbox(true);
	for (i=document.getElementById('channels').bchannels.length-1; i >= 0 ; i--) {
		document.getElementById('channels').bchannels.options[i].selected=true;
	}
	document.getElementById('channels').submit();
}
function do_abort(){
	document.location.href="/Y_Boxcontrol_Bouquet_Editor_Main.yhtm?selected={=selected=}";
}
function movechannels(source, destination){
	for (i=0; i < source.length; i++) {
		if (source.options[i].selected==true) {
			destination.options[destination.length] = new Option(source.options[i].text, source.options[i].value);
		}
	}
	for (i=source.length-1; i >= 0 ; i--) {
		if (source.options[i].selected==true) {
			source.options[i] = null;
		}
	}
}
function poschannel(box, direction){
	if (direction==0) {
		for (i=1; i < box.length  ; i++) {
			if (box.options[i].selected==true) {
				buffer = new Option(box.options[i].text, box.options[i].value);
				box.options[i].selected=false;
				box.options[i]= new Option(box.options[i-1].text, box.options[i-1].value);
				box.options[i-1]=buffer;
				box.options[i-1].selected=true;
			}
		}
	} else {
		for (i=box.length-2; i >= 0  ; i--) {
			if (box.options[i].selected==true) {
				buffer = new Option(box.options[i].text, box.options[i].value);
				box.options[i].selected=false;
				box.options[i]=new Option(box.options[i+1].text, box.options[i+1].value);
				box.options[i+1]=buffer;
				box.options[i+1].selected=true;
			}
		}
	}
}
</script>
{=include-block:Y_Blocks.txt;head_close=}

<body>
{=var-set:wait_text={=L:save_values=}=}{=include-block:Y_Blocks.txt;snip_wait=}
<div class="work_box">
	<div class="work_box_head"><div class="work_box_head_h2">
	{=var-set:menu={=L:bou.bouquet=} &quot;{=name=}&quot;=}{=include-block:Y_Blocks.txt;work_menu=}</div></div>
	<div class="work_box_body">
		<form action="/control/changebouquet" method="post" id="channels" enctype="x-www-form-urlencoded">
		<p><input type="hidden" name="selected" value="{=selected=}" /></p>
		<table cellspacing="5">
		<tr>
			<td>
				<select multiple="multiple" size="20" name="bchannels">
				{=bouquet_channels=}
				</select>
			</td>
			<td align="center">
				<button type="button" title="{=L:bou.move_up=}" onclick="poschannel(document.getElementById('channels').bchannels, 0);">&nbsp;<img src="/images/arrowup.png"/>&nbsp;</button><br /><br />
				<button type="button" title="{=L:bou.move_down=}" onclick="poschannel(document.getElementById('channels').bchannels, 1);">&nbsp;<img src="/images/arrowdown.png"/>&nbsp;</button><br /><br />
				<button type="button" title="{=L:bou.remove=}" onclick="movechannels(document.getElementById('channels').bchannels, document.getElementById('channels').achannels);">&nbsp;<img src="/images/arrowright.png"/>&nbsp;</button><br /><br />
				<button type="button" title="{=L:bou.add=}" onclick="movechannels(document.getElementById('channels').achannels, document.getElementById('channels').bchannels);">&nbsp;<img src="/images/arrowleft.png"/>&nbsp;</button><br /><br />
			</td>
			<td>
				<select multiple="multiple" size="20" name="achannels">
				{=all_channels=}
				</select>
			</td>
		</tr>
		</table>
		<input type="hidden" name="redirect" value="/Y_Boxcontrol_Bouquet_Editor_Main.yhtm"/>
		<p><button type="button" ytype="save" onclick="do_submit();">{=L:save=}</button>
		<button type="button" ytype="cancel" onclick="do_abort();">{=L:cancel=}</button></p>
		{=L:bou.bouquets_must_be_saved=}
		</form>
	</div>
</div>
</body>
</html>
