var busyFlag;

busyFlag=0;


function AddObjToRouteByXY(currX,currY, lAddType)
{
	//alert("AddObjToRouteByXY: " + currX + "," + currY);
	if ((m_sClientBrowserType == 'IE') && (m_sClientPlatform == 'Windows')) {
		document.getElementById("frmMap").contentWindow.document.getElementById("imgMap").releaseCapture();
	}
	var RoutesResWin;
	var sm;
	sm=document.getElementById("cboMaps").value;

	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&chi='+lAddType+'&md=1&cx='+currX+'&cy='+currY+'&sm='+sm,'frmRouteRes');
}

function cmdRoutesAdd(lAddType)
{
	var RoutesResWin, objList, selIndx, routeObj, opt;
	var sm;
	
	objList = parent.document.getElementById("routObjects" + lAddType);
	routeObj=parent.document.getElementById("listPoints"); 
	selIndx=objList.selectedIndex;
	
	if (selIndx <0)
	{
		alert(MSG_11);
		return;
	}
	var lSelectedCityId;
	lSelectedCityId = objList.options[selIndx].value;
	
	objList.selectedIndex = 0;
	sm=0;
	
	if(lSelectedCityId < 0)return;
	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&md=1&chi='+lAddType+'&twnid='+lSelectedCityId+'&sm='+sm,'frmRouteRes');
	
}

function addSelectedToRoute(lAddType)
{
	var RoutesResWin;
	var sm;
	
	sm=document.getElementById("cboMaps").value;
	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&chi='+lAddType+'&md=6'+'&sm='+sm,'frmRouteRes');
}


function clearCurrRout()
{
	var RoutesResWin;
	var currObj;
	
	document.getElementById("firstPoint").value='';	
	document.getElementById("lastPoint").value='';
	
	currObj=document.getElementById("listPoints");
	do
		currObj.remove(0);
	while (currObj.options.length=0);
	
	//parent.document.getElementById("divLoader").style.visibility = 'visible';
	
	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&md=5','frmRouteRes');
}

function cmdRoutesFind()
{
	var RoutesCalcWin
	var radioObj
	var paramVal
	
	radioObj=document.getElementById("shortlyPath");
	
	if (radioObj.checked)
		paramVal='Length';
	else
		paramVal='Time';
	
	if  (busyFlag==0)
	{
	
		radioObj=document.getElementById("quicklyPath");
		parent.document.getElementById("divLoaderWait").style.visibility = 'visible';

	//RoutesCalcWin=window.open('routesCalc.asp?tpanl='+paramVal,'calculateroute'+g_sessionId,"height=500,width=600,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no,left=10,top=10,resizable=yes");
		RoutesCalcWin = ShowForm(false, "Route", paramVal);
		busyFlag=1;//flaga se svalia v routesCalc		
	}
	
}

function MoveUp()
{
	var curSelIndx;
	var routeObj;
	var currInerText;
	var currValue;
	
	routeObj=parent.document.getElementById("listPoints"); 
	if (routeObj.selectedIndex<0) return;
	if (routeObj.selectedIndex==0) return;
	
	curSelIndx=routeObj.selectedIndex;
	currInerText=routeObj.options[routeObj.selectedIndex].innerHTML;
	currValue=routeObj.options[routeObj.selectedIndex].value;
	
	routeObj.options[routeObj.selectedIndex].innerHTML=routeObj.options[routeObj.selectedIndex-1].innerHTML;
	routeObj.options[routeObj.selectedIndex].value=routeObj.options[routeObj.selectedIndex-1].value;
	
	routeObj.options[routeObj.selectedIndex-1].innerHTML=currInerText;
	routeObj.options[routeObj.selectedIndex-1].value=currValue;
	routeObj.selectedIndex=routeObj.selectedIndex-1;
	
	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&md=9&objid='+curSelIndx,'frmRouteRes');
}

function DelRow()
{
	var curSelIndx;
	var routeObj;
	var RoutesResWin;
	
	routeObj=parent.document.getElementById("listPoints"); 
	if (routeObj.selectedIndex<0) return;
	
	curSelIndx=routeObj.selectedIndex;
	
	routeObj.remove(routeObj.selectedIndex);
	if (routeObj.options.length>0)
		routeObj.selectedIndex=0;
		
	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&md=8&objid='+curSelIndx,'frmRouteRes');	
	
}

function MoveDown()
{
	var curSelIndx;
	var routeObj;
	var currInerText;
	var currValue;
	
	routeObj=parent.document.getElementById("listPoints"); 
	if (routeObj.selectedIndex<0) return;
	if (routeObj.selectedIndex==routeObj.options.length-1) return;
	
	curSelIndx=routeObj.selectedIndex;
	currInerText=routeObj.options[routeObj.selectedIndex].innerHTML;
	currValue=routeObj.options[routeObj.selectedIndex].value;
	
	routeObj.options[routeObj.selectedIndex].innerHTML=routeObj.options[routeObj.selectedIndex+1].innerHTML;
	routeObj.options[routeObj.selectedIndex].value=routeObj.options[routeObj.selectedIndex+1].value;
	
	routeObj.options[routeObj.selectedIndex+1].innerHTML=currInerText;
	routeObj.options[routeObj.selectedIndex+1].value=currValue;
	routeObj.selectedIndex=routeObj.selectedIndex+1;
	
	RoutesResWin=window.open('routes.asp?lng='+ g_LANG +'&md=7&objid='+curSelIndx,'frmRouteRes');
}

function ShowEdge(currid,currindx)
{
	var RoutesResWin;
	var radioObj
	var paramVal
	
	//radioObj=document.getElementById("shortlyPath");
	
	//if (radioObj.checked)
	//	paramVal='Length';
	//else
	//	paramVal='Time';
//prm='+paramVal+'&
	RoutesResWin=window.open('ShowrEdgeRouts.asp?swid='+currid+'&indx='+currindx,'frmRouteRes');
}

function zoomToRoute()
{	
	var RoutesResWin;
	
	RoutesResWin=window.open('routesZoom.asp','frmRouteRes');
}

function printRoute()
{
	var RoutesPrintWin

	RoutesPrintWin=window.open('printRoute.asp','printroute',"height=600,width=600,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no, left=10,top=10");

}