var paramparent;
var paramtop;
// Change the "back buttons" on a linked index page, to return to its parent album
function pageInit(pTopURL)
{	getParams();
	paramparent = params[paramparentname];
	paramtop = params[paramtopname];
	if (params[paramgotopname] == 'y')
	{	window.location.replace(pTopURL);
	}
}

function enableIndexParent()
{	if (paramparent != null)
	{	var vParentLink = document.getElementById('parentLink');
		var vParentButton = document.getElementById('parentButton');
		var vTopLink = document.getElementById('topLink');
		var vTopButton = document.getElementById('topButton');
		if (paramtop == null)
		{	paramtop = fDocURL();
		}
		vParentButton.style.visibility = 'visible';
		if (paramtop == fDocURL() || vParentLink.href == '')
		{	vParentLink.href = paramparent;
			vParentButton.alt = 'Back';
		}
		else
		{	vParentLink.href += '?' + paramparentname + '=' + paramparent + '&' + paramtopname + '=' + paramtop;
//			alert("vParentLink = " + vParentLink.href);
		}
		if (vTopLink != null)
		{	vTopLink.href = paramparent + '?' + paramgotopname + '=y';
			vTopButton.style.visibility = 'visible'
			vTopButton.alt = 'Top';
		}
	}
}

// If the page is in a linked album, or is about to link to another album, change the address in the href
function makeHref(pObj, pIsLink)
{
//	If opening a url, and "new_window" was specified, we should not be here.
//	If opening a remote url from a local web page, open in a new window without parameters.
//	If not opening a url, pass the incoming parameters
//	If opening a url, and there are no incoming parameters, build the parent parameter & attach to the href.
//	If opening a url, and there are incoming parameters, open in a new window without parameters.
	var vhref = pObj.href;
	var vLinked = (paramparent != null);

	if (pIsLink)
	{	if (vLinked || (document.location.href.substr(0,5) == "file:" && pObj.href.substr(0,5) == "http:"))
		{	pObj.target="_blank";
		}
		else
		{	vhref += '?' + paramparentname + '=' + fDocURL();
		}
	}
	else if (vLinked)
	{	vhref += '?' + paramparentname + '=' + paramparent
					 + '&' + paramtopname + '=' + (paramtop == null ? fDocURL() : paramtop);
	}

	pObj.href = vhref;
}
