var timmenga = {
	init: function(){
		jQuery("#search input").focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
		
		var form = jQuery('form#consult');
		if(form){
			form.submit(function(){
				jQuery('#warning').remove();
				var t = jQuery(this), reg = RegExp('^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$'), mail = jQuery(this).find('#mail').val();
				if(t.find('#name').val() == '' ||
					mail == '' ||
					!reg.test(mail))
				{
					t.prepend('<div id="warning" style="margin-bottom: 20px;"><p>Please fill out all required fields.</p></div>');
					return false;
				}
				return true;
			});
		}
		// Lightbox
		var l = jQuery('body.photo a.light');
		if(l.get(0)){
			l.lightBox();
		}			
		timmenga.initMap();
	},
	initMap: function(){
		var m = document.getElementById('map');
		if (m && loc && GBrowserIsCompatible()){
			var map = new GMap2(m);
			map.setCenter(loc, 14);
			map.addControl(new GSmallMapControl());
			map.setMapType(G_NORMAL_MAP);
			map.enableScrollWheelZoom();
			map.enableContinuousZoom();
			
			var blueIcon = new GIcon(G_DEFAULT_ICON);
			blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
			blueIcon.iconSize = new GSize(27, 30);
			var marker = new GMarker(loc, { icon:blueIcon });
			map.addOverlay(marker);
			
			GEvent.addListener(marker, 'click', function() {
				marker.openInfoWindowHtml(address);
			});
			marker.openInfoWindowHtml(address);

		}
	}
}
jQuery(timmenga.init);
