<link rel="stylesheet" href="<?php echo base_url(); ?>css/modules/maps.css" type="text/css" media="screen" title="default" />
				<!--<p style="margin-bottom: 10px;"><?php foreach($parents as $node){
					echo '<img src="'.base_url().'images/icon_arrow.png" align="baseline" style=" position:relative; top:4px;" /><a href="'.base_url().'admin/wyswietl/'.$node->id.'">'.$node->nodeData['name'].'</a>';
				 } 
				echo '<img src="'.base_url().'images/icon_arrow.png" align="baseline" style=" position:relative; top:4px;" /><a href="'.base_url().'admin/module/'.$this->uri->segment(3).'">'.$module->modules_name; ?></a> </p>
				
				-->
                <div class="breadcrumb ui-corner-tl ui-corner-tr">
                <div style="float:left; position:relative;"><img class="breadcrumbIcon" align="absmiddle"  src="<?php echo base_url();?>images/homePage.png" /><a href="<?php echo base_url(); ?>">Strona WWW</a><img src="<?php echo base_url(); ?>images/breadcrumbSeparator.png" align="absmiddle" style="" /></div>
                <?php
				$counter = count($parents);
				$count = 1;
				$lastNode = null;
				 foreach($parents as $node){
					 
					echo '<div class="contenerNodeBreadcrumb"><img src='.base_url().'images/newspaper.png align="absmiddle" class="breadcrumbIcon"><a href="'.base_url().'admin/wyswietl/'.$node->id.'">'.truncate($node->nodeData['name']).'</a>';
				//	if($counter==$count) echo '<img style="position:absolute; left:40%; top:32px;" src='.base_url().'images/pointer_breadcrumb.png /> ';
				
					echo '</div><img src="'.base_url().'images/breadcrumbSeparator.png"  align="absmiddle"  class="separatorBreadcrumb" />'; 
				 $count++;
				 $lastNode = $node; 
				 } 
				 echo '<div class="contenerNodeBreadcrumb"><img src="'.base_url().'images/brick_mini.png" align="absmiddle" class="breadcrumbIcon" /><a  href="'.base_url().'admin/module/'.$this->uri->segment(3).'">'.truncate($module->modules_name).'</a> <img class="pointerBreadcrumb" src='.base_url().'images/pointer_breadcrumb.png /></div>';
				?>
                <a href="<?php echo base_url()?>admin/wyswietl/<?php echo $lastNode->id ?>"><img src="<?=base_url(); ?>images/back_cms_main.png" border="0" style="float:right;"></a>
                </div>
				<script type="text/javascript"src="http://www.google.com/jsapi?key=ABQIAAAA8YqIQM3Q6Xw1EWcyyJ3hAhSig1buWRuaChAP8EijXW6f4YvbAhR-XJkLsYDP4hVtj9QF1VAu7DKO3w"></script>
				<script type="text/javascript"charset="utf-8">
				google.load("maps","2.x"); 
				$(document).ready(function(){ 
					 
					var map = new GMap2($("#map").get(0));
					var center = new GLatLng(52.231837,19.090576);  
					map.setUIToDefault();
					map.enableScrollWheelZoom();
					map.disableDoubleClickZoom();
					map.setCenter(center, 6); 
					//map.setMapType(G_SATELLITE_MAP );
					

					var bounds = new GLatLngBounds();
					var geo = new GClientGeocoder(); 
					

					var mapClick = GEvent.addListener(map, "dblclick", function(overlay, latlng, overlaylatlng){
						//alert(11);
						//alert(latlng.lng());
						var adres = '';
						geo.getLocations(latlng, function(result){
							if (result.Status.code == G_GEO_SUCCESS) {
								adres = adres+result.Placemark[0].address;
								//alert(result.Placemark[0].address);
								addLocation(latlng.lat(), latlng.lng(), adres, '');
							} 
							
						});
						
						
					});
					//GEvent.removeListener(mapClick);
					
					/*var bounds = map.getBounds(); 
					var southWest = bounds.getSouthWest(); 
					var northEast = bounds.getNorthEast(); 
					var lngSpan = northEast.lng() - southWest.lng(); 
					var latSpan = northEast.lat() - southWest.lat(); 
					var markers = []; 
					for (var i = 0; i<10; i++) { 
					  var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random()); 
					  marker = new GMarker(point); 
					  map.addOverlay(marker); 
					  markers[i] = marker; 
					}

					$(markers).each(function(i,marker){ 
						GEvent.addListener(marker,"click", function(){ 
							displayPoint(marker, i); 
						}); 
						$("<li />") 
						  .html("Point"+i) 
						  .click(function(){ 
							  displayPoint(marker, i); 
						  }) 
						  .appendTo("#list");
					});*/

					//$("#message").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE));

					
					
					var reasons=[];
					reasons[G_GEO_SUCCESS]            = "Success";
					reasons[G_GEO_MISSING_ADDRESS]    = "Podaj adres";
					reasons[G_GEO_UNKNOWN_ADDRESS]    = "Nieznany adres";
					reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Adres niedostępny";
					reasons[G_GEO_BAD_KEY]            = "Zły API Key";
					reasons[G_GEO_TOO_MANY_QUERIES]   = "Zby duzo zapytań";
					reasons[G_GEO_SERVER_ERROR]       = "Błąd serwera";
						
					
					function displayPoint(marker, index){ 
						$("#message").hide(); 
						var moveEnd = GEvent.addListener(map,"moveend", function(){ 
							var markerOffset = map.fromLatLngToDivPixel(marker.getLatLng()); 
							$("#message") 
						      .fadeIn() 
						      .css({ top:markerOffset.y, left:markerOffset.x }); 
						  	GEvent.removeListener(moveEnd); 
						}); 
						map.panTo(marker.getLatLng()); 
					}

					$("#add-point").submit(function(){ 
						geoEncode(); //alert(1);
						$(this).find("input").val("");
						return false; 
					});

					$.getJSON("<?php echo base_url() ?>admin/getlocationsjson/<?php echo $this->uri->segment(3); ?>"
						, function(json) { 
						
						if(json.Locations.length>0){
							for(i=0; i<json.Locations.length; i++){
								var location = json.Locations[i];
								addLocation2(location.lat, location.lng, location.opis, location.tytul, location.id);
								/*var point = new GLatLng(location.lat, location.lng); 
								var marker = new GMarker(point); 
								map.addOverlay(marker); 
								bounds.extend(marker.getPoint()); 
								$("<li />")
								  .html(location.tytul+"<br/>"+location.opis+"<br/>") 
								  .click(function(){ 
								    //showMessage(marker, 'test'); 
								  	map.panTo(marker.getLatLng());
								  }) 
								  .prependTo("#list"); 
								GEvent.addListener(marker,"dblclick", function(){ 
								  //showMessage(this); 
								    
								  map.panTo(marker.getLatLng());
								});*/
							}
						}
					});

					function geoEncode() { 
						  $("#add-point .error").fadeOut();
						  var address = $("#add-point input[name=address]").val(); 
						  geo.getLocations(address, function (result){ 
						    if (result.Status.code == G_GEO_SUCCESS) { 
						      geocode = result.Placemark[0].Point.coordinates; 
						      //alert(geocode[1]+' '+geocode[0]);
						      //savePoint(geocode);
						      //var data = $("#add-point :input").serializeArray();
						      //data[data.length] = { name:"lng", value: geocode[0] }; 
						      //data[data.length] = { name:"lat", value: geocode[1] };
						      var location = {name:"lng", value: geocode[0]};
						      var location = {name:"lat", value: geocode[1]};
						      //var location = data; 
						      
						      var adres = '';
						      var latlng = new GLatLng(geocode[1], geocode[0]);
						      geo.getLocations(latlng, function(result){
									if (result.Status.code == G_GEO_SUCCESS) {
										adres = result.Placemark[0].address;
										//alert(result.Placemark[0].address);
										
										addLocation(geocode[1], geocode[0], adres, $("#add-point input[name=name]").val()); //zoomToBounds();
										
									} 
									
							  });
						      
						       
						    } else { 
						      var reason="Code"+result.Status.code; 
						      if (reasons[result.Status.code]) { 
						        reason = reasons[result.Status.code] 
						      } 
						      $("#add-point .error").html(reason).fadeIn(); 
						      geocode = false; 
						    } 
						  }); 
					}

					function addLocation(lat, lng, adres, tytul) { 
						  var point = new GLatLng(lat, lng); 
						  var marker = new GMarker(point); 
						  map.addOverlay(marker); 
						  bounds.extend(marker.getPoint()); 
						  //<input type='submit' value='Zapisz' />
						  var o = $("<li />")
						    .html("")
						    //<form action='<?php echo base_url(); ?>admin/savepoint' method='post' >Tytuł<br/><input type='hidden' name='module_id' value='<?php echo $this->uri->segment(3) ?>' /><input type='hidden' name='lat' value='"+lat+"' /><input type='hidden' name='lng' value='"+lng+"' /><input type='text' name='title' value='"+tytul+"' /><br/>Opis<br/><input type='text' name='desc' value='"+adres+"' /><br/><br/><a  class='submit button buttonBlack '><img src='<?php echo base_url()?>images/buttons/disc.png' />Zapisz</a></form> 
						    .click(function(){ 
						      //showMessage(marker, 'test'); 
						      
						    	map.panTo(marker.getLatLng());
						    	marker.openInfoWindowHtml("<h2>"+tytul+"</h2><p>"+adres+"</p>");
						    	
						    });
							o.effect("highlight", {}, 1500);
						    $("<form />")
						      .attr("action", "<?php echo base_url(); ?>admin/savepoint")
						      .attr("method", "post")
						      .html("<div class='markerInfoInput'>Tytuł<br/><input type='hidden' name='module_id' value='<?php echo $this->uri->segment(3) ?>' /><input type='hidden' name='lat' value='"+lat+"' /><input type='hidden' name='lng' value='"+lng+"' /><input type='text' name='title' value='"+tytul+"' /><br/>Opis<br/><input type='text' name='desc' value='"+adres+"' /></div><div class='buttonsPointsContener2'><a  title='zapisz punkt' class='submit button buttonLightGrey tooltip' style='margin-right:5px;'><img style='margin-right:0px;' src='<?php echo base_url()?>images/disk_mini.png' /></a></div>")
						      .submit(function(){
							      $.post(
									"<?php echo base_url()?>admin/savepointjson"
									, $(this).serialize(),
									function(data){
										//if(data.id > 0){
							    	  		map.removeOverlay(marker);
								      		o.remove();
								      		addLocation2(data.lat, data.lng, data.opis, data.tytul, data.id);
										//}
									}, "json");
							      	
							      return false;
							  })
						      .appendTo(o);

							  
							 
						    $("<span />").html("<div class='buttonsPointsContener2'><a title='usuń punkt' class='usunnews button buttonLightGrey tooltip' ><img style='margin-right:0px;' src='<?php echo base_url() ?>images/cancel.png'></a></div><br style='clear:both;'>")
						      .click(function(){
							      map.removeOverlay(marker);
							      $(this).parents("li").remove();
							      return false;
							  })
						      .appendTo(o.find("form"));
						    o.find('.tooltip').tipTip({maxWidth: "auto", edgeOffset: 3, defaultPosition: 'right',delay: 150 });
							   
						    o.prependTo("#listTemp"); 
						  GEvent.addListener(marker,"click", function(){ 
						    //showMessage(this); 
						    
							map.panTo(marker.getLatLng());
							marker.openInfoWindowHtml("<h2>"+tytul+"</h2><p>"+adres+"</p>");
							
						  }); 
						  map.panTo(marker.getLatLng());
					}
					
					function addLocation2(lat, lng, adres, tytul, id) { 
						  var point = new GLatLng(lat, lng); 
						  var marker = new GMarker(point); 
						  map.addOverlay(marker); 
						  bounds.extend(marker.getPoint()); 
						  var o = $("<li />")
						    .html("<div class='markerInfo'><span class='titleMarker'>"+tytul+"</span><br/><span class='adressMarker'>"+adres+"</span></div>") 
						    .click(function(){ 
						      //showMessage(marker, 'test'); 
						        
						    	map.panTo(marker.getLatLng());
						    	marker.openInfoWindowHtml("<h2>"+tytul+"</h2><p>"+adres+"</p>");
						    	
						    });
						  $("<span />")
						  	.html("<div class='buttonsPointsContener'><a title='usuń punkt' class='deleteMarkerButton button buttonLightGrey tooltip'  href='<?php echo base_url(); ?>admin/removelocation/"+id+"/<?php echo $this->uri->segment(3)?>'><img style='margin-right:0px;' src='<?php echo base_url() ?>images/bin.png'></a></div><br style='clear:both;'>")
						  	.click(function(){
							  	//alert($(this).find("a").attr("href"));
							  	var a = $(this);
							  	$.get($(this).find("a").attr("href"), function(data){
							  		map.removeOverlay(marker);
								    a.parents("li").remove();  	
								});
							  	
							  	return false;
							 })
						    .appendTo(o);  
						  o.prependTo("#list");
						 // alert('a');
						  
							  $('.tooltip').tipTip({maxWidth: "auto", edgeOffset: 3, defaultPosition: 'right',delay: 150 });
							
						  GEvent.addListener(marker,"click", function(){ 
						    //showMessage(this); 
						    
							map.panTo(marker.getLatLng());
							marker.openInfoWindowHtml("<h2>"+tytul+"</h2><p>"+adres+"</p>");
							
							
							
						  }); 
					}
					
				});
				</script>
				
				<form id="add-point"action="map-service.php"method="POST">
				  <input type="hidden"name="action"value="savepoint"id="action">
				  <fieldset class="ui-corner-all" >
				    <legend style="margin-left:10px; font-weight:bold;">Wyszukaj punkt na mapie</legend><div class="error" style="display:none;"></div>
                    <table width="" border="0"  class="searchPlace">
  <tr>
    <td><span class="input">
      <label for="name">Tytuł</label>: 
    </span></td>
    <td><span class="input">
      <input type="text" name="name" id="name" value="" />
    </span></td>
    <td rowspan="2"> <a title="dasdasd"  class="submit button buttonBlack tooltip"><img src="<?php echo base_url(); ?>images/buttons/disc.png" />Znajdź</a></td>
  </tr>
  <tr>
    <td>Adres*: </td>
    <td><span class="input">
      <input type="text" name="address" id="address" value="" />
    </span></td>
    </tr>
</table><br />

<p> Możesz również zaznaczyć punkt na mapie, klikając dwukrotnie w wybranym przez Ciebie miejscu na mapie</p>

			
				  </fieldset>
				</form>

				
				<div id="mapContener">
				<div id="map"></div>
				
				
				<ul id="listTemp"></ul>
				<ul id="list"></ul>
				</div>
	
				
				<div id="message"style="display:none;">Test text.</div>

				
                
              		
						
			
						
				