// open a search for a partner inside a department provided by a select
function openDepartmentSearch() {
	var requestedDepartmentSearchUrl = document.getElementById('dep').value;
	window.location = requestedDepartmentSearchUrl;
	return false;
}

// open a large image
function openLargeImage() {
	$('large_picture_partner').innerHTML = '<img src="'+ this.id +'" />';
}

// initialize the whole page
function initializePage() {
	// add event to all thumbnails
	$$('.aThumb img').each(function(aThumb) {
		aThumb.addEvent('click',openLargeImage);
	});
	// load quickbox
	new QuickBox();
}

// insert a google map and geocode
function loadMap(id,address) {
	var coordinates = address.split(',');
	if(coordinates[0] == '' || coordinates[1] == '') {
		$(id).innerHTML = 'Plan indisponible';
		$(id).setStyle('height','26px');
		return;
	}
	
	var geocoder	= new google.maps.Geocoder();
	var latlng		= new google.maps.LatLng(coordinates[0], coordinates[1]);
	var myOptions	= {
		zoom		: 11,
		center		: latlng,
		disableDefaultUI: true,
		navigationControl: true,
		mapTypeId	: google.maps.MapTypeId.ROADMAP
	}
	
	var map			= new google.maps.Map($(id), myOptions);
	var myLatLng	= new google.maps.LatLng(coordinates[0], coordinates[1]);
	var marker		= new google.maps.Marker({
        position: myLatLng, 
        map: map
    }); 
    
	/**** DISABLED GEOCODING ****
	
	if (geocoder) {
		geocoder.geocode({
			'address': address
			}, function(results, status) {
			if(status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				var marker 	= new google.maps.Marker({
					map		: map,
					title	: address,
					position: results[0].geometry.location
				});
			}
			else {
				map = null;
				$(id).innerHTML = 'Plan indisponible';
				$(id).setStyle('height','26px');	
			}
		});
	}
	
	**** DISABLED GEOCODING *****/
}

// add event to page for dom ready
window.addEvent('domready',initializePage);