/*	Author: Alexander Albrecht www.alexanderalbrecht.ch
	© 2011–2012

	Scripts
	Version 1.0
	09.10.2011
*/

/* Hide background */
$("#adress").click().toggle(function() {

		$("body").toggleClass("withmap");
		$("#background").slideUp(250);

	}, function() {

		$("body").toggleClass("withmap");
		$("#background").slideDown(250);

});

/* Lettering */
$(document).ready(function() {

	$("h1").lettering();

});

/* Map */
$(function(){

	var atlas = [
		{
			featureType: "poi",
			elementType: "all",
			stylers: [
				{ visibility: "off" }
			]
		},
		{
			featureType: "transit",
			elementType: "all",
			stylers: [
				{ visibility: "off" }
			]
		},
		{
			featureType: "administrative.neighborhood",
			elementType: "all",
			stylers: [
			{ visibility: "off" }
			]
		},
		{
			featureType: "administrative.land_parcel",
			elementType: "all",
			stylers: [
				{ visibility: "off" }
			]
		},
		{
			featureType: "administrative.province",
			elementType: "all",
			stylers: [
				{ visibility: "off" }
			]
		},
		{
			featureType: "water",
			elementType: "labels",
			stylers: [
				{ visibility: "off" }
			]
		},
		{
			featureType: "water",
			elementType: "geometry",
			stylers: [
				{ hue: "#00ccff" },
				{ lightness: 51 },
				{ saturation: -31 }
			]
		},

	];

	$("#map").gmap3(

		{
			action: "init",
			options: {
			// Map Position
				center: [47.06,8.653193],
				zoom: 12,

			// Map Type and Styles
				backgroundColor: "rgb(51,204,255)", // when tiles are loading
				mapTypeId: "style-easy",
				mapTypeControl: true,
				mapTypeControlOptions: {
					mapTypeIds: ["style-easy", google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.TERRAIN],
					style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
					position: google.maps.ControlPosition.TOP_RIGHT
				},
			// Map Nav, Zoom
				navigationControl: true,
				navigationControlOptions: {
					style: google.maps.NavigationControlStyle.SMALL,
					position: google.maps.ControlPosition.TOP_RIGHT
				},
			// Additional Options
				scrollwheel: true,
				streetViewControl: false,
				disableDoubleClickZoom: false
			}
		},

		{
			action: "addMarker",
			latLng: [47.020256,8.653565],
			icon: "pin-map.png",
			title: "Albrecht Grafik & Code, Archivgasse 8, 6430 Schwyz",
			clickable: true,
			flat: true
		},

		{
		  	action: "addStyledMap",
		    id: "style-easy",
		    style: atlas,
		    options: {
		    	name: "Karte"
		    }
		},

		{
		  	action: "addStyledMap",
		    id: google.maps.MapTypeId.SATELLITE,
		    options: {
		    	name: "Satellit"
		    }
		},

		{
		  	action: "addStyledMap",
		    id: google.maps.MapTypeId.TERRAIN,
		    options: {
		    	name: "Gelände"
		    }
		}

	);
});

/* Hide URL bar on iOS iPhone */
if (navigator.userAgent.indexOf('iPhone') != -1) {
	addEventListener("load", function() {
		setTimeout(hideURLbar, 0);
	}, false);
}
function hideURLbar() {
	window.scrollTo(0, 1);
}
