﻿/*************************************
		fonctions de base
	 								*/
function afmod_getEltById(id,doc) {
	if (doc==null) doc=document;
	if(doc.getElementById)
		return doc.getElementById(id);
	else if (doc.all)
			return doc.all[id];
		else if (doc.layers)
				return doc.layers[id];
			else return null;
}
function afmod_showHide(obj,show) {
	obj.style.display=show ? "block" : "none";
}

/*************************************
			fonctions diverses
	 								*/
function afmod_popupImage(src,titre,w,h) {
	if (typeof(afvid_stopVideo)!="undefined") afvid_stopVideo();
	popupContent='<div align="center"><br><table cellpadding=0 cellspacing=0><tr><td class="afmod_photo">';
	popupContent+='<img src="' + src + '" border=0 />';
	popupContent+='</td></tr></table><br></div>';
	afmod_popupWindow(titre,popupContent,w,h+30);
}

var afmod_popupBg;
function afmod_popupWindow(popupTitle, popupContent,w,h) {
	if (!afmod_popupBg) {
		afmod_popupBg=document.createElement("DIV");
		afmod_popupBg.innerHTML='&nbsp;';
		afmod_popupBg.className = 'afmod_popupBg';
		document.body.insertBefore(afmod_popupBg,document.body.firstChild);
		afmod_popupBg.onclick=afmod_popupHide;
	}
	var thePopup=afmod_getEltById("afmod_popup");
	w+=40; h+=40;
	thePopup.style.width=w+"px";
	afmod_getEltById("afmod_popupTitle").innerHTML=popupTitle;
	afmod_getEltById("afmod_popupContent").innerHTML=popupContent;

	winwidth = window.innerWidth ? window.innerWidth : document.body.clientWidth;
	winheight = window.innerHeight ? window.innerHeight : document.body.clientHeight;

	afmod_popupBg.style.height=document.body.scrollHeight+"px";
	thePopup.style.left=((winwidth - w)/2 + document.body.scrollLeft) + "px";
	thePopup.style.top=((winheight - h)/2 + document.body.scrollTop) + "px";
	afmod_showHide(thePopup,true);
	afmod_popupBg.style.visibility='visible';
}

function afmod_popupHide() {
	if (typeof(afvid_stopVideo)!="undefined") afvid_stopVideo();
	if (afmod_popupBg) afmod_popupBg.style.visibility='hidden';
	afmod_showHide(afmod_getEltById("afmod_popup"),false);
}
