
/* Scripts for Argos Yachtcharter GmbH
 * Copyright © 2002-2008 Inceoeren IT Consulting. All rights reserved. 
 */
 
var map;
 
function mapZoom( a )
{
	map.setZoom( map.getZoom() + a );
}

function mapLoad( x, y, z, maptitle)
{
	if( GBrowserIsCompatible() )
	{
		map = new GMap2( document.getElementById( "googleMap" ) );
		
		document.getElementById( "googleMap" ).style.backgroundColor="white";
		document.getElementById( "googleMapLabelDetail" ).innerHTML = maptitle;
		
		map.setCenter( new GLatLng( x, y ), z );
		map.setMapType( G_HYBRID_MAP );
		//map.addControl( new GSmallMapControl() );
		map.addControl( new GMapTypeControl() );
		map.addControl( new GScaleControl(50) );
		map.enableScrollWheelZoom();
		
		var tooltip = document.createElement( "div" );
		document.getElementById( "googleMap" ).appendChild( tooltip );
		tooltip.style.visibility="hidden";
		
        function markerIcon( type_id, dim_x, dim_y, anchor_x, anchor_y )
        {
        	var icon = new GIcon();
			icon.image = "http://www.argos-yachting.de/images/marker_"+type_id+".png";
			icon.iconSize = new GSize( dim_x, dim_y );
			icon.iconAnchor = new GPoint( anchor_x, anchor_y );
			icon.infoWindowAnchor = new GPoint( 5, 1 );
			return icon;
        }
                
        function createMarker( coords, zoom, type_id, dim_x, dim_y, anchor_x, anchor_y, html )
        {
        	var marker = new GMarker( coords, markerIcon( type_id, dim_x, dim_y, anchor_x, anchor_y ) );
        	
        	marker.tooltip = '<div class="googleMapTooltip"><p>'+html+'</p></div>';
        	
			GEvent.addListener( marker, "click", function()
			{
				tooltip.style.visibility="hidden"
				map.setCenter( coords );
				map.setZoom( zoom );
			} );
			
			GEvent.addListener( marker, "mouseover", function()
			{
				showTooltip( marker );
			} );
			
			GEvent.addListener( marker, "mouseout", function()
			{
				tooltip.style.visibility="hidden"
			} );

			return marker;
		}
				
		// initialize variables
		var gmarkers = new Array();
		var oceans = new Array();
		var harbours = new Array();
		var locations = new Array();
		
		harbours[0] = new Object();
harbours[0]['name'] = 'Alacati (Marina Alacati)';
harbours[0]['google_x'] = Number(38.25317846640115);
harbours[0]['google_y'] = Number(26.384568214416504);
harbours[0]['google_z'] = Number(16);
harbours[0]['type_id'] = '0';
harbours[0]['dim_x'] = 10;
harbours[0]['dim_y'] = 10;
harbours[0]['anchor_x'] = 1;
harbours[0]['anchor_y'] = 1;
harbours[0]['shown'] = true;
harbours[1] = new Object();
harbours[1]['name'] = 'Antalya (Celebi Marina)';
harbours[1]['google_x'] = Number(36.832860275134784);
harbours[1]['google_y'] = Number(30.60617208480835);
harbours[1]['google_z'] = Number(17);
harbours[1]['type_id'] = '0';
harbours[1]['dim_x'] = 10;
harbours[1]['dim_y'] = 10;
harbours[1]['anchor_x'] = 1;
harbours[1]['anchor_y'] = 1;
harbours[1]['shown'] = true;
harbours[2] = new Object();
harbours[2]['name'] = 'Bodrum (Milta Marina)<br><ul><li>Kiriacoulis</li><li>Pupa Yachting</li><li>Yildiz Yachting</li></ul>';
harbours[2]['google_x'] = Number(37.03421392812777);
harbours[2]['google_y'] = Number(27.424020767211914);
harbours[2]['google_z'] = Number(15);
harbours[2]['type_id'] = '0';
harbours[2]['dim_x'] = 10;
harbours[2]['dim_y'] = 10;
harbours[2]['anchor_x'] = 1;
harbours[2]['anchor_y'] = 1;
harbours[2]['shown'] = true;
harbours[3] = new Object();
harbours[3]['name'] = 'Bodrum (Stadthafen)<br><ul><li>SEAGULL</li></ul>';
harbours[3]['google_x'] = Number();
harbours[3]['google_y'] = Number();
harbours[3]['google_z'] = Number(0);
harbours[3]['type_id'] = '0';
harbours[3]['dim_x'] = 10;
harbours[3]['dim_y'] = 10;
harbours[3]['anchor_x'] = 1;
harbours[3]['anchor_y'] = 1;
harbours[3]['shown'] = true;
harbours[4] = new Object();
harbours[4]['name'] = 'Cesme (Marina)';
harbours[4]['google_x'] = Number(38.32159229272278);
harbours[4]['google_y'] = Number(26.30101203918457);
harbours[4]['google_z'] = Number(16);
harbours[4]['type_id'] = '0';
harbours[4]['dim_x'] = 10;
harbours[4]['dim_y'] = 10;
harbours[4]['anchor_x'] = 1;
harbours[4]['anchor_y'] = 1;
harbours[4]['shown'] = true;
harbours[5] = new Object();
harbours[5]['name'] = 'Datca (Stadthafen)';
harbours[5]['google_x'] = Number(36.722443435528334);
harbours[5]['google_y'] = Number(27.689194679260254);
harbours[5]['google_z'] = Number(16);
harbours[5]['type_id'] = '0';
harbours[5]['dim_x'] = 10;
harbours[5]['dim_y'] = 10;
harbours[5]['anchor_x'] = 1;
harbours[5]['anchor_y'] = 1;
harbours[5]['shown'] = true;
harbours[6] = new Object();
harbours[6]['name'] = 'Fethiye (Ece Marina)<br><ul><li>BBS Yachting</li><li>Yildiz Yachting</li></ul>';
harbours[6]['google_x'] = Number(36.62334653422068);
harbours[6]['google_y'] = Number(29.10175323486328);
harbours[6]['google_z'] = Number(16);
harbours[6]['type_id'] = '0';
harbours[6]['dim_x'] = 10;
harbours[6]['dim_y'] = 10;
harbours[6]['anchor_x'] = 1;
harbours[6]['anchor_y'] = 1;
harbours[6]['shown'] = true;
harbours[7] = new Object();
harbours[7]['name'] = 'Fethiye (Yacht Plaza Hotel)<br><ul><li>Sunsail</li></ul>';
harbours[7]['google_x'] = Number(36.62238213092648);
harbours[7]['google_y'] = Number(29.098883271217346);
harbours[7]['google_z'] = Number(17);
harbours[7]['type_id'] = '0';
harbours[7]['dim_x'] = 10;
harbours[7]['dim_y'] = 10;
harbours[7]['anchor_x'] = 1;
harbours[7]['anchor_y'] = 1;
harbours[7]['shown'] = true;
harbours[8] = new Object();
harbours[8]['name'] = 'Finike (Setur Marina)';
harbours[8]['google_x'] = Number(36.293751789896305);
harbours[8]['google_y'] = Number(30.149896144866943);
harbours[8]['google_z'] = Number(16);
harbours[8]['type_id'] = '0';
harbours[8]['dim_x'] = 10;
harbours[8]['dim_y'] = 10;
harbours[8]['anchor_x'] = 1;
harbours[8]['anchor_y'] = 1;
harbours[8]['shown'] = true;
harbours[9] = new Object();
harbours[9]['name'] = 'Göcek (Marina)<br><ul><li>Portway</li><li>Pupa Yachting</li><li>SEAGULL</li><li>Vernicos Yachts</li></ul>';
harbours[9]['google_x'] = Number(36.75274247195595);
harbours[9]['google_y'] = Number(28.941400051116943);
harbours[9]['google_z'] = Number(16);
harbours[9]['type_id'] = '0';
harbours[9]['dim_x'] = 10;
harbours[9]['dim_y'] = 10;
harbours[9]['anchor_x'] = 1;
harbours[9]['anchor_y'] = 1;
harbours[9]['shown'] = true;
harbours[10] = new Object();
harbours[10]['name'] = 'Göcek (Club Marina)<br><ul><li>Moorings</li><li>Sunsail</li></ul>';
harbours[10]['google_x'] = Number(36.74908899422219);
harbours[10]['google_y'] = Number(28.925446271896362);
harbours[10]['google_z'] = Number(16);
harbours[10]['type_id'] = '0';
harbours[10]['dim_x'] = 10;
harbours[10]['dim_y'] = 10;
harbours[10]['anchor_x'] = 1;
harbours[10]['anchor_y'] = 1;
harbours[10]['shown'] = true;
harbours[11] = new Object();
harbours[11]['name'] = 'Göcek (Port Göcek)';
harbours[11]['google_x'] = Number(36.74847863157123);
harbours[11]['google_y'] = Number(28.942601680755615);
harbours[11]['google_z'] = Number(16);
harbours[11]['type_id'] = '0';
harbours[11]['dim_x'] = 10;
harbours[11]['dim_y'] = 10;
harbours[11]['anchor_x'] = 1;
harbours[11]['anchor_y'] = 1;
harbours[11]['shown'] = true;
harbours[12] = new Object();
harbours[12]['name'] = 'Göcek (Skopea Marina)<br><ul><li>EGG Yachting</li></ul>';
harbours[12]['google_x'] = Number(36.754092065608994);
harbours[12]['google_y'] = Number(28.93844962120056);
harbours[12]['google_z'] = Number(17);
harbours[12]['type_id'] = '0';
harbours[12]['dim_x'] = 10;
harbours[12]['dim_y'] = 10;
harbours[12]['anchor_x'] = 1;
harbours[12]['anchor_y'] = 1;
harbours[12]['shown'] = true;
harbours[13] = new Object();
harbours[13]['name'] = 'Karacasögut (Steganlage)<br><ul><li>Offshore Sailing</li></ul>';
harbours[13]['google_x'] = Number(36.94172883201283);
harbours[13]['google_y'] = Number(28.186787366867065);
harbours[13]['google_z'] = Number(17);
harbours[13]['type_id'] = '0';
harbours[13]['dim_x'] = 10;
harbours[13]['dim_y'] = 10;
harbours[13]['anchor_x'] = 1;
harbours[13]['anchor_y'] = 1;
harbours[13]['shown'] = true;
harbours[14] = new Object();
harbours[14]['name'] = 'Kemer (Kemer Marina)';
harbours[14]['google_x'] = Number(36.60054205554235);
harbours[14]['google_y'] = Number(30.57271957397461);
harbours[14]['google_z'] = Number(16);
harbours[14]['type_id'] = '0';
harbours[14]['dim_x'] = 10;
harbours[14]['dim_y'] = 10;
harbours[14]['anchor_x'] = 1;
harbours[14]['anchor_y'] = 1;
harbours[14]['shown'] = true;
harbours[15] = new Object();
harbours[15]['name'] = 'Kusadasi (Setur Marina)';
harbours[15]['google_x'] = Number(37.87007680981617);
harbours[15]['google_y'] = Number(27.262208461761475);
harbours[15]['google_z'] = Number(16);
harbours[15]['type_id'] = '0';
harbours[15]['dim_x'] = 10;
harbours[15]['dim_y'] = 10;
harbours[15]['anchor_x'] = 1;
harbours[15]['anchor_y'] = 1;
harbours[15]['shown'] = true;
harbours[16] = new Object();
harbours[16]['name'] = 'Marmaris (Pupa Marina)<br><ul><li>Dream Yacht Charter</li><li>Kiriacoulis</li><li>Pupa Yachting</li></ul>';
harbours[16]['google_x'] = Number(36.82931366764484);
harbours[16]['google_y'] = Number(28.310158252716064);
harbours[16]['google_z'] = Number(16);
harbours[16]['type_id'] = '0';
harbours[16]['dim_x'] = 10;
harbours[16]['dim_y'] = 10;
harbours[16]['anchor_x'] = 1;
harbours[16]['anchor_y'] = 1;
harbours[16]['shown'] = true;
harbours[17] = new Object();
harbours[17]['name'] = 'Marmaris (Netsel Marina)<br><ul><li>Sunshine Cruising</li><li>YÃ¼ksel Yachting</li></ul>';
harbours[17]['google_x'] = Number(36.85057367565917);
harbours[17]['google_y'] = Number(28.279924392700195);
harbours[17]['google_z'] = Number(13);
harbours[17]['type_id'] = '0';
harbours[17]['dim_x'] = 10;
harbours[17]['dim_y'] = 10;
harbours[17]['anchor_x'] = 1;
harbours[17]['anchor_y'] = 1;
harbours[17]['shown'] = true;
harbours[18] = new Object();
harbours[18]['name'] = 'Marmaris (Albatros Marina)<br><ul><li>Offshore Sailing</li></ul>';
harbours[18]['google_x'] = Number(36.84393699752257);
harbours[18]['google_y'] = Number(28.286345601081848);
harbours[18]['google_z'] = Number(18);
harbours[18]['type_id'] = '0';
harbours[18]['dim_x'] = 10;
harbours[18]['dim_y'] = 10;
harbours[18]['anchor_x'] = 1;
harbours[18]['anchor_y'] = 1;
harbours[18]['shown'] = true;
harbours[19] = new Object();
harbours[19]['name'] = 'Marmaris (Stadthafen)<br><ul><li>SEAGULL</li></ul>';
harbours[19]['google_x'] = Number();
harbours[19]['google_y'] = Number();
harbours[19]['google_z'] = Number(0);
harbours[19]['type_id'] = '0';
harbours[19]['dim_x'] = 10;
harbours[19]['dim_y'] = 10;
harbours[19]['anchor_x'] = 1;
harbours[19]['anchor_y'] = 1;
harbours[19]['shown'] = true;
harbours[20] = new Object();
harbours[20]['name'] = 'Orhaniye (Steganlage)';
harbours[20]['google_x'] = Number(36.754165132103815);
harbours[20]['google_y'] = Number(28.1272691488266);
harbours[20]['google_z'] = Number(18);
harbours[20]['type_id'] = '0';
harbours[20]['dim_x'] = 10;
harbours[20]['dim_y'] = 10;
harbours[20]['anchor_x'] = 1;
harbours[20]['anchor_y'] = 1;
harbours[20]['shown'] = true;
harbours[21] = new Object();
harbours[21]['name'] = 'Orhaniye (Marti Marina)<br><ul><li>Sunsail</li></ul>';
harbours[21]['google_x'] = Number(36.770173612218606);
harbours[21]['google_y'] = Number(28.127059936523438);
harbours[21]['google_z'] = Number(16);
harbours[21]['type_id'] = '0';
harbours[21]['dim_x'] = 10;
harbours[21]['dim_y'] = 10;
harbours[21]['anchor_x'] = 1;
harbours[21]['anchor_y'] = 1;
harbours[21]['shown'] = true;
harbours[22] = new Object();
harbours[22]['name'] = 'Orhaniye (Steganlage Palmiye Hotel)<br><ul><li>Moorings</li></ul>';
harbours[22]['google_x'] = Number(36.75385137548681);
harbours[22]['google_y'] = Number(28.131405115127563);
harbours[22]['google_z'] = Number(18);
harbours[22]['type_id'] = '0';
harbours[22]['dim_x'] = 10;
harbours[22]['dim_y'] = 10;
harbours[22]['anchor_x'] = 1;
harbours[22]['anchor_y'] = 1;
harbours[22]['shown'] = true;
harbours[23] = new Object();
harbours[23]['name'] = 'Turgutreis (D-Marin)<br><ul><li>Sunsail</li><li>Vernicos Yachts</li></ul>';
harbours[23]['google_x'] = Number(37.002501263291464);
harbours[23]['google_y'] = Number(27.256425619125366);
harbours[23]['google_z'] = Number(15);
harbours[23]['type_id'] = '0';
harbours[23]['dim_x'] = 10;
harbours[23]['dim_y'] = 10;
harbours[23]['anchor_x'] = 1;
harbours[23]['anchor_y'] = 1;
harbours[23]['shown'] = true;
harbours[24] = new Object();
harbours[24]['name'] = 'Yalikavak (Port Bodrum Marina)<br><ul><li>Aura Yachting</li></ul>';
harbours[24]['google_x'] = Number(37.104359599146875);
harbours[24]['google_y'] = Number(27.28527545928955);
harbours[24]['google_z'] = Number(16);
harbours[24]['type_id'] = '0';
harbours[24]['dim_x'] = 10;
harbours[24]['dim_y'] = 10;
harbours[24]['anchor_x'] = 1;
harbours[24]['anchor_y'] = 1;
harbours[24]['shown'] = true;
locations[0] = new Object();
locations[0]['name'] = 'Dalaman (DLM)';
locations[0]['google_x'] = Number(36.70957734575541);
locations[0]['google_y'] = Number(28.792591094970703);
locations[0]['google_z'] = Number(10);
locations[0]['type_id'] = '2';
locations[0]['dim_x'] = 10;
locations[0]['dim_y'] = 10;
locations[0]['anchor_x'] = 1;
locations[0]['anchor_y'] = 1;
locations[0]['shown'] = true;
locations[1] = new Object();
locations[1]['name'] = 'Bodrum (BJV)';
locations[1]['google_x'] = Number(37.24864107759967);
locations[1]['google_y'] = Number(27.661170959472656);
locations[1]['google_z'] = Number(12);
locations[1]['type_id'] = '2';
locations[1]['dim_x'] = 10;
locations[1]['dim_y'] = 10;
locations[1]['anchor_x'] = 1;
locations[1]['anchor_y'] = 1;
locations[1]['shown'] = true;
locations[2] = new Object();
locations[2]['name'] = 'Izmir (ADB)';
locations[2]['google_x'] = Number(38.29101446582335);
locations[2]['google_y'] = Number(27.155113220214844);
locations[2]['google_z'] = Number(12);
locations[2]['type_id'] = '2';
locations[2]['dim_x'] = 10;
locations[2]['dim_y'] = 10;
locations[2]['anchor_x'] = 1;
locations[2]['anchor_y'] = 1;
locations[2]['shown'] = true;
locations[3] = new Object();
locations[3]['name'] = 'Antalya (AYT)';
locations[3]['google_x'] = Number(36.89650806672221);
locations[3]['google_y'] = Number(30.799827575683594);
locations[3]['google_z'] = Number(13);
locations[3]['type_id'] = '2';
locations[3]['dim_x'] = 10;
locations[3]['dim_y'] = 10;
locations[3]['anchor_x'] = 1;
locations[3]['anchor_y'] = 1;
locations[3]['shown'] = true;
locations[4] = new Object();
locations[4]['name'] = 'Istanbul (IST)';
locations[4]['google_x'] = Number(40.97899090545241);
locations[4]['google_y'] = Number(28.81765365600586);
locations[4]['google_z'] = Number(13);
locations[4]['type_id'] = '2';
locations[4]['dim_x'] = 10;
locations[4]['dim_y'] = 10;
locations[4]['anchor_x'] = 1;
locations[4]['anchor_y'] = 1;
locations[4]['shown'] = true;
locations[5] = new Object();
locations[5]['name'] = 'Istanbul (SAW)';
locations[5]['google_x'] = Number(40.89924135913096);
locations[5]['google_y'] = Number(29.30706024169922);
locations[5]['google_z'] = Number(13);
locations[5]['type_id'] = '2';
locations[5]['dim_x'] = 10;
locations[5]['dim_y'] = 10;
locations[5]['anchor_x'] = 1;
locations[5]['anchor_y'] = 1;
locations[5]['shown'] = true;
			
		function getMarkers( array_name )
		{
			var batch = [];
			
			// loop through all locations and set markers
			for( var i=0; i < array_name.length; i++ )
			{
				if( array_name[i].google_x && array_name[i].google_y )
				{
					var coords = new GLatLng( array_name[i].google_x, array_name[i].google_y );
					batch.push( createMarker( coords, array_name[i].google_z, array_name[i].type_id, array_name[i].dim_x, array_name[i].dim_y, array_name[i].anchor_x, array_name[i].anchor_y, array_name[i].name ) );
				}
			}
			
			return batch;
		}
		
		function setupMarkers() 
		{
			mgr = new GMarkerManager( map );
			
			mgr.addMarkers( getMarkers( oceans ), 0 );
			mgr.addMarkers( getMarkers( harbours ), 6 );
			mgr.addMarkers( getMarkers( locations ), 8, 14 );
						
			mgr.refresh();
		}
		
		window.setTimeout( setupMarkers, 0 );
		
		function showTooltip( marker )
		{
			tooltip.innerHTML = marker.tooltip;
			
			var point=map.getCurrentMapType().getProjection().fromLatLngToPixel( map.getBounds().getSouthWest(),map.getZoom() );
			var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel( marker.getPoint(),map.getZoom() );
			var anchor=marker.getIcon().iconAnchor;
			var width=marker.getIcon().iconSize.width;
			var pos = new GControlPosition( G_ANCHOR_BOTTOM_LEFT, new GSize( offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y ) ); 
			
			pos.apply(tooltip);
			
			tooltip.style.visibility="visible";
		}
		
		GEvent.addListener( map, "wheelup", function(p)
		{
		  if ( map.getZoomLevel() > 0 ) {
		    map.centerAndZoom(
		      p.scaleRelative( map.getCenterLatLng() ),
		      map.getZoomLevel() - 1
		    );
		  }
		} );
		
		GEvent.addListener( map, "wheeldown", function(p)
		{
		  if ( map.getZoomLevel() <= 16 )
		    map.centerAndZoom(
		      p.scaleRelative( map.getCenterLatLng(), -1 ),
		      map.getZoomLevel() + 1
		    );
		} );
		
		GEvent.addDomListener(map.getContainer(), "DOMMouseScroll",
		function(oEvent)
		{
			if( oEvent.preventDefault )
			oEvent.preventDefault();
		} ); 
		
		// things that happen when the map is moved - basically just for debugging and detecting the coordinates for locations
		GEvent.addListener( map, "moveend", function()
		{
			var center = map.getCenter();
			var zoom = map.getZoom();
			document.getElementById("googleMapLabelDetail").innerHTML = center.toString() + ' ' + zoom.toString();
        } );
	}
}