/*
* [AC] 20080425
* add-on for mambot simple-gallery.
* show caption for individual images.
* captions are written in numbered list <ol /> tag, in order of the images,
* saved in the joomla content item itself.
* once document is loaded, the <ol> is hidden from displaying.
* then this function sig_ShowCaption can be called to show the caption
*
* REQUIRE:
* /_js/dom/event.js
*/

function sig_ShowCaption(num) {
	var domSiteCol = document.getElementById('site-col-main');
	if (!domSiteCol) return;
	var domCaptionCon = document.getElementById('sig-caption-con');
	if (!domCaptionCon) return;
	var arrDomOL = domSiteCol.getElementsByTagName('ol');
	// use the first <ol> in the col
	var domOL = arrDomOL[0];
	if (!domOL) return;
	// hide <ol>
	domOL.style.display = 'none';
	// get List of LI
	var arrDomLI = domOL.getElementsByTagName('li');
	var intIndex = num - 1;
	// get the LI to show
	var domLIToShow = arrDomLI[intIndex];
	if (!domLIToShow) return;
	// copy caption to display area
	if (domLIToShow) {
		domCaptionCon.innerHTML = domLIToShow.innerHTML;
	} else {
		domCaptionCon.innerHTML = '';
	}
}
addListener(window, 'load', function() {sig_ShowCaption(1)});