var icons=[];
var _mSvgEnabled=true;
var _mSvgForced=true;

function ymCreateMap(a,zoom,lng,lat)
{
	zoom=zoom==null?13:zoom;
	lng=lng==null?55.757287:lng;
	lat=lat==null?37.620217:lat;
	var e=new YMaps.Map(gid(a));
	e.addControl(new YMaps.Zoom());
	e.addControl(new YMaps.TypeControl());
	e.setCenter(new YMaps.GeoPoint(lng,lat),zoom);
		
	ymInitIcons();
	return e
};
function ymDrawCircle(a,b,c,d)
{
};
function ymAddPointCheckUse(a,b,c,d,e,f,g,h,i)
{
	g=g==null?'simple':g;
	if(f==0)
	{
		g='tat-unchecked'
	}
	else
	{
		g='tat'
	}
	h=h==null?false:h;
	if(h==false)
	{
		var j=new YMaps.Placemark(c, {style: icons[g],hideIcon:false});
	}
	else
	{
		var j=new YMaps.Placemark(c, {style: icons[g],draggable:true,hideIcon:false});
		j.enableDragging();
		YMaps.Events.observe(j,j.Events.DragEnd,function()
		{
			gid('newid').value=b;
			gid('newname').value=d;
			gid('newaddr').value=e;
			gid('inuse').value=f;
			gid('newlat').value=j.getPoint().lat();
			gid('newlng').value=j.getPoint().lng();
			gid('checkpointid').value=i
		}
		)
	}
	var k='<b>'+d+'</b>'+'<br/>'+e;
	YMaps.Events.observe(j,j.Events.Click,function()
	{
		j.setBalloonOptions({maxWidth:250});
		j.setBalloonContent(k);
		gid('newid').value=b;
		gid('newname').value=d;
		gid('newaddr').value=e;
		gid('inuse').value=f;
		gid('newlat').value=j.getPoint().lat();
		gid('newlng').value=j.getPoint().lng();
		gid('checkpointid').value=i
	}
	);
	return j
};
function ymAddPointSpec(a,b,c,d,e,f,g,h,i)
{
	h=h==null?'simple':h;
	i=i==null?false:i;
	if(i==false)
	{
		var j=new YMaps.Placemark(c, {style: icons[h],hideIcon:false});
	}
	else
	{
		var j=new YMaps.Placemark(c, {style: icons[h],draggable:true,hideIcon:false});
		j.enableDragging();
		YMaps.Events.observe(j,j.Events.DragEnd,function(){
			gid('newid').value=b;
			if(gid('switchid')){
				gid('switchid').value=b;
			}
			gid('newname').value=f;
			gid('newaddr').value=g;
			gid('newlat').value=j.getPoint().lat();
			gid('newlng').value=j.getPoint().lng();
		});
	}
	var k='<b>'+e+': '+d+'</b>'+'<br/>'+f+'<br/>'+g;
	YMaps.Events.observe(j,j.Events.Click,function()
	{
		j.setBalloonOptions({maxWidth:250});
		j.setBalloonContent(k);
		gid('newid').value=b;
		if(gid('switchid')){
			gid('switchid').value=b;
		}
		gid('newname').value=f;
		gid('newaddr').value=g;
		gid('newlat').value=j.getPoint().lat();
		gid('newlng').value=j.getPoint().lng()
	}
	);
	return j
};
function ymAddPointSimple(a,b,c,d,e)
{
	d=d==null?'simple':d;
	e=e==null?false:e;
	if(e==false)
	{
		var f=new YMaps.Placemark(b, {style: icons[d],hideIcon:false,hideIcon:false});
	}
	else
	{
		var f=new YMaps.Placemark(b, {style: icons[d],draggable:true,hideIcon:false,hideIcon:false});
	}
	var g='<b>'+c+'</b>';
	YMaps.Events.observe(f,f.Events.Click,function()
	{
		f.setBalloonOptions({maxWidth:250});
		f.setBalloonContent(g)
	}
	);
	a.addOverlay(f);
	return f
};
function ymAddCheckpoint(a,b,c,d,e,f,g,h,i)
{
	h=h==null?false:h;
	i=i==null?true:i;
	var j=ymCreateIcon(g);
	if(h==false)
	{
		var k=new YMaps.Placemark(b, {style: icons[j],hideIcon:false,hideIcon:false});
	}
	else
	{
		var k=new YMaps.Placemark(b, {style: icons[j],draggable:true,hideIcon:false});
	}
	var l='<div id="bubble"><h1 class="'+f+'">'+e+'</h1>'+'<strong>'+c+'</strong><br/>'+'<small>'+d+'</small></div>';
	YMaps.Events.observe(k,k.Events.Click,function()
	{
		k.setBalloonOptions({maxWidth:250});
		k.setBalloonContent(l)
	}
	);
	if(i)
	{
		a.addOverlay(k)
	}
	return k
};
function ymAddPoint(map,coords,c,d,iconStyle,flag,g)
{
	g=g==null?true:false;
	iconStyle=iconStyle==null?'simple':iconStyle;
	flag=flag==null?false:flag;
	if(flag==false)
	{
		var point_=new YMaps.Placemark(coords, {style: icons[iconStyle],hideIcon:false});
	}
	else
	{
		var point_=new YMaps.Placemark(coords,{style:icons[iconStyle], draggable:true, hideIcon:false});
		if(iconStyle=='orig'){
			YMaps.Events.observe(point_,point_.Events.DragEnd,function(){gid('aFromText').value = 0;});
		}
		else if(iconStyle=='dest'){
			YMaps.Events.observe(point_,point_.Events.DragEnd,function(){gid('bFromText').value = 0;});
		}
	}
	var i='<div id="bubble"><strong>'+c+'</strong></div>';
	YMaps.Events.observe(point_,point_.Events.Click,function()
	{
		point_.setBalloonOptions({maxWidth:250});
		point_.setBalloonContent(i)
	}
	);
	if(g)
	{
		map.addOverlay(point_)
	}
	return point_
};
function ymReadMarker(a,b,c)
{
	var d=b.getAttribute("way")+"<br/>"+b.getAttribute("name");
	var e=b.getAttribute("address");
	var f=new YMaps.GeoPoint(parseFloat(b.getAttribute("lng")),parseFloat(b.getAttribute("lat")));
	return ymAddPoint(a,f,d,e,c)
};
function ymReadMarkerSpec(a,b,c,d)
{
	var e=c+"<br/>"+b.getAttribute("name");
	var f=b.getAttribute("address");
	var g=new YMaps.GeoPoint(parseFloat(b.getAttribute("lng")),parseFloat(b.getAttribute("lat")));
	return ymAddPoint(a,g,e,f,d)
};
function ymCreateIcon(a)
{
	var custom = new YMaps.Style();
	custom.iconStyle = new YMaps.IconStyle();
	custom.iconStyle.offset = new YMaps.Point(-6,-10);
	custom.iconStyle.href = RES_ROOT+'images/msk/'+IMAGES_ROOT+'/icons/'+a;
	custom.iconStyle.size = new YMaps.Point(20,20);
	YMaps.Styles.add("rusavtobus#custom", custom);
	icons['custom']=custom;
	return 'custom'
};
function ymInitIcons()
{
	var simple = new YMaps.Style();
	simple.iconStyle = new YMaps.IconStyle();
	simple.iconStyle.offset = new YMaps.Point(-5,-1);
	simple.iconStyle.href = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
	simple.iconStyle.size = new YMaps.Point(12,20);
	simple.iconStyle.shadow = new YMaps.IconShadowStyle();
	simple.iconStyle.shadow.offset = new YMaps.Point(-5,-1);
	simple.iconStyle.shadow.href = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	simple.iconStyle.shadow.size = new YMaps.Point(22,20);
	YMaps.Styles.add("rusavtobus#simple", simple);
	icons['simple']=simple;
	icons['blue']=simple;

	var red = new YMaps.Style();
	red.iconStyle = new YMaps.IconStyle();
	red.iconStyle.offset = new YMaps.Point(-6,-20);
	red.iconStyle.href = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
	red.iconStyle.size = new YMaps.Point(12,20);
	red.iconStyle.shadow = new YMaps.IconShadowStyle();
	red.iconStyle.shadow.offset = new YMaps.Point(-6,-20);
	red.iconStyle.shadow.href = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	red.iconStyle.shadow.size = new YMaps.Point(22,20);
	YMaps.Styles.add("rusavtobus#red", red);
	icons['red']=red;

	var dest = new YMaps.Style();
	dest.iconStyle = new YMaps.IconStyle();
	dest.iconStyle.offset = new YMaps.Point(-15,-30);
	dest.iconStyle.href = RES_ROOT+'images/msk/'+IMAGES_ROOT+'/icons/endpoint.gif';
	dest.iconStyle.size = new YMaps.Point(30,30);
	YMaps.Styles.add("rusavtobus#dest", dest);
	icons['dest']=dest;
	
	var green = new YMaps.Style();
	green.iconStyle = new YMaps.IconStyle();
	green.iconStyle.offset = new YMaps.Point(-6,-20);
	green.iconStyle.href = 'http://labs.google.com/ridefinder/images/mm_20_green.png';
	green.iconStyle.size = new YMaps.Point(12,20);
	green.iconStyle.shadow = new YMaps.IconShadowStyle();
	green.iconStyle.shadow.offset = new YMaps.Point(-6,-20);
	green.iconStyle.shadow.href = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	green.iconStyle.shadow.size = new YMaps.Point(22,20);
	YMaps.Styles.add("rusavtobus#green", green);
	icons['green']=green;
	
	var orig = new YMaps.Style();
	orig.iconStyle = new YMaps.IconStyle();
	orig.iconStyle.offset = new YMaps.Point(-15,-30);
	orig.iconStyle.href = RES_ROOT+'images/msk/'+IMAGES_ROOT+'/icons/begpoint.gif';
	orig.iconStyle.size = new YMaps.Point(30,30);
	YMaps.Styles.add("rusavtobus#orig", orig);
	icons['orig']=orig;

	var tat = new YMaps.Style();
	tat.iconStyle = new YMaps.IconStyle();
	tat.iconStyle.offset = new YMaps.Point(-6,-20);
	tat.iconStyle.href = RES_ROOT+'images/msk/'+IMAGES_ROOT+'/icons/tat.gif';
	tat.iconStyle.size = new YMaps.Point(20,20);
	YMaps.Styles.add("rusavtobus#tat", tat);
	icons['tat']=tat;

	var tat_unchecked = new YMaps.Style();
	tat_unchecked .iconStyle = new YMaps.IconStyle();
	tat_unchecked .iconStyle.offset = new YMaps.Point(-6,-20);
	tat_unchecked .iconStyle.href = RES_ROOT+'images/msk/'+IMAGES_ROOT+'/icons/tat-unchecked .gif';
	tat_unchecked .iconStyle.size = new YMaps.Point(20,20);
	YMaps.Styles.add("rusavtobus#tat-unchecked", tat_unchecked );
	icons['tat-unchecked']=tat_unchecked;
	
	var line_style = new YMaps.Style();
	line_style.lineStyle = new YMaps.LineStyle();
	line_style.lineStyle.strokeColor = 'FF0000FF';
	line_style.lineStyle.strokeWidth = '5';
	YMaps.Styles.add("rusavtobus#LineStyle", line_style);
};
function CDownloadUrl(b,c,d)
{
	var e;
	var f=navigator.appName;
	if(f.indexOf("Microsoft")>-1)e=new ActiveXObject("Microsoft.XMLHTTP");
	else e=new XMLHttpRequest();
	e.open(b,c,true);
	e.setRequestHeader('X-Requested-With','XMLHtpRequest');
	e.setRequestHeader('Accept','txt/html');
	e.onreadystatechange=function()
	{
		if(e.readyState==4)
		{
			if(e.status==200)
			{
				var a=e.getResponseHeader('Content-Type');
				if(a.indexOf('xml')>-1)
				{
					d(e.responseText)
				}
				else
				{
					d(e.responseText)
				}
			}
			else
			{
				d('Error: '+e.status)
			}
		}
	};
	e.send(null)
};
function gid(a)
{
	return document.getElementById(a)
};
function getbyid(a)
{
	return document.getElementById(a)
};
function GUnload(){};
