<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>FatRat - new transfer</title>
<link rel="icon" href="/favicon.png" type="image/png"/>
<link rel="stylesheet" type="text/css" href="/style.css"/>
<script type="text/javascript" src="/filedialog/api.js"></script>

<script type="text/javascript"><!--
function queueChanged()
{
	var elemQueue = document.getElementById('queue');
	var elemDir = document.getElementById('destination');
	if(elemQueue.selectedIndex == lastQueue)
		return;
	
	if(elemDir.value == defaultDirs[lastQueue])
		elemDir.value = defaultDirs[elemQueue.selectedIndex];
	
	lastQueue = elemQueue.selectedIndex;
}
//--></script>
</head>
<body>

<p style="text-align: center"><b>New transfer</b></p>

<form method="post" action="/add_transfer2.qsp">

<table class="transfers">
<tr>
	<td>Queue</td>
	<td>
		<select name="queue" id="queue" style="width: 100%" onchange="javascript: queueChanged()">
		<?qs
		var lastQueue = -1;
		for(i=0;i<QUEUES.length;i++)
		{
			print('<option value="'+QUEUES[i].uuid+'" ');
			if(GET.queue == QUEUES[i].uuid)
			{
				print('selected="selected"');
				lastQueue = i;
			}
			print('>'+QUEUES[i].name+'</option>');
		}
		print("<script type=\"text/javascript\"><!--\n");
		print('var defaultDirs = new Array('+QUEUES.length+');');
		print('var lastQueue = '+lastQueue+';');
		for(i=0;i<QUEUES.length;i++)
			print('defaultDirs['+i+'] = "' + new String(QUEUES[i].defaultDirectory).replace('"','\\"') +'";');
		print('//--></script>');
		?>
		</select>
	</td>
</tr>
<tr>
	<td>Links</td>
	<td><textarea name="links" rows="10" cols="10" style="width: 100%"></textarea></td>
</tr>
<tr>
	<td>Transfer type</td>
	<td>
		<select name="type" style="width: 100%">
			<option value="-1" selected="selected">Auto detect</option>
			<?qs
				for(i=0;i<ENGINES.length;i++)
					print('<option value="'+i+'">'+ENGINES[i]+'</option>');
			?>
		</select>
	</td>
</tr>
<tr>
	<td>Destination</td>
	<td>
		<input type="text" id="destination" name="destination" style="width: 90%" value="<?qs if(lastQueue!=-1) print(QUEUES[lastQueue].defaultDirectory); ?>"/>
		<input type="button" value="..." onclick="javascript: dirDialog('destination')"/>
	</td>
</tr>
<tr>
	<td>Max. download speed</td>
	<td><input type="text" size="4" name="downLimit" value="0"/> kB/s</td>
</tr>
<tr>
	<td>Max. upload speed</td>
	<td><input type="text" size="4" name="upLimit" value="0"/> kB/s</td>
</tr>
<tr>
	<td></td>
	<td><label><input type="checkbox" name="paused" id="paused" value="true"/>Add paused</label></td>
</tr>
</table>

<p style="text-align: center">
	<input type="submit" name="add" value="OK"/>
	<input type="button" value="Close" onclick="javascript:window.close()"/>
</p>

</form>

</body></html>
