// Fonction lancée au démarrage
function initPage() {

}

// Joue sur le visibility d'un ?ment
function affiche(div, etat) {
	document.getElementById(div).style.visibility = (etat==1)?"visible":"hidden";
}

// Joue sur le display d'un élément
function montre(div, etat) {
	document.getElementById(div).style.display = (etat==1)?"block":"none";
}

// Récupère la valeur d'un élément
function getVal(div) {
	return document.getElementById(div).value;
}

function sendMe(id) {
	var email = window.prompt('Votre adresse email :');
	if(email) {
		var myXHR = new XHR({method: 'get', autoCancel: true, onSuccess: function() { alert('L\'annonce a bien été envoyée, merci pour votre confiance !'); }, onFailure: function() { alert('Il y a eu une erreur, veuillez réessayer dans quelques instants.'); }}).send('./ajax/sendme.php', 'id='+id+'&email='+email);
	}
}

function switchPhoto(id, nbphotos) {
	var i;
	document.getElementById('foto1').style.display = 'none'; // on cache l'image chargée en dur (la 1e a s'etre affichee)
	for(i = 0; i<nbphotos; i++)
		document.getElementById('lien_photo_bien_'+i).style.display = 'none'; // on cache les eventuelles images prechargees
	document.getElementById('lien_photo_bien_'+id).style.display = 'block'; // on affiche celle qu'on veut
}

function popup(url,w,h,resiz,scrolls) { 
var w_avail = screen.availWidth; 
var h_avail = screen.availHeight; 
var top = Math.round ((h_avail - h) * .5); 
var left = Math.round ((w_avail - w) * .5); 
// You have to use math.round in Safari because Safari will report odd numbers as availWidth and availHeigth. It subtracts the Dock and Menubar values from the real screen resolution. And if you multiply these values by .5 you'll end up with decimals. window.open wont't work with decimals as top/left values. 

var newWin = window.open(url,newWin,'width=' + w +',height=' +h + ',left=' + left + ',top=' + top + ',resizable=' + resiz + ', scrollbars=' + scrolls + ''); 
newWin.focus(); 
}
