function isOption(list,value)
{
	var i;
	if(list.options)
	{
		for(i=0; i<list.options.length; i++)
		{
			if(list.options[i].value==value)
				return true;
		}
	}
	return false;
}

function addOptions(all)
{
	var list=document.getElementById('subway_zones');
	var list2=document.getElementById('selected_zones');
	for(i=0; i<list.options.length; i++)
	{
		if(list.options[i].selected || all)
		{
			if(!isOption(list2,list.options[i].value))
			{
				list2.options[list2.options.length] = new Option(list.options[i].text, list.options[i].value);
			}
			
		}
	}
}

function setArea(id, value,show)
{
	var list=document.getElementById('selected_zones');
	if(show)
	{
		for(i=0; i<list.options.length; i++)
		{
			if(list.options[i].value==id)
				list.options[i]=null;
		}
	}
	else if(!isOption(list,id))
		list.options[list.options.length] = new Option(value, id);	
}

function removeOptions(all)
{
	var list=document.getElementById('selected_zones');
	var i;
	for(i=(list.options.length-1); i>-1; i--)
	{
		if(list.options[i].selected || all)
		{
			list.options[i]=null;
		}
	}
}

function addZones()
{
	var list=document.getElementById('selected_zones');
	var zones=document.getElementById('zones_hidden');
	for(i=0; i<list.options.length; i++)
	{
		zones.value+=list.options[i].value+',';
	}
	
	return true;
}

