﻿function cRoute()
{
	var uid;
	var routeId;
	var changeCount;
	var pointsCount;
	var cost;
	var time;
	var len;
	var walk1;
	var walk2;
	var wtotal;
	var unitCount;
	var units;
	var header;
	var target;
	var iwn;
	var icwn;
	var pts;
	var fellaznum=0;
	var fellazlink='';
	var routeRater; // объект для рейтингования маршрута

	// константы для удобства чтения кода
	var _mapwayname=0;
	var _htmlwayname=1;
	var _waytype=2;
	var _pointsCount=3;
	var _len=4;
	var _time=5;
	var _cost=6;
	var _textstyle=7;
	var _mapiconlink=8;
	var _htmliconlink=9;
	var _linelink=10;
	var _typelink=11;
	var _walkbefore=12;
	var _trafqoef=13;
	var _trafdesc=14;
	var _unum=15;
	var _htmlwaynameforprint=16;
	var _icwn=17;
	var _url=18;
	var _usch=18;

	var _name=0;
	var _address=1;
	var _lat=2;
	var _lng=3;

	this.getEndPoint=function(address){
		var a = '<div class="unit endpoint">'+
		'<div><img alt="&darr;" src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/endpoint.gif"/></div>'+
		'<strong>'+address+'</strong>'+'</div>';
		if(unitCount==0 || units[unitCount-1][0][_waytype]==0 || units[unitCount-1][0][_waytype]==13){
			a = '<div class="arrow specarrow"><small>&nbsp;</small></div>'+a;
		}
		else{
			a = '<div class="arrow specarrow"><small>'+walk2+' '+sklonit(METER_WORD,walk2)+' '+BY_WALK+'</small></div>'+a;
		}
		return a;
	};
	this.getBegPoint=function(address){
		var a = '<div class="unit begpoint">'+
		'<div><img alt="&darr;" src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/begpoint.gif"/></div>'+
		'<strong>'+address+'</strong>'+'</div>';
		if(unitCount==0 || units[0][0][_waytype]==0 || units[unitCount-1][0][_waytype]==13){
			a += '<div class="arrow specarrow"><small>&nbsp;</small></div>';
		}
		else{
			a += '<div class="arrow specarrow"><small>'+walk1+' '+sklonit(METER_WORD,walk1)+' '+BY_WALK+'</small></div>';
		}
		return a;
	};

	this.echoNumResults=function(num){
		return '('+num+' '+sklonit(VARIANT_WORD,num)+')';
	};

	this.getFirstAddress=function(i){
		if(i==0 && units[i][0][_waytype]!=6 && units[i][0][_waytype]!=0){
			return '<small>'+units[i][1][_address]+'</small>';
		}
		else{
			return '';
		}
	}

	this.getTrafClass=function(i){
		var result = '';
		if(units[i][0][_waytype]==0 || units[i][0][_waytype]==6 || units[i][0][_waytype]==7 || units[i][0][_waytype]==8){
			result = '';
		}
		else{
			result = '';
		}
		return result;
	};
	this.getTrafDesc=function(i){
		if(HASTRAF__==0){return ''}
		var result = '';
		if(units[i][0][_trafqoef]!=0){
			// на участке есть пробки
			result = '<div id="trafwrap-'+uid+'-'+i+'" class="trafwrap">'+
			'<span id="trafswitch-'+uid+'-'+i+
			'" class="ajaxlink" onMouseOver="showTrafficWin('+uid+','+i+');" '+
			'onMouseOut="closeTrafficWin('+uid+'-'+i+');"'+
			'>'+WORD_JAMS+': '+units[i][0][_trafqoef]+' '+sklonit(WORD_BALL,units[i][0][_trafqoef])+'</span>'+
			'<div id="traf-'+uid+'-'+i+'"  class="traf">'+
			//'<img class="close-win" src="http://msk.rusavtobus.ru/images_ru/closewindow-mini.gif" onclick="closeTrafficWin('+uid+'-'+i+');" alt="закрыть окно"/>'+
			parseTraffic(units[i][0][_trafdesc])+'</div>'+
			'</div>';
		}
		else if(units[i][0][_waytype]<6){
			result = '<div id="trafwrap-'+uid+'-'+i+'" class="trafwrap">'+
			'<span class="freeway">'+FREE_WAY+'</span>'+
			'</div>';
		}
		return result;
	}

	this.getUnitsInText=function(forPrint)
	{
		forPrint = forPrint==null?false:forPrint;
		var a='';
		var b=0;
		for(var i=0;i<unitCount;i++)
		{
			var firstAddress = this.getFirstAddress(i);
			if(forPrint){
				var _wayname = units[i][0][_htmlwaynameforprint];
			}
			else{
				var _wayname = units[i][0][_htmlwayname];
			}

			if(units[i][0][_waytype]==0){//пешеход
				a+=	'<div class="unit '+units[i][0][_linelink]+'">'+
				'<div class="toppoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+
				units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'<div class="toppointinfo">'+'<strong>&nbsp;</strong>'+
				'</div>'+
				'<div class="unitinfo">'+
				'<h6>'+_wayname+'</h6>'+
				'</div>'+
				'<div class="botpointinfo">'+'<strong>&nbsp;</strong>'+
				'</div>'+
				'<div class="botpoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'</div>';
			}
			else if(units[i][0][_waytype]==13){//такси
				a+=	'<div class="unit '+units[i][0][_linelink]+'">'+
				'<div class="toppoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+
				units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'<div class="toppointinfo">'+'<strong>&nbsp;</strong>'+
				'</div>'+
				'<div class="unitinfo">'+
				'<h6>'+_wayname+'</h6>'+
				'</div>'+
				'<div class="botpointinfo">'+'<strong>&nbsp;</strong>'+
				'</div>'+
				'<div class="botpoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'</div>';
			} else {
				// полноценные юниты
				var trafDesc = this.getTrafDesc(i);

				b=units[i].length-1;
				a+=	'<div class="unit '+units[i][0][_linelink]+this.getTrafClass(i)+'">'+
				'<div class="toppoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+
				units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'<div class="toppointinfo"><strong>'+units[i][1][_name]+'</strong>'+
				firstAddress+
				'</div>'+
				'<div class="unitinfo">'+
				'<h6>'+_wayname+'</h6>'+
				trafDesc+
				'</div>'+
				'<div class="botpointinfo"><strong>'+units[i][b][_name]+'</strong>'+
				'</div>'+
				'<div class="botpoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'</div>';
			}
			if(i!=unitCount-1)
			{
				if( units[i+1] && units[i+1][0][_waytype]==0){
					a+='<div class="arrow">'+'<small>&nbsp;</small>'+'</div>';
				}
				else if(units[i][0][_waytype]==0){
					a+='<div class="arrow">'+'<small>&nbsp;</small>'+'</div>';
				}
				else{
					a+='<div class="arrow">'+'<small>'+units[i+1][0][_walkbefore]+' '+sklonit(METER_WORD,units[i+1][0][_walkbefore])+' '+BY_WALK+'</small>'+'</div>'
				}
			}
		}
		return a
	};
	this.getRouteInfoForPrint=function(){
		var str = '<div class="routeinfo">';
		if(target=='speed'){
			str += '<strong>'+time+' '+sklonit(MINUTE_WORD,time)+' '+DURATION+'<em>*</em></strong><br/>';
		}
		else{
			str += time+' '+sklonit(MINUTE_WORD,time)+' '+DURATION+'<em>*</em><br/>';
		}
		if(target=='changes'){
			str += '<strong>'+changeCount+' '+sklonit(CHANGE_WORD,changeCount)+'</strong><br/>';
		}
		else{
			str += changeCount+' '+sklonit(CHANGE_WORD,changeCount)+'<br/>';
		}
		if(target=='walk'){
			str += '<strong>'+wtotal+' '+sklonit(METER_WORD,wtotal)+' '+BY_WALK+'</strong><br/>';
		}
		else{
			str += wtotal+' '+sklonit(METER_WORD,wtotal)+' '+BY_WALK+'<br/>';
		}
		if(target=='cost'){
			str += '<strong>'+cost+' '+sklonit(RUBLE_WORD,cost)+' '+FOR_TICKETS+'</strong>';
		}
		else{
			str += cost+' '+sklonit(RUBLE_WORD,cost)+' '+FOR_TICKETS;
		}
		str += '</div>';
		return str;
	};
	this.getRouteInfo=function(allLinks,withFellaz,type)
	{
		allLinks = allLinks==null?false:allLinks;
		withFellaz = withFellaz==null?false:withFellaz;
		var str = '<div class="routeinfo">';
		if(target=='speed' && !allLinks){
			str += '<strong>'+'<span id="route-'+uid+'-speed">'+time+'</span> '+sklonit(MINUTE_WORD,time)+' '+DURATION+'<em>*</em></strong><br/>';
		}
		else{
			str += '<span class="ajaxlink" onclick="getBestTargetRoute_('+uid+',\'speed\')">'+'<span id="route-'+uid+'-speed">'+time+'</span> '+sklonit(MINUTE_WORD,time)+' '+DURATION+'<em>*</em></span><br/>';
		}
		if(target=='changes' && !allLinks){
			str += '<strong>'+'<span id="route-'+uid+'-change">'+changeCount+'</span> '+' '+sklonit(CHANGE_WORD,changeCount)+'</strong><br/>';
		}
		else{
			str += '<span class="ajaxlink" onclick="getBestTargetRoute_('+uid+',\'changes\')">'+'<span id="route-'+uid+'-change">'+changeCount+'</span> '+' '+sklonit(CHANGE_WORD,changeCount)+'</span><br/>';
		}

		if(target=='walk' && !allLinks){
			str += '<strong>'+'<span id="route-'+uid+'-walk">'+wtotal+'</span> '+' '+sklonit(METER_WORD,wtotal)+' '+BY_WALK+'</strong><br/>';
		}
		else{
			str += '<span class="ajaxlink" onclick="getBestTargetRoute_('+uid+',\'walk\')">'+'<span id="route-'+uid+'-walk">'+wtotal+'</span> '+' '+sklonit(METER_WORD,wtotal)+' '+BY_WALK+'</span><br/>';
		}

		if(target=='cost' && !allLinks){
			str += '<strong>'+'<span id="route-'+uid+'-cost">'+cost+'</span> '+' '+sklonit(RUBLE_WORD,cost)+' '+FOR_TICKETS+'</strong>';
		}
		else if (type!=null && type==13)
		{
			str += '<span class="ajaxlink" onclick="getBestTargetRoute_('+uid+',\'cost\')">'+'<span id="route-'+uid+'-cost">'+cost+'</span> '+' '+sklonit(RUBLE_WORD,cost)+' '+FOR_TICKETS+'**</span>';
		}
		else
		{
			str += '<span class="ajaxlink" onclick="getBestTargetRoute_('+uid+',\'cost\')">'+'<span id="route-'+uid+'-cost">'+cost+'</span> '+' '+sklonit(RUBLE_WORD,cost)+' '+FOR_TICKETS+'</span>';
		}
		if(withFellaz){
			if (type!=13){
				str += '<br/><span id="fellaz-'+uid+'" class="fellaz">'+fellazlink+'</span>';
			}
			else{
				str += '<br/><span id="fellaz-'+uid+'" class="fellaz" style="display:none">'+fellazlink+'</span>';
			}
		}
		str += '<div id="rating-'+uid+'"></div>';
		str += '</div>';
		return str;
	};
	this.getHeaderbyTarget=function(target)
	{
		return headers[target];
	};
	this.getHtmlInnerHeader=function(num,offset,tomap){
		var stuff = '';
		if(LOCALE__ && LOCALE__=='en'){
			var tmp = num+1;
			if(tmp==1){
				stuff = 'st';
			}
			else if(tmp==2){
				stuff = 'nd';
			}
			else if(tmp==3){
				stuff = 'rd';
			}
			else if(tmp>3 && tmp<=9){
				stuff = 'th';
			}
		}
		else{
			stuff='й';
		}
		var printIcon = '<img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/print-icon.gif" alt="на печать" onClick="printLink('+num+','+num+');"/>';
		//var printIcon = '<img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/print-icon.gif" alt="на печать" onClick="toPrint('+num+','+offset+');"/>';
		if(tomap){
			// если нужно ставить с заголовка ссылку по клику на которую будет на карте
			var str = '<a class="ajaxlink tomap" onclick="switchMap('+num+','+offset+')">'+(num+1)+'-'+stuff+' '+VARIANT_WORD+'</a>'+printIcon;
		}
		else{
			//var str = TARGET_HEADER[target]+printIcon;
			var str = (num+1)+'-'+stuff+' '+VARIANT_WORD+printIcon;
		}
		return str
	};
	this.getHtmlHeader=function(num,offset,tomap,plainText)
	{
		plainText = plainText==null?false:plainText;
		var stuff = '';
		if(LOCALE__ && LOCALE__=='en'){
			var tmp = num+1;
			if(tmp==1){
				stuff = 'st';
			}
			else if(tmp==2){
				stuff = 'nd';
			}
			else if(tmp==3){
				stuff = 'rd';
			}
			else if(tmp>3 && tmp<=9){
				stuff = 'th';
			}
		}
		else{
			stuff='й';
		}
		if (!plainText)
		{
			var printIcon = '<input type="hidden" name="num" /><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/print-icon.gif" alt="на печать" onClick="printLink('+num+','+num+');"/>';
			//var printIcon = '<img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/print-icon.gif" alt="на печать" onClick="toPrint('+num+','+offset+');"/>';
		}
		else
		{
			var printIcon = '';
		}
		if(tomap){
			// если нужно ставить с заголовка ссылку по клику на которую будет на карте
			//var str = '<h1 id="resh-'+offset+'"><a class="ajaxlink tomap" onclick="switchMap('+num+','+offset+')">'+TARGET_HEADER[target]+'</a>'+printIcon+'</h1>';
			var inner = plainText==false?'<a class="ajaxlink tomap" onclick="switchMap('+num+','+offset+')">':'';
			var outer = plainText==false?'</a>':'';
			var str = '<h1 id="resh-'+offset+'">'+inner+(num+1)+'-'+stuff+' '+VARIANT_WORD+outer+printIcon+'</h1>';
		}
		else{
			//var str = '<h1 id="resh-'+offset+'">'+TARGET_HEADER[target]+printIcon+'</h1>';
			var isActive = plainText==false?'':' (' + SELECTED + ')';
			var str = '<h1 id="resh-'+offset+'">'+(num+1)+'-'+stuff+' '+VARIANT_WORD + isActive + printIcon+'</h1>';
		}
		return str;//'<h1>'+printIcon+'</h1>'
	};
	this.getW1=function()
	{
		return walk1
	};
	this.getW2=function()
	{
		return walk2
	};
	this.getHeader=function()
	{
		return header
	};
	this.getTime=function(){
		return time
	};
	this.getWalk=function(){
		return wtotal
	};
	this.getCost=function(){
		return cost
	};
	this.getPTextStyle=function(i)
	{
		return units[i][0][_textstyle]
	};
	this.getPMapIconLink=function(i,j)
	{
		if(!units[i][j+1][_mapiconlink]){
			return units[i][0][_mapiconlink];
		}
		else{
			return units[i][j+1][_mapiconlink];
		}
	};
	this.getPAddress=function(i,j)
	{
		return units[i][j+1][_address]
	};
	this.getPName=function(i,j)
	{
		return units[i][j+1][_name]
	};
	this.getPLng=function(i,j)
	{
		return units[i][j+1][_lng]
	};
	this.getPLat=function(i,j)
	{
		return units[i][j+1][_lat]
	};
	this.getMapWayName=function(a)
	{
		return units[a][0][_mapwayname]
	};
	this.getUid=function(){
		return uid
	};
	this.getUnitWalkBefore=function(a)
	{
		return units[a][0][_walkbefore]
	};
	this.getPts=function()
	{
		return pts
	};
	this.getUnitIcwn=function(a)
	{
		return units[a][0][_icwn]
	};
	this.getUnitType=function(a)
	{
		return units[a][0][_waytype]
	};
	this.getUnitCount=function()
	{
		return unitCount
	};
	this.getPointCount=function(a)
	{
		return units[a][0][_pointsCount]
	};
	this.getChangeCount=function()
	{
		return changeCount
	};
	this.setFellaz=function(num_,str_){
		fellaznum = num_;
		fellazlink =str_;
	};
	this.setRating=function(routeId_, userStatus_, oldRating_){
		routeId = routeId_;
		userStatus = userStatus_;
		oldRating = oldRating_;
		routeRater = new RouteRater(routeId, uid, userStatus, oldRating);
	};
	this.setHeaders=function(num_,changeCount_,pointsCount_,cost_,time_,len_,walk1_,walk2_,target_,wtotal_,pts_)
	{
		uid=num_;
		pts=pts_;
		target=target_;
		header=headers[target];
		changeCount=changeCount_;
		pointsCount=pointsCount_;
		cost=cost_;
		time=time_;
		len=len_;
		walk1=parseInt(walk1_);
		walk2=parseInt(walk2_);
		wtotal=parseInt(wtotal_);
		units=new Array();
		unitCount=0
	};
	this.addUnitHeaders=function(a,b,d,t,l,c,wb,tq,td,iwn,icwn,routeNum,unum,url,usch)
	{
		units[unitCount]=new Array();
		units[unitCount][0]=new Array();
		units[unitCount][0][_unum]=unum;
		units[unitCount][0][_trafqoef]=tq==null?0:tq;
		b = icwn.split(':');
		a = b[1];
		b = b[0];
		if(b==0){
			units[unitCount][0][_textstyle]=styles['walk'];
			units[unitCount][0][_mapiconlink]=iconurls['walk']+'.gif';
			units[unitCount][0][_htmliconlink]=iconurls['walk']+'.gif';
			units[unitCount][0][_linelink]=lineurls['walk'];
			units[unitCount][0][_mapwayname]=parseSingleWay(icwn);
		}
		else if(b==8){
			units[unitCount][0][_textstyle]=styles['электричка'];
			units[unitCount][0][_mapiconlink]=iconurls['электричка']+'.png';
			units[unitCount][0][_htmliconlink]=iconurls['электричка']+'.gif';
			units[unitCount][0][_linelink]=lineurls['электричка'];
			units[unitCount][0][_mapwayname]=ELECTRIC_TRAIN;
			units[unitCount][0][_htmlwayname]='<span>'+units[unitCount][0][_mapwayname]+'</span>';
		}
		else if(b==7)
		{
			units[unitCount][0][_textstyle]=styles['Монорельс-1'];
			units[unitCount][0][_mapiconlink]=iconurls['Монорельс-1']+'.png';
			units[unitCount][0][_htmliconlink]=iconurls['Монорельс-1']+'.gif';
			units[unitCount][0][_linelink]=lineurls['Монорельс-1'];
			units[unitCount][0][_htmlwayname]='<span>'+b+'</span>';
			units[unitCount][0][_mapwayname]=a;
		}
		else if(b==6)
		{
			units[unitCount][0][_textstyle]=styles[a];
			units[unitCount][0][_mapiconlink]=iconurls[a]+'.png';
			units[unitCount][0][_htmliconlink]=iconurls[a]+'.gif';
			units[unitCount][0][_linelink]=lineurls['метро'];
			a=a+' '+LINE_STRING;
			units[unitCount][0][_htmlwayname]='<span>'+a+'</span>';
			units[unitCount][0][_mapwayname]=a+' '+types[b];
		}
		else if(b==11){
			units[unitCount][0][_textstyle]=styles['Монорельс-1'];
			units[unitCount][0][_mapiconlink]=iconurls[a]+'.png';
			units[unitCount][0][_htmliconlink]=iconurls[a]+'.gif';
			units[unitCount][0][_linelink]=lineurls['метро'];
			a=types[b]+' '+a;
			units[unitCount][0][_htmlwayname]='<span>'+a+'</span>';
			units[unitCount][0][_mapwayname]=a;
		}
		else if(b==12){
			units[unitCount][0][_textstyle]=styles['спутник'];
			units[unitCount][0][_mapiconlink]=iconurls['спутник']+'.png';
			units[unitCount][0][_htmliconlink]=iconurls['спутник']+'.gif';
			units[unitCount][0][_linelink]=lineurls['метро'];
			a=types[b]+' '+a;
			units[unitCount][0][_htmlwayname]='<span>'+a+'</span>';
			units[unitCount][0][_mapwayname]=a;
		}
		else if(b==13){
			units[unitCount][0][_textstyle]=styles['такси'];
			units[unitCount][0][_mapiconlink]=iconurls['такси']+'.png';
			units[unitCount][0][_htmliconlink]=iconurls['такси']+'.gif';
			units[unitCount][0][_linelink]=lineurls['такси'];
			units[unitCount][0][_mapwayname]=parseSingleWay(icwn);
		}
		else
		{
			units[unitCount][0][_textstyle]=styles['тат'];
			if(HASTRAF__ == 1){
				units[unitCount][0][_mapiconlink]='tat-traf-'+units[unitCount][0][_trafqoef]+'-head'+'.png';
				units[unitCount][0][_htmliconlink]='tat-traf-'+units[unitCount][0][_trafqoef]+'-head'+'.gif';
			}
			else{
				units[unitCount][0][_mapiconlink]='tat-traf-out-head'+'.png';
				units[unitCount][0][_htmliconlink]='tat-traf-out-head'+'.gif';
			}
			units[unitCount][0][_linelink]=lineurls['тат'];
			//units[unitCount][0][_mapwayname]=parseSeveralWays(a);
			units[unitCount][0][_mapwayname]=parseSingleWay(icwn);
		}

		units[unitCount][0][_icwn]=icwn;
		units[unitCount][0][_url]=url;
		units[unitCount][0][_usch]=usch;
		units[unitCount][0][_htmlwayname]=parseSuperString(iwn,icwn,unum,unitCount,routeNum,target,url,usch);
		units[unitCount][0][_htmlwaynameforprint]=parseSuperStringForPrint(iwn,icwn,unum,unitCount,routeNum,target);
		units[unitCount][0][_waytype]=b;
		units[unitCount][0][_typelink]=ticons[b];
		units[unitCount][0][_pointsCount]=d;
		units[unitCount][0][_len]=l;
		units[unitCount][0][_time]=t;
		units[unitCount][0][_cost]=c;
		units[unitCount][0][_walkbefore]=wb;

		if(HASTRAF__ == 0 && b>0 && b<6){
			units[unitCount][0][_linelink] = lineurls['пробка-нет'];
		}
		if(HASTRAF__ == 1 && units[unitCount][0][_trafqoef]>0){
			units[unitCount][0][_linelink]=lineurls['пробка-'+units[unitCount][0][_trafqoef]];
		}
		units[unitCount][0][_trafdesc]=td;
		unitCount++;
	};
	this.addPoint=function(n,a,b,c,hastraf,traf)
	{
		curpoint=units[unitCount-1].length;
		units[unitCount-1][curpoint]=new Array();
		if(units[unitCount-1][0][_waytype]>=6){
			units[unitCount-1][curpoint][_name] = STATION_SHORT+' '+n;
		}
		else{
			units[unitCount-1][curpoint][_name] = POINT_SHORT+' '+n;
		}
		units[unitCount-1][curpoint][_address]=a;
		units[unitCount-1][curpoint][_lat]=b;
		units[unitCount-1][curpoint][_lng]=c;
		if(hastraf>0 && traf && units[unitCount-1][0][_waytype]<=5 && units[unitCount-1][0][_waytype]>0){
			if(traf==0){
				units[unitCount-1][curpoint][_mapiconlink]='tat-traf-0-head.gif';
			}
			else if(traf==1){
				units[unitCount-1][curpoint][_mapiconlink]='tat-traf-2-head.gif';
			}
			else if(traf==2){
				units[unitCount-1][curpoint][_mapiconlink]='tat-traf-6-head.gif';
			}
			else if(traf==3){
				units[unitCount-1][curpoint][_mapiconlink]='tat-traf-10-head.gif';
			}
		}
	};
	parseMiniUnits=function(str,type,currentway,unitNum,realUnitNum,routeNum,target,alone,url,usch){
		// 227_446_17_20, 66_192_4_7
		var newstr = '';
		var ways = str.split(', ');
		var len = ways.length;
		for(var i=0;i<len;i++){
			var way = ways[i].split('_');
			var numPoints = way[3]-way[2];
			var hoverFeatures = ' onmouseover="showNumPointsWin_(event,this,\''+numPoints+' '+sklonit(POINT_WORD,numPoints)+'\');" onmouseout="closeNumPointsWin_('+numPoints+');"';

			if(0 == type && type==currentway[0]){
				// это стопудово активный пешок
				if(alone){
					newstr += '<span class="delim">' + way[0]+' '+sklonit(METER_WORD,way[0])+'</span>';
				}
				else{
					newstr += '<em>' + way[0]+' '+sklonit(METER_WORD,way[0])+'</em>';
				}
			}
			else if(type==currentway[0] && way[0]==currentway[1]){
				// это наш мегамаршрут
				if(6==type){
					var tmpname;
					if(way[0].length<17){
						tmpname = way[0];
					}
					else{
						tmpname = shortways[way[0]];
					}
					if(alone){
						newstr += '<span class="delim"'+hoverFeatures+'>'+tmpname+' '+LINE_STRING+'</span>';
					}
					else{
						newstr += '<em'+hoverFeatures+'>'+tmpname+' '+LINE_STRING+'</em>';
					}
				}
				else if(11==type || 12==type){
					if(alone){
						newstr += '<span class="delim"'+hoverFeatures+'>'+types[type]+'<br/>'+way[0]+'</span>';
					}
					else{
						newstr += '<em'+hoverFeatures+'>'+types[type]+'<br/>'+way[0]+'</em>';
					}
				}
				else{
					if(alone){
						newstr += '<span class="delim"'+hoverFeatures+'>'+way[0]+'</span>';
					}
					else{
						newstr += '<em'+hoverFeatures+'>'+way[0]+'</em>';
					}
				}
				if(url.length!=0){
					if(LOCALE__=='en'){
						url = url.replace(/sch/i,'en/sch');
					}
					newstr += '<br/><a href="'+url+'" target="_blank">'+WORD_SHEDULE+'</a>';
				}
				if(usch.length!=0){
					if(13==type){
						newstr += '<br/><span style="color:#A72F29">'+ORDER_TAXI+'</span>';
					}
					else{
						newstr += '<br/><a href="'+usch+'" target="_blank">'+WORD_SHEDULE+'</a>';
					}
				}
			}
			else{
				if(0 == type){
					// пешок
					if(realUnitNum==0){
						var na = way[0];
						var nb = 0;
					}
					else{
						var na = 0;
						var nb = way[0];
					}
					newstr += '<span onclick="switchRoute_(0,'+na+','+nb+','+unitNum+','+routeNum+',\''+target+'\',0);">' 
					+ way[0]+' '+sklonit(METER_WORD,way[0])+'</span>';
				}
				else{
					if(6==type){
						if(way[0].length>=17){
							way[0] = shortways[way[0]];
						}
						way[0] += ' '+LINE_STRING;
					}
					else if(11==type || 12==type){
						way[0] = types[type]+' '+way[0];
					}
					// или не пешок
					newstr += '<span onclick="switchRoute_('+way[1]+','+way[2]+','+way[3]+','+unitNum+','+routeNum+',\''+target+'\','+type+');"'+hoverFeatures+'>'
					+way[0]+'</span>';
				}
			}
			if(i<len-1){
				newstr += '<span class="delim">,</span> ';
			}
		}
		return newstr;
	};
	parseSuperString=function(str,currentway,unitNum,realUnitNum,routeNum,target,url,usch){
		// функция парсит мегастроку в суперпупер строку
		var newstr = '';
		var transports = str.split(';');
		var ways = new Array();
		var len = transports.length;
		var currentway = currentway.split(':');

		var last = null;
		var first = null;
		if(len>1 && transports[len-1].charAt(0)=='5'){
			last = transports.pop();
		}
		if(len>1 && transports[0].charAt(0)=='0'){
			first = transports.shift();
		}
		if(first!=null){
			transports.push(first);
		}
		if(last!=null){
			transports.unshift(last);
		}

		for(var i=0;i<len;i++){
			ways = transports[i].split(':');
			if(ways[1].indexOf(',')>-1){
				typename = types1[ways[0]]+': ';
			}
			else{
				if(0==ways[0]){
					typename = types[ways[0]]+': ';
				}
				else if(ways[0]>5){
					typename = '';
				}
				else{
					typename = types[ways[0]]+' ';
				}
			}


			if((len==1 && ways[1].indexOf(',')<0) || ways[0]!=currentway[0]){
				newstr += '<span class="delim">'+typename+'</span>';
			}
			else if(ways[0]==currentway[0]){
				//newstr += '<em>'+typename+'</em>';
				newstr += '<span class="delim">'+typename+'</span>';
			}

			newstr += parseMiniUnits(ways[1],ways[0],currentway,unitNum,realUnitNum,routeNum,target,(len==1 && ways[1].indexOf(',')<0),url,usch)+' ';
			if(i!=len-1){
				newstr += '<br/>';
			}
		}

		return newstr;
	};
	parseMiniUnitsForPrint=function(str,type,currentway,unitNum,realUnitNum,routeNum,target,alone){
		// 227_446_17_20, 66_192_4_7
		var newstr = '';
		var ways = str.split(', ');
		var len = ways.length;
		for(var i=0;i<len;i++){
			var way = ways[i].split('_');
			var numPoints = way[3]-way[2];
			var hoverFeatures = ' onmouseover="showNumPointsWin_(event,this,\''+numPoints+' '+sklonit(POINT_WORD,numPoints)+'\');" onmouseout="closeNumPointsWin_('+numPoints+');"';

			if(0 == type && type==currentway[0]){
				// это стопудово активный пешок
				if(alone){
					newstr += '<span class="delim">' + way[0]+' '+sklonit(METER_WORD,way[0])+'</span>';
				}
				else{
					newstr += '<em>' + way[0]+' '+sklonit(METER_WORD,way[0])+'</em>';
				}
			}
			else if(type==currentway[0] && way[0]==currentway[1]){
				// это наш мегамаршрут
				if(6==type){
					var tmpname;
					if(way[0].length<17){
						tmpname = way[0];
					}
					else{
						tmpname = shortways[way[0]];
					}
					if(alone){
						newstr += '<span class="delim"'+hoverFeatures+'>'+tmpname+' '+LINE_STRING+'</span>';
					}
					else{
						newstr += '<em'+hoverFeatures+'>'+tmpname+' '+LINE_STRING+'</em>';
					}
				}
				else{
					if(alone){
						newstr += '<span class="delim"'+hoverFeatures+'>'+way[0]+'</span>';
					}
					else{
						newstr += '<em'+hoverFeatures+'>'+way[0]+'</em>';
					}
				}
			}
			else{
				if(0 == type){
					// пешок
					if(realUnitNum==0){
						var na = way[0];
						var nb = 0;
					}
					else{
						var na = 0;
						var nb = way[0];
					}
					newstr += '<span class="delim">' 
						+ way[0]+' '+sklonit(METER_WORD,way[0])+'</span>';
				}
				else{
					if(6==type){
						var tmp = ' '+LINE_STRING;
						if(way[0].length>=17){
							way[0] = shortways[way[0]];
						}
					}
					else{
						var tmp = '';
					}
					// или не пешок
					newstr += '<span  class="delim"'+hoverFeatures+'>'
					+way[0]+tmp+'</span>';
				}
			}
			if(i<len-1){
				newstr += '<span class="delim">,</span> ';
			}
		}
		return newstr;
	};
	parseSuperStringForPrint=function(str,currentway,unitNum,realUnitNum,routeNum,target){
		// функция парсит мегастроку для печати без ссылок
		var newstr = '';
		var transports = str.split(';');
		var ways = new Array();
		var len = transports.length;
		var currentway = currentway.split(':');

		var last = null;
		var first = null;
		if(len>1 && transports[len-1].charAt(0)=='5'){
			last = transports.pop();
		}
		if(len>1 && transports[0].charAt(0)=='0'){
			first = transports.shift();
		}
		if(first!=null){
			transports.push(first);
		}
		if(last!=null){
			transports.unshift(last);
		}

		for(var i=0;i<len;i++){
			ways = transports[i].split(':');
			if(ways[1].indexOf(',')>-1){
				typename = types1[ways[0]]+': ';
			}
			else{
				if(0==ways[0]){
					typename = types[ways[0]]+': ';
				}
				else if(ways[0]>5){
					typename = '';
				}
				else{
					typename = types[ways[0]]+' ';
				}
			}


			if((len==1 && ways[1].indexOf(',')<0) || ways[0]!=currentway[0]){
				newstr += '<span class="delim">'+typename+'</span>';
			}
			else if(ways[0]==currentway[0]){
				//newstr += '<em>'+typename+'</em>';
				newstr += '<span class="delim">'+typename+'</span>';
			}

			newstr += parseMiniUnitsForPrint(ways[1],ways[0],currentway,unitNum,realUnitNum,routeNum,target,(len==1 && ways[1].indexOf(',')<0))+' ';
			if(i!=len-1){
				newstr += '<br/>';
			}
		}

		return newstr;
	}
	parseSingleWay=function(str){
		// функция парсит строку вида "5:60м в строку вида маршрутка 60м"
		var way = str.split(':');
		var newstr = types[way[0]]+' '+way[1]+' ';
		return newstr;
	};
	parseSeveralWays=function(str){
		// функция парсит строку вида "5: 30м, 21м;4: 12, 13" в строку вида "маршрутки: 30м, 21м <br/>троллейбусы: 12,13 "
		var newstr = '';
		var transports = str.split(';');
		var ways = new Array();
		var len = transports.length;

		// маршрутки толкаем наверх, если они есть
		if(len>1 && transports[len-1].charAt(0)=='5'){
			var tmp = transports.pop();
			transports.unshift(tmp);
		}

		for(var i=0;i<len;i++){
			ways = transports[i].split(':');
			if(ways.length==1){
				newstr += ways[0];
			}
			else if(ways[1].indexOf(',')>-1){
				newstr += types1[ways[0]]+': '+ways[1]+' ';
			}
			else{
				newstr += types[ways[0]]+' '+ways[1]+' ';
			}
			if(i!=len-1){
				newstr += '<br/>';
			}
		}
		return newstr;
	};
	parseTraffic=function(str){
		// парсим строку с пробками
		// <3:60>Ленинский проспект::МКАД--улица Миклухо-Маклая<2:0><1:0>
		str = str.replace(/--/g,' &rarr; ');

		var pos1 = str.indexOf('>');
		var higProc = parseInt(str.substring(3,pos1)); // вырезали кол-во процентов уровня 3
		var pos2 = str.indexOf('<2:');
		var high = str.substring(pos1+1,pos2); // вырезали строку с пробками для уровня 3
		var tmpstr = str.substring(pos2,str.length);
		if(higProc>=100){
			higProc = 100;
		}

		pos1 = tmpstr.indexOf('>');
		var midProc = parseInt(tmpstr.substring(3,pos1)); // вырезали кол-во процентов уровня 2
		pos2 = tmpstr.indexOf('<1:');
		var medium = tmpstr.substring(pos1+1,pos2); // вырезали строку с пробками для уровня 2
		tmpstr = tmpstr.substring(pos2,tmpstr.length);

		if(higProc+midProc>100){
			if(higProc>50){
				higProc -= (higProc+midProc-100);
			}
			else{
				midProc -= (higProc+midProc-100);
			}
		}

		pos1 = tmpstr.indexOf('>');
		var lowProc = parseInt(tmpstr.substring(3,pos1)); // вырезали кол-во процентов уровня 2
		var low = tmpstr.substring(pos1+1,tmpstr.length); // вырезали строку с пробками для уровня 1

		if(higProc+midProc+lowProc>100){
			if(higProc>30){
				higProc -= (higProc+midProc+lowProc-100);
			}
			else if(midProc>30){
				midProc -= (higProc+midProc+lowProc-100);
			}
			else{
				lowProc -= (higProc+midProc+lowProc-100);
			}
		}

		var noProc = 100 - lowProc - midProc - higProc;

		var traf = '';
		var tmp = null;
		var innertmp = null;


		traf += '<strong class="ministrong">'+UNIT_STRUCTURE+'</strong>';
		traf += '<div class="graph">'+
		'<div class="higtraf" style="width:'+higProc+'px"></div>'+
		'<div class="midtraf" style="width:'+midProc+'px"></div>'+
		'<div class="lowtraf" style="width:'+lowProc+'px"></div>'+
		'<div class="notraf" style="width:'+noProc+'px"></div>'+
		'</div>';
		if(noProc>0){
			traf += '<small>'+MINI_FREE_WAY+' — <em class="notraf_">'+noProc+'%</em></small><br/>';
		}
		if(lowProc>0){
			traf += '<small>'+MINI_WORD_JAMS_LOW+' — <em class="lowtraf_">'+lowProc+'%</em></small><br/>';
		}
		if(midProc>0){
			traf += '<small>'+MINI_WORD_JAMS_MEDIUM+' — <em class="midtraf_">'+midProc+'%</em></small><br/>';
		}
		if(higProc>0){
			traf += '<small>'+MINI_WORD_JAMS_HIGH+' — <em class="higtraf_">'+higProc+'%</em></small><br/>';
		}

		if(high!=''){
			traf += '<strong>'+WORD_JAMS_HIGH+'</strong>';
			tmp = high.split(';;');
			for(var i=0;i<tmp.length;i++){
				innertmp = tmp[i].split('::')
				traf +='<span>'+innertmp[0]+'</span>'+'<small>'+innertmp[1]+'</small>';
			}
		}
		if(medium!=''){
			traf += '<strong>'+WORD_JAMS_MEDIUM+'</strong>';
			tmp = medium.split(';;');
			for(var i=0;i<tmp.length;i++){
				innertmp = tmp[i].split('::')
				traf +='<span>'+innertmp[0]+'</span>'+'<small>'+innertmp[1]+'</small>';
			}
		}
		if(low!=''){
			traf += '<strong>'+WORD_JAMS_LOW+'</strong>';
			tmp = low.split(';;');
			for(var i=0;i<tmp.length;i++){
				innertmp = tmp[i].split('::')
				traf +='<span>'+innertmp[0]+'</span>'+'<small>'+innertmp[1]+'</small>';
			}
		}


		return traf;
	};
	sklonit=function(word,number)
	{
		var mod10=number%10;
		var mod100=number%100;
		if(number==0)
		{
			return words[word][2]
		}
		else if(mod100>=11&&mod100<=20)
		{
			return words[word][2]
		}
		else if(mod10==2||mod10==3||mod10==4)
		{
			return words[word][1]
		}
		else if(mod10==1)
		{
			return words[word][0]
		}
		else
		{
			return words[word][2]
		}
	};
	printLink=function(xml, num, all)
	{
		var form = document.createElement("form"), tmp;
		form.action = "print/";
		form.method = "post";
		form.target = "_blank";
		form.id = "__id_print_form";
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "xml";
		tmp.value = getCurrentRoutesXML();
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "num";
		tmp.value = num;
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "pointAaddr";
		tmp.value = getPointAaddr();
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "pointBaddr";
		tmp.value = getPointBaddr();
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "pointAlat";
		tmp.value = getPointA().getLatLng().lat();
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "pointAlng";
		tmp.value = getPointA().getLatLng().lng();
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "pointBlat";
		tmp.value = getPointB().getLatLng().lat();
		form.appendChild(tmp);
		tmp = document.createElement("input");
		tmp.type = "hidden";
		tmp.name = "pointBlng";
		tmp.value = getPointB().getLatLng().lng();
		form.appendChild(tmp);
		if (all != null)
		{
			tmp = document.createElement("input");
			tmp.type = "hidden";
			tmp.name = "printAll";
			tmp.value = all;
			form.appendChild(tmp);
		}
		document.body.appendChild(form);
		form.submit();
	}
	this.getPictures=function()
	{
		var a='';
		var counter=1;
		for(var i=0;i<=unitCount;i++)	
		{
			//не показываем переходы в метро
			if (i==unitCount || (i==0 || this.getUnitType(i-1)!=6 || this.getUnitType(i)!=6) && this.getUnitType(i)!=0)
			{
				a += '<div id="piccont' + (i + 1) + '" class="piccont"><div class="picnum">'+ counter++ +'</div><div class="picpic" id="picture' + (i + 1) + '" style="width: 300px; height: 300px; overflow: hidden"></div><div class="picclose"><img alt="&darr;" src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/closewindow-mini.gif" onclick=\"gid(\'piccont' + (i + 1) + '\').style.display=\'none\';\"/></div></div>';
			}
		}

		return a
	};
	this.drawMaps=function(Alat, Alng, Blat, Blng)
	{
		gmInitIcons();
		for(var i=0;i<=unitCount;i++)	
		{
			//Get coordinates
			var lat, lng, pointfrom, pointto, descfrom, addrfrom, wayfrom, textfrom, iconfrom, descto, addrto, wayto, textto, iconto;
			if (i==0)
			{
				pointfrom = new GLatLng(Alat, Alng);
				descfrom = START_POINT;
				addrfrom = '';
				wayfrom = '';
				textfrom = '';
				iconfrom = 'begpoint.gif';
			}
			else if (this.getUnitType(i-1)!=0)
			{
				var num = Number(this.getPointCount(i-1));
				lat = this.getPLat(i-1,num);
				lng = this.getPLng(i-1,num);
				pointfrom = new GLatLng(lat, lng);
				descfrom = this.getPName(i-1, num);
				addrfrom = this.getPAddress(i-1, num);
				wayfrom = this.getMapWayName(i-1);
				textfrom = this.getPTextStyle(i-1);
				iconfrom = this.getPMapIconLink(i-1,num);
			}

			if (i==unitCount)
			{
				pointto = new GLatLng(Blat, Blng);
				descto = DESTINATION_POINT;
				addrto = '';
				wayto = '';
				textto = '';
				iconto = 'endpoint.gif';
			}
			else if (this.getUnitType(i)!=0)
			{
				lat = this.getPLat(i,0);
				lng = this.getPLng(i,0);
				pointto = new GLatLng(lat, lng);
				descto = this.getPName(i, 0);
				addrto = this.getPAddress(i, 0);
				wayto = this.getMapWayName(i);
				textto = this.getPTextStyle;
				iconto = this.getPMapIconLink(i,0);
			}

			//не показываем переходы в метро
			if (i==unitCount || (i==0 || this.getUnitType(i-1)!=6 || this.getUnitType(i)!=6) && this.getUnitType(i)!=0)
			{
				var map = new GMap2(document.getElementById("picture" + (i + 1)));
				map.disableDragging();

				var bounds = new GLatLngBounds();
				bounds.extend(pointfrom);
				bounds.extend(pointto);
				map.setCenter(bounds.getCenter());
				map.setZoom(map.getBoundsZoomLevel(bounds));
				map.addControl(new GSmallZoomControl()-1);

				//draw points
				if (i==0 || iconfrom == 'begpoint.gif')
				{
					gmAddPoint(map,pointfrom,'','','orig',false,true,false);
				}
				else
				{
					gmAddCheckpoint(map,pointfrom,descfrom,addrfrom,wayfrom,textfrom,iconfrom,false,true,false);
				}

				if (i==unitCount)
				{
					gmAddPoint(map,pointto,'','','dest',false,true,false);
				}
				else
				{
					gmAddCheckpoint(map,pointto,descto,addrto,wayto,textto,iconto,false,true,false);
				}
			}
		}
	};
	this.showRouteOnMap=function(Alat, Alng, Blat, Blng)
	{
		gmInitIcons();
		var allowPolylines=true;
		if(navigator){
			if(navigator.appName=='Opera'){
				allowPolylines = false;
			}
		}

		var map = new GMap2(document.getElementById("bigmap"));
		map.setCenter(new GLatLng(CITY_LAT[CITYID__],CITY_LNG[CITYID__]),CITY_ZOOM[CITYID__]);
		map.disableDragging();

		p=new Array();
		polylines=new Array();
		var b=this.getUnitCount();
		//var pointBeg = null;
		var pointA = new GLatLng(Alat, Alng);
		var pointB = new GLatLng(Blat, Blng);
		
		gmAddPoint(map,pointA,'','','orig',false,true,false);
		gmAddPoint(map,pointB,'','','dest',false,true,false);
		
		var pointBeg = pointA;
		for(var i=0;i<b;i++)
		{
			if(this.getUnitType(i)!=0){
				var c=this.getMapWayName(i);
				var d=this.getPointCount(i);
				for(var j=0;j<=d;j++)
				{
					var e=new GLatLng(this.getPLat(i,j),this.getPLng(i,j));
					p.push(gmAddCheckpoint(map,e,this.getPName(i,j),this.getPAddress(i,j),c,this.getPTextStyle(i),this.getPMapIconLink(i,j)));

					if((i>0 || j>0) && pointBeg!=pointA && allowPolylines){
						polylines.push(new GPolyline([pointBeg,e], "#ff0000", 5));
						map.addOverlay(polylines[polylines.length-1]);//dfdf
					}
					else if(i==0 && j==0 && pointBeg!=pointA && allowPolylines){
						polylines.push(new GPolyline([pointA,e], "#ff0000", 5));
						map.addOverlay(polylines[polylines.length-1]);//dsfdsf
					}
					pointBeg = e;
				}
			}
		}
		if(pointBeg==null){
			pointBeg = pointA;
		}
		polylines.push(new GPolyline([pointBeg,pointB], "#ff0000", 5));
		
		if(allowPolylines){
			//map.addOverlay(polylines[polylines.length-1]);//dsfdsfdsf
		}
		
		var bounds = new GLatLngBounds();
		for (var i=0; i< p.length; i++) {
			bounds.extend(p[i].getPoint());
		}
		bounds.extend(pointA);
		bounds.extend(pointB);
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter());
	};
	this.getText=function(plainText, start, finish)
	{
		plainText = plainText==null?false:plainText;
		start = start==null?START_POINT:start;
		finish = finish==null?DESTINATION_POINT:finish;
		var counter = 1;
		var countStr = '';
		var a = '<div class="unit begpoint">'+
		'<div><img alt="&darr;" src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/begpoint.gif"/></div>'+
		'<strong>'+start+'</strong>'+'</div>';
		if(unitCount==0 || units[0][0][_waytype]==0){
			a += '<div class="arrow specarrow"><small>&nbsp;</small></div>';
		}
		else{
			countStr = plainText==false?'<div class="arrownum">'+ counter++ +'</div>':'';
			a += countStr + '<div class="arrow specarrow"><small>'+walk1+' '+sklonit(METER_WORD,walk1)+' '+BY_WALK+'</small></div>';
		}
		var b=0;
		for(var i=0;i<unitCount;i++)
		{
			var firstAddress = this.getFirstAddress(i);
			var _wayname = units[i][0][_htmlwaynameforprint];

			if(units[i][0][_waytype]==0){
				a+=	'<div class="unit '+units[i][0][_linelink]+'">'+
				'<div class="toppoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+
				units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'<div class="toppointinfo">'+'<strong>&nbsp;</strong>'+
				'</div>'+
				'<div class="unitinfo">'+
				'<h6>'+_wayname+'</h6>'+
				'</div>'+
				'<div class="botpointinfo">'+'<strong>&nbsp;</strong>'+
				'</div>'+
				'<div class="botpoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'</div>';
			}
			else{
				// полноценные юниты
				var trafDesc = this.getTrafDesc(i);

				b=units[i].length-1;
				a+=	'<div class="unit '+units[i][0][_linelink]+this.getTrafClass(i)+'">'+
				'<div class="toppoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+
				units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'<div class="toppointinfo"><strong>'+units[i][1][_name]+'</strong>'+
				firstAddress+
				'</div>'+
				'<div class="unitinfo">'+
				'<h6>'+_wayname+'</h6>'+
				trafDesc+
				'</div>'+
				'<div class="botpointinfo"><strong>'+units[i][b][_name]+'</strong>'+
				'</div>'+
				'<div class="botpoint"><img src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/'+units[i][0][_htmliconlink]+'" alt="*"/></div>'+
				'</div>';
			}
			if(i!=unitCount-1)
			{
				if( units[i+1] && this.getUnitType(i+1)==0){
					a+='<div class="arrow">'+'<small>&nbsp;</small>'+'</div>';
				}
				else if(this.getUnitType(i)==0){
					countStr = plainText==false?'<div class="arrownum">'+ counter++ +'</div>':'';
					a+=countStr + '<div class="arrow">'+'<small>&nbsp;</small>'+'</div>';
				}
				else if(this.getUnitType(i)!=6 || this.getUnitType(i+1)!=6)
				{
					countStr = plainText==false?'<div class="arrownum">'+ counter++ +'</div>':'';
					a+=countStr + '<div class="arrow">'+'<small>'+units[i+1][0][_walkbefore]+' '+sklonit(METER_WORD,units[i+1][0][_walkbefore])+' '+BY_WALK+'</small>'+'</div>'
				}
				else{
					a+='<div class="arrow">'+'<small>'+units[i+1][0][_walkbefore]+' '+sklonit(METER_WORD,units[i+1][0][_walkbefore])+' '+BY_WALK+'</small>'+'</div>'
				}
			}
		}
		if(unitCount==0 || units[unitCount-1][0][_waytype]==0){
			countStr = plainText==false?'<div class="arrownum">'+ counter++ +'</div>':'';
			a += countStr + '<div class="arrow specarrow"><small>&nbsp;</small></div>';
		}
		else{
			countStr = plainText==false?'<div class="arrownum">'+ counter++ +'</div>':'';
			a += countStr + '<div class="arrow specarrow"><small>'+walk2+' '+sklonit(METER_WORD,walk2)+' '+BY_WALK+'</small></div>';
		}
		a += '<div class="unit endpoint">'+
		'<div><img alt="&darr;" src="'+RES_ROOT+'images/'+RES_FOLDER+'/'+IMAGES_ROOT+'/icons/endpoint.gif"/></div>'+
		'<strong>'+finish+'</strong>'+'</div>';
		return a;
	};
}