// JavaScript Document

function init(){
	
	loadMap();
	
	$$('.sidebar-search input[type="text"]').each(function(input){
		var title = input.title;
		if (input.value != "" && input.value != title) return;
		
		input.value = title;
		input.title = "";
		input.addClass('default-value');
		
		input.addEvent('focus', function(){
			var value = input.value;
			if(value == title){
				input.value = "";
				input.removeClass('default-value');
			}
		});
		
		input.addEvent('blur', function(){
			var value = input.value;
			if(value == ""){
				input.value = title;
				input.addClass('default-value');
			}
		});
	});
	
}

function loadMap(){
	var map = $('map');
	if (!map || !googlemaps_address) return;
	
	// Load Map
	var latlng = new google.maps.LatLng(0, 0);
	var myOptions = {
		 zoom: 0
		,center: latlng
		,mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		
	map = new google.maps.Map(map, myOptions);
	
	// Code address
	var geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': googlemaps_address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			map.setCenter(results[0].geometry.location);
			marker = new google.maps.Marker({
				 map: map
				,position: results[0].geometry.location
				});
			map.setZoom(15);
		}
	});
	
}

window.addEvent('domready', init);







































