$(function() {
    
    var mapDiv = $("#map"), 
        mapLatLng = new google.maps.LatLng(50.080539, 14.424528);
    
    if (mapDiv.length > 0) {
        // map appearance
        var mapOptions = {
            zoom: 16,
            center: mapLatLng,
            mapTypeControl: true,
            mapTypeControlOptions: {
            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
            },
            zoomControl: true,
            zoomControlOptions: {
            style: google.maps.ZoomControlStyle.SMALL
            },
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
         
        // map initilization
        var map = new google.maps.Map(mapDiv.get(0), mapOptions);
        
        // info window initialization
        var infowindow = new google.maps.InfoWindow({
            content: '<div class="map-info">Vodičkova 699/30<br />pasáž U Nováků<br />schodiště 4, I. patro</div>'
        });

        // marker initialization
        var marker = new google.maps.Marker({
            position: mapLatLng,
            map: map
        });
        
        // click + marker + infowindow
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map,marker);
        });
    }
    
    // gallery
    $('#gallery a, .lightbox').lightBox({fixedNavigation:true});
    
    // disable blank navigation links
    $('#menu a').each(function() {
        var link = $(this);
        if (link.attr('href') == '#') {
            link.bind('click', function() { return false; });
        }
    });
    
    // print link
    $('#print').bind('click', function() {
      if (window !== undefined) {
        window.print();
      }
      return false;
    });

    // search placeholder
    $('#query').each(function() {
        var ph = $(this);

        // update placeholder text for empty inputs
		if (ph.val() == '') {
			ph.val(ph.attr('title'));
		}

		// add obvious event listeners
		ph.bind('focus', function() {
			if (ph.attr('title') == ph.val()) {
				ph.val('');
			}					
		}).bind('blur', function() {
			if (ph.val() == '' || ph.val() == ph.attr('title')) {
				ph.val(ph.attr('title'));
			}
		});
    });
});

