/* No harm if no corresponding tooltip on page */
new ToolTip('info');

new checkFrames();

var _nextDia;
var _diapoTimeout;
var _userInput = false;


/* Initially (page loading) show the slide show state but don't start timer yet (in case photo long to load) */
function diaState()
{
	if(location.href.indexOf("?") > 0) {
		showOn();
	}
	else {
		showOff();
	}
}

/* Called once page finished loading to set initial timer */
function diaTimer()
{
	/* If user asked for something, forget the initial parameters of the page */
	if (!_userInput) {
		if(location.href.indexOf("?") > 0) {
			dOn();
		}
		else {
			dOff();
		}
	}
}


function dOff()
{
	_userInput = true;
	clearTimeout(_diapoTimeout);
	showOff();
}

function showOff()
{
	var _object = YAHOO.util.Dom.get("stopDiapo");
	YAHOO.util.Dom.replaceClass(_object, 'showDia', 'hidDia');
	var _object = YAHOO.util.Dom.get("startDiapo");
	YAHOO.util.Dom.replaceClass(_object, 'hidDia', 'showDia');
}

function dOn()
{
	var _nextSlide = function()
	{
		// setTimeout(_nextSlide, 30000); // Try again if page not here in 30 seconds...
		location.href = _nextDia + '?';
	};

	clearTimeout(_diapoTimeout);
	_userInput = true;
	showOn();
	_diapoTimeout = setTimeout(_nextSlide, 5000); // Delay ms on each page AFTER photo finished loading
}

function showOn()
{
	var _object = YAHOO.util.Dom.get("stopDiapo");
	YAHOO.util.Dom.replaceClass(_object, 'hidDia', 'showDia');
	var _object = YAHOO.util.Dom.get("startDiapo");
	YAHOO.util.Dom.replaceClass(_object, 'showDia', 'hidDia');
}


function mail(a, b) {
  document.write("<a class=\"sitenav\" href=\"mailto:"+a+"@"+b+"?subject=contact murblanc.org\">"+a+"@"+b+"</a>");
}

function helpthumb() {
  return overlib('cliquez sur les vignettes pour accéder aux photos.<br>passez la souris sur le message pour le faire disparaître.<br>cliquez sur le copyright pour me contacter.<p><i>click on the thumbnails to get to the pictures.<br>move the mouse on and off this message to make it go.<br>click on the copyright for contact information.</i><img src="/aidemenu.gif" height="0" width="0">',STICKY, MOUSEOFF, ABOVE, RIGHT, WIDTH, 380);
}


function checkFrames()
{
	var _frmDiv = YAHOO.util.Dom.get('frm');

	if (parent.frames.length != 0) {
		YAHOO.util.Dom.replaceClass(_frmDiv, 'hid', 'frameDivV');
		/* YAHOO.util.Dom.setStyle(_frmDiv, 'opacity', 0.60); */
	}

	var _frameKillerHandler = function(e, obj)
	{
		top.location=self.location;
	};
	
	YAHOO.util.Event.addListener(_frmDiv, 'mouseover', _frameKillerHandler, this, true);
}

function flashObject(id, realClass, flashClass)
{
	var _object = YAHOO.util.Dom.get(id);
	
	var _realClass = realClass;
	var _flashClass = flashClass;
	
	var _iteration = 0;
	var _timeout;

	var _onTimerPop = function()
	{
		if (_iteration++ % 2 == 0) {
			YAHOO.util.Dom.replaceClass(_object, realClass, flashClass);
		}
		else {
			YAHOO.util.Dom.replaceClass(_object, flashClass, realClass);
		}
		
		if (_iteration < 16) { /* nbre doit être pair */
			_timeout = setTimeout(_onTimerPop, 200);
		}
	}
	
	_onTimerPop();
}


/* Link id is name + 'Link', tooltip id is name + 'Tip' */
function ToolTip(n)
{
	var _toolTip;
	var _timeout;
	
	var _toolTipHandler = function(e, obj)
	{
		if (e.type === 'mouseover') {
			clearTimeout(_timeout);
			YAHOO.util.Dom.setStyle(_toolTip, 'display', 'block');
		}
		else { /* 'mouseout' */
			_timeout = setTimeout(_hideTooltip, 350);
		}
	};
	
	var _hideTooltip = function()
	{
		YAHOO.util.Dom.setStyle(_toolTip, 'display', 'none');
	};
	
	_toolTip = YAHOO.util.Dom.get(n + 'Tip');
	var _link = YAHOO.util.Dom.get(n + 'Link');
	YAHOO.util.Event.addListener([_toolTip, _link], 'mouseover', _toolTipHandler, this, true);
	YAHOO.util.Event.addListener([_toolTip, _link], 'mouseout', _toolTipHandler, this, true);
};


