
var Gmapa_map;
var Gmapa_polySR;
var Gmapa_geocoder;
var Gmapa_mapaId = "gMapa";
var Gmapa_zapnute_polySR = 0;
var Gmapa_zobrazenie = "ROADMAP";
var Gmapa_adresa_stred = "";
var Gmapa_stred = {
    Latitude: 49.2604644217204,
    Longitude: 17.369922437500023
}
var Gmapa_zoom = 7;
var Gmapa_typ_pre_system = "";
var Gmapa_vymaz_ozancene = false;
var Gmapa_body = [];
var Gmapa_body_znacky = [];
var Gmapa_body_text = [];
var Gmapa_zakladnyStred = new google.maps.LatLng(Gmapa_stred.Latitude,Gmapa_stred.Longitude);
//var nacitanieNastaveniMapy = false;
var Gmapa_casNacitaniaMapy = 2; //v sekundach
//var Gmapa_adresaPreSpracovanie= ObjektyAdresa;
var Gmapa_over_funkcia=0;
var Gmapa_over_funkcia_class='over';

var Gmapa_zadavanieNovychBodov= false;
var Gmapa_scroll= false;
var Gmapa_infowindow;
var Gmapa_znacky = {
	zakladna: {
		url: "http://labs.google.com/ridefinder/images/mm_20_red.png"
	},
    google_velka: {url: "http://www.google.com/mapfiles/marker.png"},
	doprava: {url: "http://www.go-ok.eu/img/mapa_ikony/doprava.png"},
	gastro: {url: "http://www.go-ok.eu/img/mapa_ikony/gastro.png"},
	institucia: {url: "http://www.go-ok.eu/img/mapa_ikony/institucia.png"},
	kultura: {url: "http://www.go-ok.eu/img/mapa_ikony/kultura.png"},
    obchod_sluzby: {url: "http://www.go-ok.eu/img/mapa_ikony/sluzba.png"},
    ubytovanie: {url: "http://www.go-ok.eu/img/mapa_ikony/ubytovanie.png"},
	vzdelavanie: {url: "http://www.go-ok.eu/img/mapa_ikony/vzdelavanie.png"},
	sport: {url: "http://www.go-ok.eu/img/mapa_ikony/sport.png"},
    zdravotnictvo: {url: "http://www.go-ok.eu/img/mapa_ikony/zdravotnictvo.png"},
	multi: {url: "http://www.go-ok.eu/img/mapa_ikony/multiple.png"},
	cervena: {
		url: "http://www.go-ok.eu/img/mapa_ikony/spolocna.png"
	},
	zlta: {
        url: "http://www.go-ok.eu/img/mapa_ikony/spolocna.png"
		//url: "http://labs.google.com/ridefinder/images/mm_20_yellow.png"
	},
	tien: {
        url: 'http://www.go-ok.eu/img/mapa_ikony/shadow.png',
		//url: 'http://www.google.com/mapfiles/shadow50.png',
		//url: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png',
		anchor: '9,33'
		//anchor: '6,20'
	}
}

var Gmapa = Class.create({
	initialize: function() {
	},
	nacitaj: function(mapa_id) {
         mapa_id=(mapa_id=="" || mapa_id==null || mapa_id==undefined)?Gmapa_mapaId:mapa_id;

		geocoder = new google.maps.Geocoder();
		var myOptions = {
			zoom: Gmapa_zoom,
			mapTypeId: google.maps.MapTypeId.ROADMAP,
			navigationControl: true,
			mapTypeControl: true,
            scaleControl: true,
			scrollwheel: Gmapa_scroll
			//maxZoom: 7
		};
		map = new google.maps.Map($(mapa_id),myOptions);
		
		//ak bola zapnute zobrazenie SR
		if (Gmapa_zapnute_polySR==1) {
			this.zapniSR();
		}
		
		//nastavenie zobrazenia typu mapy
		this.nastavZobrazenie(Gmapa_zobrazenie);
		
		//ak bola zadana adresa stredu
		/*if (MP_adresa_stred!="") {
			this.najdiStred(MP_adresa_stred);
		}*/
		
		if (Gmapa_body.length) {
			var body2=Gmapa_body;
			var body_znacky2=Gmapa_body_znacky;
			Gmapa_body=[];
			Gmapa_body_znacky=[];
			for (i=0; i<body2.length; i++) {
				this.nakresliBod(body_znacky2[i].getPosition(),Gmapa_over_funkcia,body2[i].Znacka,body2[i].BublinaNie);
				if (Gmapa_body_text[i]) {
					var bod_na_mape=body_znacky2[i];
					bod_na_mape.setTitle(Gmapa_body_text[i].Nadpis);
				}
			}
		}
		if (Gmapa_zadavanieNovychBodov) {
			google.maps.event.addListener(map,'click',function(event){
				Gmapa.vymazVsetkyBody();
				Gmapa.nakresliUpravitelnyBod(event.latLng);
			});
		}
		/*google.maps.event.addListener(map,'dragend',function(event){
			MP_stred={
				Latitude: map.getCenter().lat(),
				Longitude: map.getCenter().lng()
			}
			Mapa.ulozNastaveniaDoSession();
		});
		google.maps.event.addListener(map,'zoom_changed',function(event){
			MP_zoom=map.getZoom();
			Mapa.ulozNastaveniaDoSession();
		});*/
		if (Gmapa_stred) {
			map.setCenter(new google.maps.LatLng(Gmapa_stred.Latitude,Gmapa_stred.Longitude));
		}
		//this.ulozNastaveniaDoSession();
	},
	nacitajSuradniceForm: function(pole,top) {
		if (top=="top") {
			if (window.parent.document.getElementById(pole) &&	window.parent.document.getElementById(pole).value!="") {
				hodnota=window.parent.document.getElementById(pole).value;
			}
			else {
				hodnota=0;
			}
		}
		else {
			if ($(pole) &&	$(pole).value!="") {
				hodnota=$(pole).value;
			}
			else {
				hodnota=0;
			}
		}
		if (hodnota!=0) {
			if ((hodnota.indexOf(".")>(-1) || hodnota.indexOf(",")>(-1)) && hodnota.indexOf(";")>(-1)) {
				pole_hodnot=hodnota.split(";");
				if (pole_hodnot.length==2) {
					if (pole_hodnot[0].indexOf(",")>(-1)) { pole_hodnot[0]=pole_hodnot[0].replace(",", "."); }
					if (pole_hodnot[1].indexOf(",")>(-1)) { pole_hodnot[1]=pole_hodnot[1].replace(",", "."); }
					var Gmapa_stred = {
						Latitude: pole_hodnot[0],
						Longitude: pole_hodnot[1]
					}
					//map.setCenter(new google.maps.LatLng(Gmapa_stred.Latitude,Gmapa_stred.Longitude));
					this.nakresliUpravitelnyBod(new google.maps.LatLng(pole_hodnot[0],pole_hodnot[1]));
				}
			}
		}
	},
	vytiahniSR: function() {
		if (Gmapa_zapnute_polySR!=1) {
			this.zapniSR();
			Gmapa_zapnute_polySR=1;
			//this.ulozNastaveniaDoSession();
		}
		else {
			this.zrusSR();
		}
	},
	zapniSR: function() {
		polySR = new google.maps.Polygon(
		{
			fill: true,
			outline: true,
			paths: [velky_stvorec_Coords,slovensko_Coords],
			strokeColor: "#000",
			strokeOpacity: 0.8,
			strokeWeight: 1,
			fillColor: "#000",
			fillOpacity: 0.35
		});
		polySR.setMap(map);
	},
	zrusSR: function() {
		if (MP_zapnute_polySR==1) {
			polySR.setMap(null);
			MP_zapnute_polySR=0;
			this.ulozNastaveniaDoSession();
		}
	},
	nastavZobrazenie: function(typ) {
		switch (typ) {
			case "ROADMAP": map.setMapTypeId(google.maps.MapTypeId.ROADMAP); break;
			case "SATELLITE": map.setMapTypeId(google.maps.MapTypeId.SATELLITE); break;
			case "HYBRID": map.setMapTypeId(google.maps.MapTypeId.HYBRID); break;
			case "TERRAIN": map.setMapTypeId(google.maps.MapTypeId.TERRAIN); break;
		}
		Gmapa_zobrazenie=typ;
		//this.ulozNastaveniaDoSession();	
	},
	najdiStred: function (zadana_adresa,pole_suradnic) {
		if (zadana_adresa!="") {
			geocoder.geocode( { 'address': zadana_adresa}, function(results, status) {
				if (status == google.maps.GeocoderStatus.OK) {
					map.setCenter(results[0].geometry.location);
					//Mapa.ulozNastaveniaDoSession();
				}
			});
		}
	},
	najdiBod: function (zadana_adresa) {
		if (zadana_adresa!="") {
			geocoder.geocode( { 'address': zadana_adresa}, function(results, status) {
				if (status == google.maps.GeocoderStatus.OK) {
					map.setCenter(results[0].geometry.location);
					Gmapa.nakresliUpravitelnyBod(results[0].geometry.location);
					map.setZoom(16);
				}
			});
		}
	},
	najdiCisloBoduPodlaZnacky: function(znacka) {
		var index=-1;
		for (i=0; i<Gmapa_body.length; i++) {
			if (Gmapa_body[i].Latitude==znacka.getPosition().lat() && Gmapa_body[i].Longitude==znacka.getPosition().lng()) {
				index=i;
				break;
			}
		}
		return index;
	},
	nakresliBod: function (bodLatLng,over_funkcia,znacka,bublina_nie) {
		if (bodLatLng=="" || bodLatLng==null || bodLatLng==undefined) {
			var myLatlng = zakladnyStred
		}
		else {
			var myLatlng = bodLatLng;
		}
		
		if (znacka=="" || znacka==null || znacka==undefined) {
			ikona=Gmapa.obrazokBodu(Gmapa_znacky.zakladna.url,Gmapa_znacky.zakladna.size,Gmapa_znacky.zakladna.anchor)
		}
		else {
			ikona=Gmapa.obrazokBodu(znacka.url,znacka.size,znacka.anchor);
		}
		var marker = new google.maps.Marker({
			position: myLatlng, 
			draggable: false,
			map: map,
			icon: ikona,
			shadow: Gmapa.obrazokBodu(Gmapa_znacky.tien.url,Gmapa_znacky.tien.size,Gmapa_znacky.tien.anchor)
		});
		
        if (bublina_nie==1) {}
        else {
		    google.maps.event.addListener(marker,'click',function(){
                map.setCenter(myLatlng);
                Gmapa.bublinaBodu(marker);
		    });
        }
		
		if (over_funkcia) {
			google.maps.event.addListener(marker,'mouseover',function(){
				Gmapa.prefarbiBodVZozname(marker);
			});
			google.maps.event.addListener(marker,'mouseout',function(){
				Gmapa.prefarbiBodVZozname(marker);
			});
		}
		
		//vytvorenie objektu noveho bodu
		var novyBod = {
			Latitude: myLatlng.lat(),
			Longitude: myLatlng.lng(),
            Znacka: znacka
		};
		//objekt noveho bodu pridany k ostatnym bodom
		Gmapa_body.push(novyBod);
		Gmapa_body_znacky.push(marker);
	},
	nakresliUpravitelnyBod: function (bodLatLng,update) {
		if (bodLatLng=="" || bodLatLng==null || bodLatLng==undefined) {
			var myLatlng = zakladnyStred
		}
		else {
			var myLatlng = bodLatLng;
		}
		var marker = new google.maps.Marker({
			position: myLatlng, 
			draggable: true,
			map: map
		});
		
		google.maps.event.addListener(marker,'drag',function(event){
			Gmapa.upravSuradniceBodu(marker,event.latLng)
		});
		google.maps.event.addListener(marker,'click',function(){
			Gmapa.ovladanieBodu(marker);
		});
		
		//zacentruj mapu na vytvoreny bod
		map.setCenter(myLatlng);
		
		//vytvorenie objektu noveho bodu
		var novyBod = {
			Latitude: myLatlng.lat(),
			Longitude: myLatlng.lng()
		};
		//objekt noveho bodu pridany k ostatnym bodom
		Gmapa_body.push(novyBod);
		Gmapa_body_znacky.push(marker);
		
	},
	obrazokBodu: function (url,size,anchor) {
		if (size=="" || size==null || size==undefined) { size=""; }
		else {
			size_pole=size.split(",");
			size=new google.maps.Size(size_pole[0],size_pole[1]);
		}
		if (anchor=="" || anchor==null || anchor==undefined) { anchor=""; }
		else {
			anchor_pole=anchor.split(",");
			anchor=new google.maps.Point(anchor_pole[0],anchor_pole[1]);
		}
		bod_obrazok=new google.maps.MarkerImage(url,size,'',anchor);
		return bod_obrazok;
	},
	prefarbiBod: function (index,obrazok) {
		bod=Gmapa_body_znacky[index];
		bod.setIcon(obrazok);
	},
	prefarbiBodVZozname: function (bod) {
		if (Gmapa_over_funkcia_class!="" && $('gid_'+this.najdiCisloBoduPodlaZnacky(bod))) {
			Wcms.prefarbiAktualnuPolozku($('gid_'+this.najdiCisloBoduPodlaZnacky(bod)));
		}
	},
	vypisBody: function() {
		var vyp="";
		for (i=0; i<Gmapa_body.length; i++) {
			vyp+="i:"+i+", "+Gmapa_body[i].Latitude+", "+Gmapa_body[i].Longitude+"\n";
		}
		alert(vyp);
	},
	priblizBod: function(bod,zoom) {
		map.setCenter(new google.maps.LatLng(Gmapa_body[bod].Latitude,Gmapa_body[bod].Longitude));
		if (zoom>0) {
			map.setZoom(zoom);
		}
	},
	vypisBod: function(index) {
		var vyp;
		if (Gmapa_body[index]) {
			vyp=Gmapa_body[index].Latitude+";"+Gmapa_body[index].Longitude;
		}
		return vyp;
	},
	vypisBodDoFrom: function(index,pole,okno,hlasenie) {
		if (okno=="top") {
			if (window.parent.document.getElementById(pole)) {
				window.parent.document.getElementById(pole).value=this.vypisBod(index);
				if (hlasenie) { alert(l_mapa_uloz_suradnice_ulozene); }
			}
		}
		else {
			if ($(pole)) {
				$(pole).value=this.vypisBod(index);
				if (hlasenie) { alert(l_mapa_uloz_suradnice_ulozene); }
			}
		}
	},
	upravSuradniceBodu: function(bod,suradnice_n) {
		var Lat_n=suradnice_n.lat();
		var Lng_n=suradnice_n.lng();
		
		//vytvorenie novych suradnic bodu
		var novyBod = {
			Latitude: Lat_n,
			Longitude: Lng_n
		};
		var index=this.najdiZnacku(bod);
		if (index>(-1)) {
			Gmapa_body[index]=novyBod;
		}
	},
	najdiZnacku: function(bod) {
		var index=-1;
		for (i=0; i<Gmapa_body_znacky.length; i++) {
			if (Gmapa_body_znacky[i]==bod) {
				index=i;
				break;
			}
		}
		return index;
	},
	ovladanieBodu: function(bod) {
		if (Gmapa_vymaz_ozancene==true) {
			this.vymazBod(bod);
		}
		else {
			cislo_bodu=this.najdiZnacku(bod);
			if (Gmapa_body_text[cislo_bodu]) {
				popis=Gmapa_body_text[cislo_bodu].Popis;
				nadpis=Gmapa_body_text[cislo_bodu].Nadpis
			}
			else {
				popis="";
				nadpis="";
			}
			obsah="<div style=\"width: 300px; height: 100px;\">";
			obsah+="<b>"+l_mapa_body_suradnice_bodu+"</b><br />";
			obsah+=l_mapa_body_zem_sirka+": "+Gmapa_body[cislo_bodu].Latitude+"<br />";
			obsah+=l_mapa_body_zem_dlzka+": "+Gmapa_body[cislo_bodu].Longitude+"<br /><br />";
			obsah+="<p class=\"content-buttons form-buttons\" style=\"margin: 0; padding: 0;\">";
			obsah+="<button type=\"button\" class=\"scalable save\" onclick=\"Gmapa.vypisBodDoFrom("+cislo_bodu+",pole,'top');Wcms.skriRam('top');return false;\" style=\"\"><span>"+l_mapa_uloz_suradnice+"</span></button>";
			obsah+="</p>";
			obsah+="</div>";
			var infowindow= new google.maps.InfoWindow({
				position: bod.getPosition(),
				content: obsah,
				pixelOffset: new google.maps.Size(0,-20)
			});
			infowindow.open(map);
		}
	},
	bublinaBodu: function(bod) {
		if (Gmapa_infowindow) {
			Gmapa_infowindow.close();
		}
		
		cislo_bodu=this.najdiZnacku(bod);
		if (Gmapa_body_text[cislo_bodu]) {
			popis=Gmapa_body_text[cislo_bodu].Popis;
			nadpis=Gmapa_body_text[cislo_bodu].Nadpis
		}
		else {
			popis="";
			nadpis="";
		}
		t_obsah="<div>";
		//obsah+=nadpis+"<br />";
		t_obsah+=popis;
		t_obsah+="</div>";
		Gmapa_infowindow= new google.maps.InfoWindow({
			position: bod.getPosition(),
			content: t_obsah,
			pixelOffset: new google.maps.Size(0,-10)
		});
		Gmapa_infowindow.open(map);
	},
	zapniVymazavanieOznacenychBodov: function(t) {
		Gmapa_vymaz_ozancene=Gmapa_vymaz_ozancene?false:true;
	},
	vymazBod: function(bod) {
		if (Gmapa_vymaz_ozancene) {
			bod.setMap(null);
			index=this.najdiZnacku(bod);
			if (index>(-1)) {
				Gmapa_body.splice(index, 1);
				Gmapa_body_znacky.splice(index, 1);
				Gmapa_body_text.splice(index, 1);
			}
		}
	},
	vymazVsetkyBody: function() {
		
		/*c=confirm(l_mapa_body_vymazavanie_vsetky_naozaj+"?");
		if (c==true) {*/
			var bod;
			for (i=Gmapa_body.length-1; i>=0; i=i-1) {
				bod=Gmapa_body_znacky[i];
				bod.setMap(null);
				Gmapa_body.splice(i, 1);
				Gmapa_body_znacky.splice(i, 1);
				Gmapa_body_text.splice(i, 1);
			}
		//}
	},
	ulozTextBodu: function(id_bodu,nadpis,popis) {
		var novyBod = {
			Nadpis: nadpis,
			Popis: popis
		};
		if (body_text[id_bodu]) {
			body_text[id_bodu]=novyBod;
		}
		else {
			body_text.push(novyBod);
		}
		var bod_na_mape=body_znacky[id_bodu];
		bod_na_mape.setTitle(nadpis);
		
		//this.ulozNastaveniaDoSession();
		
		alert(l_ulozene);
	},
	ulozNastaveniaDoSession: function() {
		Wcms.aktivujLoad()
		var polozky=[];
		polozky.push(Builder.node('input',{type:'hidden',name:'p',value:'gmapa'}));
		polozky.push(Builder.node('input',{type:'hidden',name:'zobraz_sr',value: MP_zapnute_polySR}));
		polozky.push(Builder.node('input',{type:'hidden',name:'zobrazenie',value: MP_zobrazenie}));
		polozky.push(Builder.node('input',{type:'hidden',name:'adresa_stred',value: MP_adresa_stred}));
		polozky.push(Builder.node('input',{type:'hidden',name:'stred_x',value: MP_stred.Latitude}));
		polozky.push(Builder.node('input',{type:'hidden',name:'stred_y',value: MP_stred.Longitude}));
		polozky.push(Builder.node('input',{type:'hidden',name:'zoom',value: map.getZoom()}));
		for (i=0; i<body.length; i++) {
			polozky.push(Builder.node('input',{type:'text',name:'bod_x_'+i,value:body[i].Latitude}));
			polozky.push(Builder.node('input',{type:'text',name:'bod_y_'+i,value:body[i].Longitude}));
			if (body_text[i]) {
				polozky.push(Builder.node('textarea',{name:'bod_n_'+i,id:'bod_n_'+i,value:body_text[i].Nadpis,text:body_text[i].Nadpis}));
				polozky.push(Builder.node('textarea',{name:'bod_p_'+i,id:'bod_p_'+i,value:body_text[i].Popis}));
			}
		}
				
		
		el=Builder.node('form',{id:'mapa_form',style:'display:none'},[polozky]);
		$('dM_mapy').appendChild(el);
		for (i=0; i<body.length; i++) {
			if (body_text[i]) {
				$('bod_n_'+i).value=body_text[i].Nadpis;
				$('bod_p_'+i).value=body_text[i].Popis;
			}
		}
		new Ajax.Request(adresaPreSpracovanie,{
			onSuccess: function(transport) {
				$('mapa_form').remove();
				Wcms.deaktivujLoad()
			},
			parameters: $('mapa_form').serialize()+'&id='+Sid+'&typ='+MP_typ_pre_system
		});
	},
	nacitajSession: function(get) {
		new Ajax.Request(Gmapa_adresaPreSpracovanie+"?"+get,{
			onSuccess: function(transport) {
				//$('mapa_form').remove();
				//Wcms.deaktivujLoad()
				xml_nastavenia=transport.responseXML;
                //alert(transport.responseText);
                if (xml_nastavenia.getElementsByTagName('Gmapa_zapnute_polySR')[0].firstChild.data!="null") {
				    Gmapa_zapnute_polySR = xml_nastavenia.getElementsByTagName('Gmapa_zapnute_polySR')[0].firstChild.data;
                }
                if (xml_nastavenia.getElementsByTagName('Gmapa_zobrazenie')[0].firstChild.data!="null") {
				    Gmapa_zobrazenie = xml_nastavenia.getElementsByTagName('Gmapa_zobrazenie')[0].firstChild.data;
                }
                if (xml_nastavenia.getElementsByTagName('Gmapa_adresa_stred')[0].firstChild.data!="null") {
				    Gmapa_adresa_stred = xml_nastavenia.getElementsByTagName('Gmapa_adresa_stred')[0].firstChild.data
                }
                if (xml_nastavenia.getElementsByTagName('Gmapa_stred_lat')[0].firstChild.data!="null") {
				    Gmapa_stred = {
					    Latitude: xml_nastavenia.getElementsByTagName('Gmapa_stred_lat')[0].firstChild.data,
					    Longitude: xml_nastavenia.getElementsByTagName('Gmapa_stred_lng')[0].firstChild.data
				    }
                }
                if (xml_nastavenia.getElementsByTagName('Gmapa_zoom')[0].firstChild.data!="null") {
				    Gmapa_zoom = Wcms.vratCislo(xml_nastavenia.getElementsByTagName('Gmapa_zoom')[0].firstChild.data);
                }
                if (xml_nastavenia.getElementsByTagName('Gmapa_vymaz_ozancene')[0].firstChild.data!="null") {
				    Gmapa_vymaz_ozancene = xml_nastavenia.getElementsByTagName('Gmapa_vymaz_ozancene')[0].firstChild.data;
                }
				Gmapa_body=[];
				Gmapa_body_znacky=[];
				Gmapa_body_text=[];
				z_body=xml_nastavenia.getElementsByTagName('body');
				for (i=0; i<z_body[0].childNodes.length; i++) {
                    bod=[];
                    bod={
						Latitude: z_body[0].childNodes[i].childNodes[0].firstChild.data,
						Longitude: z_body[0].childNodes[i].childNodes[1].firstChild.data
						//Znacka: eval(z_body[0].childNodes[i].childNodes[2].firstChild.data)
					}
                    if (z_body[0].childNodes[i].childNodes.length>=3) {
                        eval("bod.Znacka="+z_body[0].childNodes[i].childNodes[2].firstChild.data);
                    }
                    if (z_body[0].childNodes[i].childNodes.length>=4) {
                        eval("bod.Tien="+z_body[0].childNodes[i].childNodes[3].firstChild.data);
                    }
                    //alert(bod.Znacka.url+"\n"+bod.Znacka.size)
					Gmapa_body.push(bod);
				}
				z_body_znacky=xml_nastavenia.getElementsByTagName('body_znacky');
				for (i=0; i<z_body_znacky[0].childNodes.length; i++) {
					Gmapa_body_znacky.push(new google.maps.Marker({position: new google.maps.LatLng(z_body_znacky[0].childNodes[i].childNodes[0].firstChild.data,z_body_znacky[0].childNodes[i].childNodes[1].firstChild.data)}));
				}
				z_body_text=xml_nastavenia.getElementsByTagName('body_text');
				for (i=0; i<z_body_text[0].childNodes.length; i++) {
					Gmapa_body_text.push({
						Nadpis: z_body_text[0].childNodes[i].childNodes[0].firstChild.data,
						Popis: z_body_text[0].childNodes[i].childNodes[1].firstChild.data
					});
				}
				//Gmapa_zakladnyStred = new google.maps.LatLng(Gmapa_stred.Latitude,Gmapa_stred.Longitude);
				
				if (xml_nastavenia.getElementsByTagName('over_funkcia')[0].firstChild.data>0) {
					Gmapa_over_funkcia=1;
				}
                if (xml_nastavenia.getElementsByTagName('nacitaj_mapu')[0].firstChild.data>0) {
                    Gmapa.nacitaj();
                }
				if (xml_nastavenia.getElementsByTagName('nacitaj_bod')[0].firstChild.data>0) {
                    cislo_bodu=xml_nastavenia.getElementsByTagName('nacitaj_bod')[0].firstChild.data-1;
					Gmapa.priblizBod(cislo_bodu,13);
                    Gmapa.bublinaBodu(Gmapa_body_znacky[cislo_bodu]);
				}
			},
			parameters: 'p=gmapa_nastavenia&'
		});
	},
	nacitajDoSession: function(typ) {
		Wcms.aktivujLoad()
		var Gmapa_typ_pre_system=typ;
		new Ajax.Request(Gmapa_adresaPreSpracovanie,{
			onSuccess: function(transport) {
                //alert(transport.responseText);
				Wcms.deaktivujLoad();
                Gmapa.nacitajSession('id='+Sid+'&typ='+Gmapa_typ_pre_system);
			},
			parameters: 'p=gmapa_nacitaj_nastavenia&id='+Sid+'&typ='+Gmapa_typ_pre_system
		});
	},
	nacitajDoSessionAJs: function(typ) {
		this.nacitajDoSession(typ);
        //this.nacitajSession('id=a'+Sid+'&typ='+typ);
	},
	vypisSession: function() {
		Wcms.aktivujLoad()
		new Ajax.Request(Gmapa_adresaPreSpracovanie,{
			onSuccess: function(transport) {
				Wcms.deaktivujLoad()
				alert(transport.responseText);
			},
			parameters: 'p=gmapa_sess'
		});
	},
	vypisNastavenia: function() {
		al="Gmapa_zapnute_polySR: "+Gmapa_zapnute_polySR+"\n";
		al+="Gmapa_zobrazenie: "+Gmapa_zobrazenie+"\n";
		al+="Gmapa_adresa_stred: "+Gmapa_adresa_stred+"\n";
		al+="Gmapa_stred: "+Gmapa_stred.Latitude+","+Gmapa_stred.Longitude+"\n";
		al+="Gmapa_zoom: "+Gmapa_zoom+"\n";
		al+="Gmapa_vymaz_ozancene: "+Gmapa_vymaz_ozancene+"\n";
		al+="Gmapa_over_funkcia: "+Gmapa_over_funkcia+"\n";
		al+="Gmapa_body: "+Gmapa_body.length+"\n";
		al+="Gmapa_body_znacky: "+Gmapa_body_znacky.length;
		alert(al);
	}
});
var Gmapa = new Gmapa();
