<?php
/**
* @version 1.0.0
* @package RSEvents! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined('_JEXEC') or die('Restricted access');
?>
<form action="index.php" method="post" name="adminForm2">
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $this->data['locations.gMaps.key'];?>" type="text/javascript"></script>
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=<?php echo $this->data['locations.gMaps.key'];?>" type="text/javascript"></script>
<script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js"  type="text/javascript"></script>

<style type="text/css">
	@import url("http://www.google.com/uds/css/gsearch.css");
	@import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
</style>
<script type="text/javascript">

	function addListener(element, baseName, handler) {
		if (element.addEventListener)
			element.addEventListener(baseName, handler, false);
		else if (element.attachEvent)
			element.attachEvent('on'+baseName,handler);
	}


	function initialize() {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map_class"),{mapTypes:[G_NORMAL_MAP]});
				
			var mapControl = new GMapTypeControl();
			map.addControl(mapControl);
			map.addControl(new GLargeMapControl());
			map.addControl(new GOverviewMapControl());
			//map.addControl(new GSmallMapControl());							
			
			var point = new GLatLng(<?php echo $this->data['locations.gMaps.center']; ?>);
			map.setCenter(new GLatLng(<?php echo $this->data['locations.gMaps.center']; ?>), 4);
			
			var myIcon = new GIcon();
			myIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
			myIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			myIcon.iconSize = new GSize(12, 20);
			myIcon.shadowSize = new GSize(22, 20);
			myIcon.iconAnchor = new GPoint(6, 20);
			myIcon.infoWindowAnchor = new GPoint(5, 1);		
			
			
			markerOptions = { icon:myIcon, draggable: true };							
			var marker = new GMarker(point, markerOptions);
			map.addOverlay(marker);
			
			GEvent.addListener(marker, "dragend", function() {
				document.getElementById("center").value = marker.getLatLng().lat()+','+marker.getLatLng().lng();
				map.setCenter(marker.getLatLng());
			});
			
			GEvent.addListener(map, "moveend", function(point) {
				document.getElementById("center").value = map.getCenter().lat()+','+map.getCenter().lng();
				marker.setPoint(map.getCenter());
			});
			
			GEvent.addListener(map, "zoomend", function(point) {
				document.getElementById("firstzoomlevel").value = map.getZoom();
			});
			

			
		}
	}
	
	addListener(window, 'load', initialize);
</script>
<div id="map_class" style="width: 480px; height: 300px;"></div>		
<br/>
<?php echo JText::_('RSE_MAP_CENTER'); ?> <input type="text" style="float:center" name="rseventsConfig[locations.gMaps.center]" id="center" size="40" maxlength="250" value="<?php echo $this->data['locations.gMaps.center'];?>" /> 
<button type="submit" onclick="window.parent.location.reload(true);window.top.setTimeout('window.parent.document.getElementById(\'sbox-window\').close()', 700);"><?php echo JText::_('RSE_SAVE_BTN'); ?></button>
<?php echo JHTML::_( 'form.token' ); ?>
<input type="hidden" name="task" value="saveCenter" />
<input type="hidden" id="firstzoomlevel" name="firstzoomlevel" value="4" />
<input type="hidden" name="option" value="com_rsevents" />
<input type="hidden" name="view" value="settings" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="controller" value="settings" />

<?php
//keep session alive while editing
JHTML::_('behavior.keepalive');
?>

</form>