var LocationType="";
var LocationWindow;
var MapWindowParams="width=680,height=680,location=no,menubar=no,resizeble=no,scrollbars=yes,status=yes,toolbar=no,fullscreen=no";
var LocationSourceForm;

function SelectFromLocation()
{	var MapURL='';
	LocationType="from";
	MapURL='/utils/locationselectpopup.asp?';
	MapURL+='ts=1&lxn=lx&lyn=ly&lcn=lc&lzn=lz';
	if (document.ItineraryForm.fx.value!=0 && document.ItineraryForm.fy.value!=0) 
		{
		MapURL+='&tlx='+document.ItineraryForm.fx.value;
		MapURL+='&tly='+document.ItineraryForm.fy.value;
		MapURL+='&zimtl=1';
		}
	window.open(MapURL,'LocationSelectMap',MapWindowParams);
	return;
}

function SelectFromLocationGoogle()
{	var MapURL='';
	LocationType="from";
	MapURL='/utils/locationselectpopup_g.asp?';
	MapURL+='ts=1&lxn=lx&lyn=ly&lcn=lc&lzn=lz';
	if (document.ItineraryForm.fx.value!=0 && document.ItineraryForm.fy.value!=0) 
		{
		MapURL+='&tlx='+document.ItineraryForm.fx.value;
		MapURL+='&tly='+document.ItineraryForm.fy.value;
		MapURL+='&zimtl=1';
		}
	window.open(MapURL,'LocationSelectMap',MapWindowParams);
	return;
}

function SelectToLocation()
{	var MapURL='';
	LocationType="to";
	MapURL='/utils/locationselectpopup.asp?';
	MapURL+='ts=1&lxn=lx&lyn=ly&lcn=lc&lzn=lz';
	if (document.ItineraryForm.tx.value!=0 && document.ItineraryForm.ty.value!=0) 
		{
		MapURL+='&tlx='+document.ItineraryForm.tx.value;
		MapURL+='&tly='+document.ItineraryForm.ty.value;
		MapURL+='&zimtl=1';
		}
	window.open(MapURL,'LocationSelectMap',MapWindowParams);
	return;
}

function SelectToLocationGoogle()
{	var MapURL='';
	LocationType="to";
	MapURL='/utils/locationselectpopup_g.asp?';
	MapURL+='ts=1&lxn=lx&lyn=ly&lcn=lc&lzn=lz';
	if (document.ItineraryForm.tx.value!=0 && document.ItineraryForm.ty.value!=0) 
		{
		MapURL+='&tlx='+document.ItineraryForm.tx.value;
		MapURL+='&tly='+document.ItineraryForm.ty.value;
		MapURL+='&zimtl=1';
		}
	window.open(MapURL,'LocationSelectMap',MapWindowParams);
	return;
}

function SelectLocationUsingMap(TargetURL, TheForm)
{	var MapURL='';
	LocationType="";
	LocationSourceForm=TheForm;
	MapURL='/utils/locationselectpopup.asp?';
	MapURL+='lx='+TheForm.lx.value;
	MapURL+='&ly='+TheForm.ly.value;
	MapURL+='&lxn=lx&lyn=ly&lsn=ls&lcn=lc&lzn=lz';
	if (TargetURL.length>0) {MapURL+='&trgt='+escape(TargetURL)};
	window.open(MapURL,'LocationSelectMap',MapWindowParams);
	return;
}

function SetLocation(LocX, LocY, LocStreet, LocCity, LocZIP)
{
	if (LocationType=="to")
		{
		document.ItineraryForm.tx.value=LocX;
		document.ItineraryForm.ty.value=LocY;
		document.ItineraryForm.ts.value=unescape(LocStreet);
		document.ItineraryForm.tc.value=unescape(LocCity);
		if (document.ItineraryForm.tz) document.ItineraryForm.tz.value=LocZIP;
		Close();
		return;
		}
	if (LocationType=="from")
		{
		document.ItineraryForm.fx.value=LocX;
		document.ItineraryForm.fy.value=LocY;
		document.ItineraryForm.fs.value=unescape(LocStreet);
		document.ItineraryForm.fc.value=unescape(LocCity);
		if (document.ItineraryForm.fz) document.ItineraryForm.fz.value=LocZIP;
		Close();
		return;
		}
	if (LocationType=="" && LocationSourceForm)
		{
		LocationSourceForm.lx.value=LocX;
		LocationSourceForm.ly.value=LocY;
		LocationSourceForm.ls.value=unescape(LocStreet);
		LocationSourceForm.lc.value=unescape(LocCity);
		if (LocationSourceForm.lz) LocationSourceForm.lz.value=LocZIP;
		Close();
		return;
		}
	return;
}

function Close()
{
	if (LocationWindow) {LocationWindow.close();}
}

