
	var active = "";
	var bTimerRunning = false;
	var iTimerCounter = 0;
	var pMiniatures = new Array();

	function getElement(name,id)
	{
		if(id >= 0)
		{
			return document.getElementById(name + "_" + id);
		}
		return document.getElementById(name);
	}

	function isVisible(name,id)
	{	var element = getElement(name,id);
		return (element != null) ? (element.style.display == "") : false;
	}

	function setVisibility(name,id,visibility)
	{	var element = getElement(name,id);
		if(element == null) return false;

		element.style.display = (visibility ? "" : "none");
		return true;
	}

	function swapVisibility(name,id)
	{	return setVisibility(name,id,!isVisible(name,id));
	}

	function showSecondary(name)
	{setVisibility("default",0,name == "default");
setVisibility("all",0,name == "all");
setVisibility("publication",0,name == "publication");
setVisibility("courses",0,name == "courses");
setVisibility("weddings",0,name == "weddings");
setVisibility("shop",0,name == "shop");
setVisibility("tutorials",0,name == "tutorials");

		stopTimer();
	}
	function startTimer()
	{	bTimerRunning = true;
		iTimerCounter = 2;
	}
	function stopTimer()
	{	bTimerRunning = false;
	}
	function setActive(name)
	{	active = name;
	}

	function onTimer()
	{	if(bTimerRunning)
		{
			iTimerCounter--;
			if(iTimerCounter == 0)
			{	showSecondary(active);
			}
		}
		window.setTimeout("onTimer()",1000);
	}

	window.setTimeout("onTimer()",1000);

	function formatMiniature(elt,bVisible)
	{
		elt.style.backgroundColor = "#EEEEEE";
		elt.style.backgroundRepeat = "no-repeat";
		elt.style.border = "1px solid #BBBBBB";
		elt.style.color = "#DDDDDD";
		elt.style.cursor = "pointer";
		elt.style.display = bVisible ? "" : "none";
		elt.style.height = "60px";
		elt.height = "60px";
		elt.style.marginBottom = "2px";
		elt.style.marginRight = "6px";
		elt.style.padding = "0px";
		elt.style.width = "60px";
		elt.width = "60px";
	}

	function addMiniature(iID,container,filter,bVisible)
	{
		var elt = document.createElement("img");
		formatMiniature(elt,bVisible);
		elt.onmouseout = new Function("hoverMiniature(" + iID + ",getElement(\"miniature\"," + iID + ").getAttribute(\"highlight\") == 1)");
		elt.onmouseover = new Function("hoverMiniature(" + iID + ",true)");
		elt.setAttribute("class","miniature rounded");
		elt.setAttribute("filter",filter);
		elt.setAttribute("highlight",0);
		elt.setAttribute("id","miniature_" + iID);
		elt.src = "styles/transp.gif";
		elt.style.backgroundImage = "url(" + thumbFilename + ")";
		elt.style.backgroundPosition = "-" + (60 * (iFirstThumb + iID)) + "px 0px";
		container.appendChild(elt);
		
		pMiniatures.push(iID);
		return elt;
	}

	function hoverMiniature(iImage,bHover)
	{
		getElement("miniature",iImage).style.backgroundColor = bHover ? "#C04040" : "#EEEEEE";
	}

	function highlightMiniature(filter)
	{
		for(var i = 0; i < pMiniatures.length; i++)
		{
			var elt = getElement("miniature",pMiniatures[i]);
			var bIsHighlight = (elt.getAttribute("filter") == filter);
			hoverMiniature(pMiniatures[i],bIsHighlight);
			elt.setAttribute("highlight",bIsHighlight ? 1 : 0);
		}
		return false;
	}

