// Début de fichier

var ol_followmouse = 1;
var ol_hauto = 1;
var ol_vauto = 1;
var ol_width = 350;	// largeur de la fenêtre popup
var ol_close = 'X';
var ol_fgclass = 'popupFg';
var ol_captionfontclass = 'popupCaption';
var ol_textfontclass = 'popupText';
var ol_mouseoff = 1; // utile pour refermer les fenêtres sans bouton

function getElement(id)
{
	if (document.getElementById)
		return document.getElementById(id);
	else
		if (document.all)
			return document.all[id];
		else
			if (document.layers)
				return document.layers[id];
	return null;
}

function getInnerHTML(id)
{
	var o = getElement(id);
	if ( o )
		return o.innerHTML;
	return '';
}

function text(id)
{
	return getInnerHTML('block'+id);
}

function caption(id)
{
	return getInnerHTML('label'+id);
}

function showPopup(id)
{
	var currentCaption = ''+caption(id);
	var noCaption = currentCaption == '&nbsp;' || currentCaption == '';
	var currentText;
	if ( typeof id == 'string' )
	{
		currentText = getInnerHTML(id);
		return overlib( currentText == '' ? id : currentText,WRAP);
	}

	currentText = ''+text(id);
	var s = currentText.toLowerCase();

	var o = getElement('player'+id);
	if ( o )
		o.play();
	// si le texte contient un lien ou un formulaire, maintenir la fenêtre ouverte
	ol_sticky = ( s.indexOf('href') > -1 ) || ( s.indexOf('<form') > -1 );

	var noText = currentText == '&nbsp;' || currentText == '';
	if ( noText )
		return true;

	if ( noCaption )
		return ( s.indexOf('<p') < 0 && s.indexOf('<ul') < 0 ) ? overlib(currentText,WRAP) : overlib(currentText);

	return overlib(currentText,CAPTION,currentCaption);
}

function hidePopup(id)
{
	var o = getElement('player'+id);
	if ( o )
		o.stop();
	ol_sticky = 0;
	return nd();
}

function showHTMLPopup(id)
{
	return overlib(getInnerHTML(id),FULLHTML,WRAP);
}


function setVisibility(m,s)
{
	if (document.all)
		{document.all[m].style.visibility=s;}
	if (document.layers)
		{document.layers[m].visibility=s;}
	if (document.getElementById)
		{document.getElementById(m).style.visibility=s;}
}

function setDisplay(m,s)
{
	if (document.all)
		{document.all[m].style.display=s;}
	if (document.layers)
		{document.layers[m].display=s;}
	if (document.getElementById)
		{document.getElementById(m).style.display=s;}
}

function show(m)
{
	setVisibility(m,'visible');
	setDisplay(m,'inline');
}

function hide(m)
{
	setVisibility(m,'hidden');
	setDisplay(m,'none');
}

var cookieLifeTime = 90; // days
var cookieName = 'showMap';
var expDate = new Date();
expDate.setTime(expDate.getTime() + cookieLifeTime*24*3600*1000);

function setCookie (name, value) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape(value)
		+ ( (expires == null) ? "" : ("; expires=" + expires.toGMTString()))
		+ ( (path == null) ? "" : ("; path=" + path))
		+ ( (domain == null) ? "" : ("; domain=" + domain))
		+ ( (secure == true) ? "; secure" : "");
}
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if ( begin == -1 ) {
		begin = dc.indexOf(prefix);
		if ( begin != 0 )
			return null;
	}
	else
		begin += 2;
	var end = dc.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function mapExists()
{
	return document.getElementById('Map');
}

function textExists()
{
	return document.getElementById('block0');
}

function showMap(mustSetCookie)
{
	var toggleButton = document.getElementById('toggleView');
	if ( mapExists() )
	{
		var txt = caption(10002);
		toggleButton.innerHTML = textExists() ? '<a href="javascript:hideMap(true);" onmouseover="return showPopup(\'block10002\');" onmouseout="return hidePopup();">'+txt+'</a>' : txt;
		hide('content');
		show('content-map');
	}
	else
	{
		toggleButton.innerHTML = caption(10001);
		hide('content-map');
		show('content');
	}
	if ( mustSetCookie )
		setCookie(cookieName,'true',expDate);
}

function hideMap(mustSetCookie)
{
	var toggleButton = document.getElementById('toggleView');
	if ( mapExists() )
	{
		toggleButton.innerHTML = '<a href="javascript:showMap(true);" onmouseover="return showPopup(\'block10001\');" onmouseout="return hidePopup();">'+caption(10001)+'</a>';
	}
	else
	{
		toggleButton.innerHTML = caption(10002);
	}
	hide('content-map');
	show('content');
	if ( mustSetCookie )
		setCookie(cookieName,'false',expDate);
}

function mapHidden()
{
	return ( getCookie(cookieName) != 'true' );
}

function setupAfterLoad()
{
	if ( mapHidden() )
		hideMap(false);
	else
		showMap(false);
}

function showContextPopup(id)
{
	return showPopup(id + (mapHidden() ? 0 : 1 ));
}

function contactUs()
{
	document.location.href='mailto:'+'denis'+'\@'+'rebaud.fr';
}
// Fin de fichier
