var map;

jQuery().ready(function() {
	
	$(window).bind('scroll', function() {
		
		$('body, #wrapper')
		.css(
			'background-position', 
			'50% ' + Math.ceil($('body').scrollTop() / 3) + 'px'
		);
		
	});
	
	
	if ($('#videopresenter').length) {
		$('#video_bar img').bind('error', function() {
			$(this).parents('li:first').hide();
		});
	}
	
	
	$('form.theform').each(function() {
		if (!$(this).hasClass('sent')) {
			$(this).find('textarea, input:text').each(function() {
				$(this).bind('focus', function() {
					if (this.value === this.defaultValue) {
						$(this).val('');
					}
				}).bind('blur', function() {
					if ($.trim($(this).val()) == '') {
						$(this).val(this.defaultValue);
					}
				})
			});
		}
	});
	
	if (typeof google !== 'undefined' && $('body').hasClass('page-template-contact-php')) {
		
		$('body').append($('<div id="map" />'));
		
		$(window).bind('load resize', function() {
	        _contentHeight = Math.max($(window).height(), $('#wrapper').outerHeight());

	        if ($('#map').length) {
	            $('#map').height(_contentHeight);
	        }
	    });
		
		$(window).bind('load', function() {
	        var mapstyle = [
	        {
	            featureType: "all",
	            elementType: "all",
	            stylers: [
	            { gamma: 1 },
	            { lightness: 50 },
	            { saturation: -100 },
	            { invert_lightness: true }
	            ]
	        }
	        ];

	        var latlng = new google.maps.LatLng(51.216562,7.635841);
	        var opts = {
	            zoom: 10,
				backgroundColor: '#000000',
	            center: latlng,
	            disableDefaultUI: true
	        };

	        var map = new google.maps.Map(document.getElementById("map"), opts);

	        var styledmap = new google.maps.StyledMapType(mapstyle, {
	            map: map,
	            name: 'shortyMap'
	        });
	        map.mapTypes.set('shortyMap', styledmap);
	        map.setMapTypeId('shortyMap');
		});
    }
	
});
