function ouvrirPhoto(photo)
{
var pathname = window.location.pathname;
if (pathname.lastIndexOf('photos') > 0) var root='';
else if (pathname.lastIndexOf('trip-reports') > 0) var root='../photos/';
else root='photos/';
$.ajax({
	type: 'POST',
	url: root+'getInfosPhoto.php',
	data: 'photo='+photo,
	success: function(xml)
	{	
	var width = $(xml).find('width').text();
	var height = $(xml).find('height').text();
	var extension = $(xml).find('extension').text();
	var categorie = $(xml).find('categorie_nom').text();
	var pays = $(xml).find('aeroport_pays').text();
	var aeroport = $(xml).find('aeroport_nom').text();
	var aeroport_code = $(xml).find('aeroport_code').text();
	var constructeur = $(xml).find('avion_constructeur').text();
	var avion = $(xml).find('avion_nom').text();
	var compagnie = $(xml).find('compagnie_nom').text();
	var compagnie_code = $(xml).find('compagnie_code').text();
	var immatriculation = $(xml).find('immatriculation').text();
	var auteur= $(xml).find('auteur_nom').text();
	var auteur_id= $(xml).find('auteur_id').text();
	var date_photo= $(xml).find('date_photo').text();
	var date_post= $(xml).find('date_post').text();
	var legende= $(xml).find('legende').text();
	var url_grand_format= $(xml).find('url_grand_format').text();
	var url_facebook= $(xml).find('url_facebook').text();
	if (width < 500) width_cadre = 500;
	else width_cadre = width;
	var width2 = width_cadre/2;
	var width2 = "-"+width2+'px';
	var height_cadre = Number(height)+110;
	var width = Number(width);
	$('#photo_details_aeroport').html('');
	$('#photo_details_compagnie').html('');
	$('#photo_details_avion').html('');
	$('#photo_details_date_photo').html('');
	$('#photo_legende').html('');
	$('#photo_photo').html('<a href="#" onclick="fermerPhoto();return false;"><img src="'+root+'album/'+photo+'.'+extension+'" alt="" width="'+width+'" height="'+height+'"></a>');
	$('#photo_cadre').width(width_cadre+'px');
	$('#photo_cadre').height(height_cadre+'px');
	$('#photo_cadre').css('margin-left',width2);
	if (aeroport != "") $('#photo_details_aeroport').html(pays+' - '+aeroport+' ('+aeroport_code+')');
	if (compagnie != "") $('#photo_details_compagnie').html(compagnie+' ('+compagnie_code+')');
	if (avion != "" && immatriculation == '') $('#photo_details_avion').html(constructeur+' - '+avion);
	else if (avion != ""  && immatriculation != '') $('#photo_details_avion').html(constructeur+' - '+avion+' immatriculté '+immatriculation);
	$('#photo_details_categorie').html(categorie);
	if (date_photo != '') $('#photo_details_date_photo').html('Photographié le '+date_photo);
	$('#photo_details_date_post').html(date_post);
	$('#photo_details_auteur').html('<a href=\"http://www.goldenflyer.com/communaute/profil.php?membre='+auteur_id+'\">'+auteur+'</a>');
	$("#lien_grand_format").attr("href",'/photos/'+url_grand_format);
	$("#url_facebook").attr("share_url",'http://www.goldenflyer.com/photos/'+url_grand_format);
	$("#url_facebook").attr("href",'http://www.facebook.com/sharer.php?u='+url_facebook+'&src=sp');
	$('#photo_cadre').show();
	$('#photo_filtre').show();
	}
	});
}

function fermerPhoto()
{
	$('#photo_cadre').hide();
	$('#photo_filtre').hide();
}
