// Fonction d'ouverture de fenetre popup centree
// Simon - egzakt.com
// 2004-10-28
//
function egz_openwindow(lien,cible,w,h) {
	var _win;
	_win = window.open(lien,cible,'width=' + w + ',height=' + h + ',top=' + (screen.height - 400)/2 + 'left='+ (screen.width - 400)/2);
	_win.moveTo((screen.width - w)/2,(screen.height - h)/2);
	_win.focus();

	return _win;
}

// Fonction d'ouverture de fenetre popup centree
// Simon - egzakt.com
// 2004-10-28
//
function egz_openwindow_param(lien,cible,w,h,param) {
	var _win;
	_win = window.open(lien,cible,param);
	_win.moveTo((screen.width - w)/2,(screen.height - h)/2);
	_win.focus();

	return _win;
}


// Fonction ouverture / fermeture de div
// Emilie 
function showhide(objet,objet_courant,image,classe_courante) {
	
	// cacher
	if (document.getElementById(objet).style.display == 'block') {
		document.getElementById(objet).style.display = 'none';
		document.getElementById(objet).style.visibility = 'hidden';		
		if (image) {
			document.getElementById(objet_courant).className = classe_courante;
			document.getElementById(objet_courant).style.backgroundImage = "url('" + image + "_off.gif')";
		}
	}
	
	// montrer
	else {
		document.getElementById(objet).style.display = 'block'
		document.getElementById(objet).style.visibility = 'visible'
		if (image) {
			document.getElementById(objet_courant).className = classe_courante + '_selected';
			document.getElementById(objet_courant).style.backgroundImage = "url('" + image + "_on.gif')";
		}
	}
}

// Fonction ouverture / fermeture de div
// Simon
function showhideClass(objet,objet_courant,image,classe_courante) {

	// cacher
	if (document.getElementById(objet).className == 'displayblock') {
		document.getElementById(objet).className = 'displaynone';
		if (image) {
			document.getElementById(objet_courant).className = classe_courante;
			document.getElementById(objet_courant).style.backgroundImage = "url('" + image + "_off.gif')";
		}
	// montrer
	} else {
		document.getElementById(objet).className = 'displayblock'
		if (image) {
			document.getElementById(objet_courant).className = classe_courante + '_selected';
			document.getElementById(objet_courant).style.backgroundImage = "url('" + image + "_on.gif')";
		}
	}
}
// Fonction bulle
// Emilie  - egzakt.com
// 2006
// Basee sur la fonction de Pat
function bulle(x,y,texte) {
	
	var largeur_box = 150;	
	var fin_box = x + largeur_box;
	var spacer = 20;
			
	if (fin_box > 748) {
		new_x = x - largeur_box - spacer;
	}
	else {
		new_x = x + spacer;
	}
		
	document.getElementById("bulle").style.visibility = "visible";
	document.getElementById("bulle").style.left = new_x + "px";
	document.getElementById("bulle").style.top = y + "px";
	document.getElementById("bulle").innerHTML = texte;
}

function cacher_bulle() {
	document.getElementById("bulle").style.visibility = "hidden";
}

// Simon - egzakt.com
// 2006
// t:input - f:obj form - s:section_id
var action_ori = "";
function rechercher(f){
	if (!action_ori) action_ori = f.action;
	var e = encodeURI(f.mots_cles.value).replace(/\%20/g, '+');
	var s = (f.recherche_par_section.checked ||
			((f.recherche_par_section.type != "checkbox") && (f.recherche_par_section.value == "1")))?f.recherche_section_id.value:1;
	f.action = action_ori + s + "/" + e;
	return true;
}


// Fonction qui change la photo moyenne du modele
// Emilie - egzakt.com
// 2006-08-10
function change_photo_modele(cible,cible_lightbox,photo,path) {
	document.getElementById(cible).src = photo;
	document.getElementById(cible_lightbox).href = photo.replace(path + "ap_",path);
}


function change_img_rep(id,img,chemin_photo) {
	if (id) {
		document.getElementById(img).style.display = 'inline';
		document.getElementById(img).src = chemin_photo + "rep_" + id + ".jpg";
	} else {
		document.getElementById(img).style.display = 'none';
	}
	return true;
}