function setOptions(dest,val,defaultSelect)
{
	eval("arrayDest = "+dest.name)
	dest.length = 0;
	dest.options[0] = new Option(defaultSelect,''); 
	index = 1;
	for(i=0;i<arrayDest.length;i++)
	{

		if((arrayDest[i][2] == val) || trim(val)=='')
		{
			dest.options[index] = new Option(arrayDest[i][1],arrayDest[i][0]); 
			index++;
		}
	}	
}

function setOptions1(dest,val,defaultSelect)
{
	eval("arrayDest = "+dest.name)
	dest.length = 0;
	
	if(val!="0")
	{
		dest.options[0] = new Option(defaultSelect,''); 
		index = 1;
		for(i=0;i<arrayDest.length;i++)
		{
	
			if((arrayDest[i][2] == val) || trim(val)=='')
			{
				dest.options[index] = new Option(arrayDest[i][1],arrayDest[i][0]); 
				index++;
			}
		}
		document.getElementById('hotel_ship_name').innerHTML = 'Hotel Name/Ship Name *';
	}
	else
	{
		document.getElementById('hotel_ship_name').innerHTML = 'Hotel Name/Ship Name';
		dest.options[0] = new Option('This is not required','0');
	}	
}

function setIndex(dest,index)
{
	selectedIndex = 0;
	for(i=0;i<dest.options.length;i++)
		if(dest.options[i].value == index)
			selectedIndex = i;
	dest.selectedIndex = selectedIndex;
}

function orderItems(s)
{
	for(i=0;i<s.length;i++)
	{
		if(s.options[i].selected && i>0)
		{
			preText = s.options[i-1].text;
			preValue = s.options[i-1].value;
			s.options[i-1].text = s.options[i].text;
			s.options[i-1].value = s.options[i].value;
			s.options[i].text=preText;
			s.options[i].value=preValue;
		}	
	}
}

//move selected options between the 2 menus, from source (s) to destination (d)
function moveItems(s,d)
{
	for(i=0;i<s.length;i++)
	{
		if(s.options[i].selected)
		{
			d.options[d.length]=new Option(s.options[i].text, s.options[i].value);
			s.options[i] = null;
			i--;
		}	
	}
}

//select All options in the menu
function selectAll(menu)
{
	for(i=0;i<menu.length;i++)
		menu.options[i].selected=true;
}

// Check for aternative location
function check_location(dest,val,swap)
{
	eval("arrayDest = "+dest.name);
	cnt = 0;
	for(i=0;i<arrayDest.length;i++)
	{
		if((arrayDest[i][2] == val) || trim(val)=='')
			cnt++;			
	}
	if(cnt==0)
	{
		document.getElementById('tiare_agent_location_select').style.display = 'none';
		document.getElementById('agent_location').style.display = 'none';
		document.getElementById('tiare_agent_location_row').style.display = '';
		document.getElementById('tiare_agent_location_text').innerHTML = 'Presently there are no TIARE Agents in '+val+'.<br'+'>'+'Your enquiry will be forwarded to an Agent in '+swap+'.';
		document.getElementById('agent_location').options[0].value = "-1";
	}
	else
	{
		document.getElementById('agent_location').options[0].value = "";
		document.getElementById('tiare_agent_location_select').style.display = '';
		document.getElementById('agent_location').style.display = '';
		document.getElementById('tiare_agent_location_row').style.display = 'none';
		document.getElementById('tiare_agent_location_text').innerHTML = '';
	}
}