$(document).ready(function() {
    // Lat/Long
	var ecurie = new google.maps.LatLng(46.184685, 6.700909);
	var philippe = new google.maps.LatLng(46.179730, 6.707088);
	var aiglon = new google.maps.LatLng(46.184477, 6.699418);
	var superMorzine = new google.maps.LatLng(46.183532, 6.703420);
	var pleney = new google.maps.LatLng(46.179908, 6.701767);
    var mapCentre = new google.maps.LatLng(46.185015,6.702583);

	// Pins
	var chaletPin = new google.maps.MarkerImage('/i/chalet_pin.png',
      new google.maps.Size(30,39),
      new google.maps.Point(0,0),
      new google.maps.Point(15,39));
	var chaletShaddow = new google.maps.MarkerImage('/i/chalet_shaddow.png',
      new google.maps.Size(52,32),
      new google.maps.Point(0,0),
      new google.maps.Point(15,39));

	var liftPin = new google.maps.MarkerImage('/i/lift_pin.png',
      new google.maps.Size(21,26),
      new google.maps.Point(0,0),
      new google.maps.Point(10,26));
	var liftShaddow = new google.maps.MarkerImage('/i/lift_shaddow.png',
      new google.maps.Size(35,26),
      new google.maps.Point(0,0),
      new google.maps.Point(10,26));

    // Options
	var myOptions = {
		zoom: 15,
		center: mapCentre,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("map"),myOptions);

	// Markers
	var aiglon_marker = new google.maps.Marker({
		position: aiglon,
		icon: chaletPin,
		shadow: chaletShaddow,
		title: "The Aiglon"
	});
	aiglon_marker.setMap(map);

	var ecurie_marker = new google.maps.Marker({
		position: ecurie,
		icon: chaletPin,
		shadow: chaletShaddow,
		title: "Chalet l'Ecurie"
	});
	ecurie_marker.setMap(map);

	var philippe_marker = new google.maps.Marker({
		position: philippe,
		icon: chaletPin,
		shadow: chaletShaddow,
		title: "Chalet Philippe"
	});
	philippe_marker.setMap(map);

	var pleney_marker = new google.maps.Marker({
		position: pleney,
		icon: liftPin,
		shadow: liftShaddow,
		title: "Pleney Lift"
	});
	pleney_marker.setMap(map);

	var superMorzine_marker = new google.maps.Marker({
		position: superMorzine,
		icon: liftPin,
		shadow: liftShaddow,
		title: "Super Morzine Lift"
	});
	superMorzine_marker.setMap(map);

	// Overlays
    var infowindow = new google.maps.InfoWindow();

	var ecurieText = '<div class="customInfoWindow" style="height:70px; overflow:hidden;">'+
					'<img src="/i/ecurie_vSml.jpg" alt="Chalet Ecurie" style="float:left; margin-right: 10px;" />'+
					'<div class="title">Chalet l\'Ecurie</div>'+
					'<p>Route de la Vielle Plagne, 74110, Morzine</p>'+
					'<p><a href="summer_chalet_lecurie.php">Chalet l\'Ecurie</a></p>'+
					'</div>';
	google.maps.event.addListener(ecurie_marker, 'click', function() {
		infowindow.setContent(ecurieText);
		infowindow.open(map, ecurie_marker);
	});

	var philippeText = '<div class="customInfoWindow" style="height:70px; overflow:hidden;">'+
					'<img src="/i/philippe_vSml.jpg" alt="Chalet Philippe" style="float:left; margin-right: 10px;" />'+
					'<div class="title">Chalet Philippe</div>'+
					'<p>137 Route du Plan, 74110, Morzine</p>'+
					'<p><a href="summer_chalet_philippe.php">Chalet Philippe</a></p>'+
					'</div>';
	google.maps.event.addListener(philippe_marker, 'click', function() {
		infowindow.setContent(philippeText);
		infowindow.open(map, philippe_marker);
	});

	var aiglonText = '<div class="customInfoWindow" style="height:70px; overflow:hidden;">'+
					'<img src="/i/aiglon_vSml.jpg" alt="The Aiglon" style="float:left; margin-right: 10px;" />'+
					'<div class="title">The Aiglon</div>'+
					'<p>Route de la Plagne, 74110, Morzine</p>'+
					'<p><a href="summer_the_aiglon.php">The Aiglon</a></p>'+
					'</div>';
	google.maps.event.addListener(aiglon_marker, 'click', function() {
		infowindow.setContent(aiglonText);
		infowindow.open(map, aiglon_marker);
	});

	var superMorzineText = '<div class="customInfoWindow" style="height:70px; overflow:hidden;">'+
					'<div class="title">Super Morzine lift</div>'+
					'<p>Leads to: Avoriaz, Chatel, Morgins, Les Crosets</p>'+
					'</div>';
	google.maps.event.addListener(superMorzine_marker, 'click', function() {
		infowindow.setContent(superMorzineText);
		infowindow.open(map, superMorzine_marker);
	});

	var pleneyText = '<div class="customInfoWindow" style="height:70px; overflow:hidden;">'+
					'<div class="title">Pleney lift</div>'+
					'<p>Leads to: Morzine, Les Gets</p>'+
					'</div>';
	google.maps.event.addListener(pleney_marker, 'click', function() {
		infowindow.setContent(pleneyText);
		infowindow.open(map, pleney_marker);
	});

	// Open marker text as default
	var defaultMarker = $('#map').attr('class');

	switch (defaultMarker){
	case 'ecurie':
	  	infowindow.setContent(ecurieText);
		infowindow.open(map, ecurie_marker);
	  	break;
	case 'philippe':
		infowindow.setContent(philippeText);
		infowindow.open(map, philippe_marker);
	  	break;
	case 'aiglon':
		infowindow.setContent(aiglonText);
		infowindow.open(map, aiglon_marker);
	  	break;
	}

});
