function addProject(id, text)
{
	var select = document.forms["boxform"]["box"];
	var option = document.createElement("option");
	option.value = id;
	option.innerHTML = text;
	
	for (var i = 0; i < select.options.length; i++)
	{
		if (select.options[i].value == id)
		{
			return false;
		}
	} 
	
	select.options.add(option);
	fillValues();
	return true;
}

function selectUp()
{
	var select = document.forms["boxform"]["box"];
	if (select.selectedIndex > 0)
	{
		swapOptions(select.selectedIndex, select.selectedIndex - 1); 
	}
	fillValues();
}

function swapOptions(i, j)
{
		var select = document.forms["boxform"]["box"];
		option1 = select.options[i];
		option2 = select.options[j];
		
		var txt = option1.innerHTML;
		var val = option1.value;
		
		option1.innerHTML = option2.innerHTML;
		option1.value = option2.value;
		
		option2.innerHTML = txt;
		option2.value = val;
		
		select.selectedIndex = j;
}

function selectDown()
{
	var select = document.forms["boxform"]["box"];
	if (select.selectedIndex > -1 && select.selectedIndex < select.options.length - 1)
	{
		swapOptions(select.selectedIndex, select.selectedIndex + 1); 
	}
	fillValues();
}

function selectDelete()
{
	var select = document.forms["boxform"]["box"];
	select.remove(select.selectedIndex);
	select.selectedIndex = -1;
	fillValues();
	document.forms["boxform"]["delete"].value = select.options[select.selectedIndex].value;
}

function fillValues()
{
	var select = document.forms["boxform"]["box"];
	var boxvals = document.forms["boxform"]["boxvalues"];
	boxvals.value = "";
	for (var i = 0; i < select.options.length; i++)
	{
		boxvals.value += (boxvals.value.length > 0 ? "," : "");
		boxvals.value += select.options[i].value.toString();
	} 
}

function selectEdit(url)
{
	var select = document.forms["boxform"]["box"];
	location.href = url + select.options[select.selectedIndex].value;
}