// JavaScript Document
//<![CDATA[

	function createMarker(point, address) {
		var baseIcon = new GIcon();
		baseIcon.image = "/mysite/themes/bsq/images/marker.png";			
		baseIcon.shadow = "/mysite/themes/bsq/images/marker-shadow.png";
		baseIcon.iconSize = new GSize(32, 21);
		baseIcon.shadowSize = new GSize(32, 28);
		baseIcon.iconAnchor = new GPoint(0, 21);
		baseIcon.shadowAnchor = new GPoint(0, 21);
		baseIcon.infoWindowAnchor = new GPoint(13, 15);
		baseIcon.infoShadowAnchor = new GPoint(0, 0);
		//baseIcon.printImage = "http://www.doubleclique.com/simplify/images/marker-print.gif";
		//baseIcon.mozPrintImage = "http://www.doubleclique.com/simplify/images/marker-mozPrint.gif";
		//baseIcon.printShadow = "http://www.doubleclique.com/simplify/images/marker-shadow-print.gif";
		//baseIcon.transparent = "http://www.doubleclique.com/simplify/images/marker-transparent.png";
		
		markerOptions = { icon:baseIcon };
		var marker = new GMarker(point, markerOptions);
	
		GEvent.addListener(marker, "click", function() {
			//marker.openInfoWindowHtml('');			
		});
		return marker;
	}
	
	var Print = false;
	
	function initialize() {
		if (GBrowserIsCompatible()) {
			if(!Print){
				var map = new GMap2(document.getElementById("map_canvas"),
					{ size: new GSize(218,296) } );
					
				var mapControl = new GMapTypeControl();			
				map.addControl(mapControl);
				map.removeMapType(G_HYBRID_MAP);				
				map.addControl(new GSmallMapControl());
			}else{
				var map = new GMap2(document.getElementById("map_canvas"),
					{ size: new GSize(600,400) } );
				
				var mapControl = new GMapTypeControl();			
				map.removeControl(mapControl);
				map.removeMapType(G_HYBRID_MAP);
				map.removeMapType(G_SATELLITE_MAP);
				map.removeMapType(G_NORMAL_MAP);				
				map.removeControl(new GSmallMapControl());		
			}
					
			//========================================================
			//========================================================
			
			//map.setCenter(new GLatLng(45.58787, 9.480188),10);
			//var marker = new GMarker(new GLatLng(45.458787, 9.380188));
			//map.addOverlay(marker);			
			//marker.openInfoWindowHtml('');
			
			var geocoder = new GClientGeocoder();			
			function showAddress(address) {
				geocoder.getLatLng(
					address,
					function(point) {
						if (!point) {
							alert(address + " not found");
						} else {
							map.setCenter(point, 15);
							//var marker = new GMarker(point);
							var marker = createMarker(point, address);
							map.addOverlay(marker);	
							if(Print)
								marker.openInfoWindowHtml('<strong>Basquesse</strong><br/>Shop 4,<br/>95 Customhouse Quay<br/>Wellington<br/>CBD New Zealand');								
						}
					}
				);
			}
			showAddress('95 Customhouse Quay, Wellington, New Zealand');			
		}		
	}
	
	function printMap(){		
		var link = document.getElementById('PrintMap'); 
        
		if (Print) {
		    Print = false;
		    link.innerHTML = 'Print this map';
		} else {
		    Print = true;
		    link.innerHTML = 'Close this map';
		}		
		initialize();	
		
		if (Print) {
		    setTimeout(function(){window.print();},1000);
		}					
	}
	
	
	window.onload = initialize;
	
//]]>
