//Photo Gallery

function getElementByParent(name, childElem)
{
    var testClassAndId = new RegExp("(^|\\s)" + name + "(\\s|$)");
        	    		
    if(testClassAndId.test(childElem.className) || testClassAndId.test(childElem.id))
    {
	    return childElem;
    }
    else if(!childElem.parentNode)
    {
        return null;
    }
    else
    {
	    return getElementByParent(name, childElem.parentNode);
    }
}    

function showPic(whichpic) {
	var source = whichpic.getAttribute("href");
	//placeholder = getElementsByClassName2("fsImgPlaceholder", "img", whichpic.parentNode.parentNode.parentNode)[0];
	whichpic_parent = getElementByParent("fsFlashPhotoGallery", whichpic);
	placeholder = getElementsByClassName2("fsImgPlaceholder", "img", whichpic_parent)[0];
	
	if(!placeholder) return true;
	placeholder.setAttribute("src",source);
	
	// this is used to hide the flash player and show the images
	var flashMovie = getElementsByClassName2("fsFlashMovies", "div")[0];
	if(!flashMovie) return false;  // check to see if there is flash, if not it does not do anything.
	flashMovie.style.display="none";
	return false;
}


function prepareGallery(){
	if(!document.getElementsByTagName('a')) return false;
	var fsInfoElems = getElementsByClassName2("fsFlashPhotoGallery", "div");		
    for(i=0; i < fsInfoElems.length; ++i)
    {		
		var links = fsInfoElems[i].getElementsByTagName('a');
		for(var j=0; j < links.length; j++)
		{
			links[j].onclick = function()
			{
				return showPic(this);
			}
		}
	}
	
}

onloads.push(prepareGallery);


   