var map;var map_m;var geocoder;var geodan=new google.maps.LatLng(genY,genX);function map_main(){geodan=new google.maps.LatLng(genY,genX);var a={zoom:genZ,center:geodan,noClear:true,mapTypeControl:false,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE,google.maps.MapTypeId.HYBRID,google.maps.MapTypeId.TERRAIN,"OSM","YMAP","YSAT","YHYB","BMAP","BSAT","BHYB"],style:google.maps.MapTypeControlStyle.DROPDOWN_MENU}};map=new google.maps.Map(document.getElementById("map_div"),a);var b=document.getElementById("map");google.maps.event.addListener(map,"center_changed",function(){var f=map.getMapTypeId();var c=map.getCenter();var d=map.getZoom();var e=c.lng()+","+c.lat()+","+d+","+f;setCookie("cPosit",e)});google.maps.event.addListener(map,"zoom_changed",function(){var f=map.getMapTypeId();var c=map.getCenter();var d=map.getZoom();var e=c.lng()+","+c.lat()+","+d+","+f;setCookie("cPosit",e)});$("#SET_GMAP").click(function(){map.setMapTypeId(google.maps.MapTypeId.ROADMAP)});$("#SET_GSAT").click(function(){map.setMapTypeId(google.maps.MapTypeId.SATELLITE)});$("#SET_GHYB").click(function(){map.setMapTypeId(google.maps.MapTypeId.HYBRID)});map.mapTypes.set("OSM",osmMapType);$("#SET_OSM").click(function(){map.setMapTypeId("OSM")});map.mapTypes.set("YMAP",yandexMapType);map.mapTypes.set("YSAT",yandexSatType);map.mapTypes.set("YHYB",yandexHybType);$("#SET_YMAP").click(function(){map.setMapTypeId("YMAP")});$("#SET_YSAT").click(function(){map.setMapTypeId("YSAT")});$("#SET_YHYB").click(function(){map.setMapTypeId("YHYB")});map.mapTypes.set("BMAP",bingMapType);map.mapTypes.set("BSAT",bingSatType);map.mapTypes.set("BHYB",bingHybType);$("#SET_BMAP").click(function(){map.setMapTypeId("BMAP")});$("#SET_BSAT").click(function(){map.setMapTypeId("BSAT")});$("#SET_BHYB").click(function(){map.setMapTypeId("BHYB")});map.setMapTypeId(genT);google.maps.LatLng.prototype.m_distanceFrom=function(g){var i=this.lat();var n=i*(Math.PI/180);var q=this.lng();var c=q*(Math.PI/180);var h=g.lat();var l=h*(Math.PI/180);var o=g.lng();var r=o*(Math.PI/180);var j=6378.1;var k=(n-l);var m=(c-r);var e=Math.sin(k/2);var f=Math.sin(m/2);var p=Math.pow(e,2)+Math.cos(n)*Math.cos(l)*Math.pow(f,2);var d=j*2*Math.asin(Math.min(1,Math.sqrt(p)));return d};$("#loading").bind("ajaxSend",function(){$(this).show()}).bind("ajaxComplete",function(){$(this).hide()});$("#getLink").click(function(){$.colorbox({opacity:0.5,html:'<p align="center">http://'+window.location.hostname+window.location.pathname+"?lng="+map.getCenter().lng()+"&lat="+map.getCenter().lat()+"&z="+map.getZoom()+"&t="+map.getMapTypeId()+"</p>"})})}var osmMapType=new google.maps.ImageMapType({getTileUrl:function(b,a){return"http://tile.openstreetmap.org/"+a+"/"+b.x+"/"+b.y+".png"},tileSize:new google.maps.Size(256,256),isPng:true,alt:"OpenStreetMap layer",name:"OpenStreetMap",maxZoom:18});var yandexMapType=new google.maps.ImageMapType({getTileUrl:function(b,a){return"http://vec0"+((b.x+b.y)%5)+".maps.yandex.net/tiles?l=map&v=2.16.0&x="+b.x+"&y="+b.y+"&z="+a+""},tileSize:new google.maps.Size(256,256),isPng:true,alt:"Яндекс карта",name:"Яндекс карта",maxZoom:18,minZoom:3,opacity:0.9});var yandexSatType=new google.maps.ImageMapType({getTileUrl:function(d,c){return"http://sat0"+((d.x+d.y)%5)+".maps.yandex.net/tiles?l=sat&v=1.26.0&x="+d.x+"&y="+d.y+"&z="+c+""},tileSize:new google.maps.Size(256,256),isPng:true,alt:"Яндекс Спутник",name:"Яндекс Спутник",maxZoom:18,minZoom:3,opacity:0.9});var yandexHybType=new google.maps.ImageMapType({getTileUrl:function(d,c){return"http://vec0"+((d.x+d.y)%5)+".maps.yandex.net/tiles?l=skl&v=2.12.1&x="+d.x+"&y="+d.y+"&z="+c+""},tileSize:new google.maps.Size(256,256),isPng:true,alt:"Яндекс Гибрид",name:"Яндекс Гибрид",maxZoom:18,minZoom:3,opacity:0.9});var bingMapType=new google.maps.ImageMapType({getTileUrl:function(d,c){return"http://a"+((d.x+d.y)%4)+".ortho.tiles.virtualearth.net/tiles/r"+GetVeName(d.x,d.y,c+1)+".png?g=353"},tileSize:new google.maps.Size(256,256),isPng:true,alt:"Bing Карта",name:"Bing Карта",maxZoom:18,minZoom:3,opacity:0.9});var bingSatType=new google.maps.ImageMapType({getTileUrl:function(d,c){return"http://a"+((d.x+d.y)%4)+".ortho.tiles.virtualearth.net/tiles/a"+GetVeName(d.x,d.y,c+1)+".jpeg?g=80"},tileSize:new google.maps.Size(256,256),isPng:true,alt:"Bing Спутник",name:"Bing Спутник",maxZoom:18,minZoom:3,opacity:0.9});var bingHybType=new google.maps.ImageMapType({getTileUrl:function(d,c){return"http://a"+((d.x+d.y)%4)+".ortho.tiles.virtualearth.net/tiles/h"+GetVeName(d.x,d.y,c+1)+".jpeg?g=80"},tileSize:new google.maps.Size(256,256),isPng:true,alt:"Bing Гибрид",name:"Bing Гибрид",maxZoom:18,minZoom:3,opacity:0.9});function atanh(a){return 0.5*Math.log((1+a)/(1-a))}var MERCATOR_RANGE=256;function degreesToRadians(a){return a*(Math.PI/180)}function radiansToDegrees(a){return a/(Math.PI/180)}function bound(b,a,c){if(a!=null){b=Math.max(b,a)}if(c!=null){b=Math.min(b,c)}return b}function YandexProjection(){this.pixelOrigin_=new google.maps.Point(128,128);this.pixelsPerLonDegree_=MERCATOR_RANGE/360;this.pixelsPerLonRadian_=MERCATOR_RANGE/(2*Math.PI)}YandexProjection.prototype.fromLatLngToPoint=function(f){var e=this;var a=new google.maps.Point(0,0);var c=e.pixelOrigin_;var d=bound(Math.sin(degreesToRadians(f.lat())),-0.9999,0.9999);a.x=c.x+f.lng()*e.pixelsPerLonDegree_;var b=0.0818197;var g=Math.sin(f.lat()/180*Math.PI);a.y=Math.abs(c.y-e.pixelsPerLonRadian_*(atanh(g)-b*atanh(b*g)));return a};YandexProjection.prototype.fromPointToLatLng=function(i){var f=this;var h=f.pixelOrigin_;var g=(i.x-h.x)/f.pixelsPerLonDegree_;var b=(i.y-h.y)/-f.pixelsPerLonRadian_;var e=Math.abs((2*Math.atan(Math.exp(b))-Math.PI/2)*180/Math.PI);var c=e/(180/Math.PI);var j=c+1;var a=0.0818197;var d=-Math.abs(((i.y)-128));while(Math.abs(j-c)>1e-7){j=c;c=Math.asin(1-((1+Math.sin(j))*Math.pow(1-a*Math.sin(j),a))/(Math.exp((2*d)/-(256/(2*Math.PI)))*Math.pow(1+a*Math.sin(j),a)))}if(i.y>256/2){e=-c*180/Math.PI}else{e=c*180/Math.PI}return new google.maps.LatLng(e,g)};yandexMapType.projection=new YandexProjection();yandexSatType.projection=new YandexProjection();yandexHybType.projection=new YandexProjection();function GetVeName(g,f,e){var d="";var b=Math.floor(Math.pow(2,e-1)/2);var a=Math.floor(Math.pow(2,e-1)/2);var j=b;var h=a;for(var c=2;c<=e;c++){j=Math.floor(j/2);h=Math.floor(h/2);if(g<b){b=b-j;if(f<a){a=a-h;d=d+"0"}else{a=a+h;d=d+"2"}}else{b=b+j;if(f<a){a=a-h;d=d+"1"}else{a=a+h;d=d+"3"}}}return d}function getCookie(b){var d=" "+document.cookie;var c=" "+b+"=";var e=null;var f=0;var a=0;if(d.length>0){f=d.indexOf(c);if(f!=-1){f+=c.length;a=d.indexOf(";",f);if(a==-1){a=d.length}e=unescape(d.substring(f,a))}}return(e)}function setCookie(b,c){var a=new Date();a.setMonth(a.getMonth()+1);document.cookie=b+"="+c+"; expires="+a.toUTCString()}function cboxlogin(){$.fn.colorbox({opacity:0.5,html:L_login_form})};
