
//----------------------------------------------------------------------------------------
//	fotosite-navigation
//
// 	<http://www.muratnkonar.com/otherstuff/fotosite>
//
//	(C) 2006 murat n konar
//
//----------------------------------------------------------------------------------------



// ------------------------------------------------------------------------------------------------------------
//	hasBio
// ------------------------------------------------------------------------------------------------------------
function hasBio()
{
	return document.siteDetails.bio.length > 0
}

// ------------------------------------------------------------------------------------------------------------
//	onBioPage
// ------------------------------------------------------------------------------------------------------------
function onBioPage()
{
	return document.galleryIndex == -2
}



// ------------------------------------------------------------------------------------------------------------
//	writeFotoNav
// ------------------------------------------------------------------------------------------------------------
function writeGalleryNav()
{
	/* writeGalleryNav() writes an unordered list of links in the form:
			
			<ul>
				<li><a href="javascript:showFoto(0, 0)">name of first gallery	</a></li>
				<li><a href="javascript:showFoto(1, 0)">name of second gallery	</a></li>
				<li><a href="javascript:showFoto(2, 0)" id="currentGallery">name of third gallery	</a></li> // <- this is the current gallery
				<li><a href="javascript:showFoto(3, 0)">name of fourth gallery	</a></li>
				
				// and optionally...
				<li><a href="javascript:showBio()">bibo title					</a></li>
 
			</ul>
	*/
		
	// Write the gallery links...
	var galleryNavString = "";
	
	var galleryCount = document.toc.galleries.length
	for (var g = 0; g < galleryCount; g++) 
	{
		var linkText = '<span>' + document.toc.galleries[g].name + '</span>'
		
		var liOpenTag = '<li>';
		
		if (!hasBio() && (g == galleryCount - 1))
		{
			liOpenTag = '<li class="last">'
		}
		
		var actionText = 'javascript:showFoto(' + g + ', 0)'
		if (g == document.galleryIndex)
		{
			linkText = liOpenTag + '<a href="' + actionText + '" id="currentGallery">' + linkText + '</a></li>'
		}
		else
		{
			linkText = liOpenTag + '<a href="' + actionText + '">' + linkText + '</a></li>'
		}
		
		galleryNavString += linkText
	}

	// Write the bio link...
	if (hasBio())
	{
		var linkText	= '<span>' +  document.siteDetails.bioTitle + '</span>'
		var liOpenTag	= '<li class="last">'
		
		if (onBioPage())
		{
			// We're rendering the bio page.
			linkText = liOpenTag + '<a href="javascript:showBio()" id="currentGallery">' + linkText + '</a></li>'
		}
		else
		{
			// We're rendering some other page.
			linkText = liOpenTag + '<a href="javascript:showBio()">' + linkText + '</a></li>'
		}
		
		galleryNavString += linkText
	}
	
	
	// Wrap it up...
	galleryNavString = '<ul>' + galleryNavString + '</ul>'

	// ... and send it home.
	document.write(galleryNavString)
}



// ------------------------------------------------------------------------------------------------------------
//	writePreviousNext
// ------------------------------------------------------------------------------------------------------------
function writePreviousNext()
{
	/* writePreviousNext() writes an unordered list of links in the form:
			
			<ul>
				<!-- "previous" -->
				<li class="fotonav_previous"><a href="javascript:showPreviousFoto()"><span>&lt;</span></a></li> 

				<!-- "next" -->
				<li class="fotonav_next"><a href="javascript:showNextFoto()" alt="next >"><span>&gt;</span></a></li> 
			</ul>
	*/

	document.write('<ul>\n');
	document.write('<!-- "previous" -->\n<li class="fotonav_previous"><a href="javascript:showPreviousFoto()"><span>&lt;</span></a></li>\n\n');
	document.write('\n<!-- "next" --><li class="fotonav_next"><a href="javascript:showNextFoto()"><span>&gt;</span></a></li>\n\n');
	document.write('</ul>\n');
}


// ------------------------------------------------------------------------------------------------------------
//	fotoNavNumbers
// ------------------------------------------------------------------------------------------------------------
function fotoNavNumbers()
{
	/* fotoNavNumbers() returns an unordered list of links in the form:
			
			<li><a href="javascript:showFoto(currentGalleryIndex, 0)">00</a></li>
			<li><a href="javascript:showFoto(currentGalleryIndex, 1)">01</a></li>
			<li><a href="javascript:showFoto(currentGalleryIndex, 2) id="currentFoto">02</a></li> // this is the current photo
			<li><a href="javascript:showFoto(currentGalleryIndex, 3)">03</a></li>
	*/

	// the fotos nav
	
	var fotonavString = '';
	
	var fotoCount = document.toc.galleries[document.galleryIndex].entries.length
	for (var f = 0; f < fotoCount; f++) 
	{
		var linkText = String(f)

		if (f < 10)
		{
			linkText = "0" + linkText
		}
	
		linkText = '<span>' + linkText + '</span>';
		
		var liOpenTag = '<li>';
		
		if (f == fotoCount - 1)
		{
			liOpenTag = '<li class="last">'
		}
	
		var actionText = 'javascript:showFoto(' + document.galleryIndex + ', ' + f + ')'
		if (f == document.fotoIndex)
		{
			linkText = liOpenTag + '<a href="' + actionText + '" id="currentFoto">' + linkText + '</a></li>\n'
		}
		else
		{
			linkText = liOpenTag + '<a href="' + actionText + '">' + linkText + '</a></li>\n'
		}
		
		fotonavString += linkText
 	}
		
	return fotonavString
}

// ------------------------------------------------------------------------------------------------------------
//	writeFotoNavNumbers
// ------------------------------------------------------------------------------------------------------------
function writeFotoNavNumbers()
{
	/* writeFotoNavNumbers() writes an unordered list of links in the form:
			
			<ul>
				<!-- "previous" -->
				<li class="fotonav_previous"><a href="javascript:showPreviousFoto()"><span>&lt;</span></a></li> 

				<li><a href="javascript:showFoto(currentGalleryIndex, 0)">00</a></li>
				<li><a href="javascript:showFoto(currentGalleryIndex, 1)">01</a></li>
				<li><a href="javascript:showFoto(currentGalleryIndex, 2) id="currentFoto">02</a></li> // this is the current photo
				<li><a href="javascript:showFoto(currentGalleryIndex, 3)">03</a></li>

				<!-- "next" -->
				<li class="fotonav_next"><a href="javascript:showNextFoto()"><span>&gt;</span></a></li> 
			</ul>
	*/

	document.write('<ul id="foto_list">\n');
	document.write('<!-- "previous" -->\n<li class="fotonav_previous"><a href="javascript:showPreviousFoto()"><span>&lt;</span></a></li>\n\n');
	document.write(fotoNavNumbers())
	document.write('\n<!-- "next" --><li class="fotonav_next"><a href="javascript:showNextFoto()"><span>&gt;</span></a></li>\n\n');
	document.write('</ul>\n');
}

// ------------------------------------------------------------------------------------------------------------
//	writeBannerText
// ------------------------------------------------------------------------------------------------------------
function writeBannerText()
{
	if (!document.siteDetails)
	{
		document.siteDetails = new SiteDetails()
	}
	
	document.write('<span>' + document.siteDetails.banner + '</span>')
}

// ------------------------------------------------------------------------------------------------------------
//	writeContactInfo
// ------------------------------------------------------------------------------------------------------------
function writeContactInfo()
{
	if (!document.siteDetails)
	{
		document.siteDetails = new SiteDetails()
	}
	
	document.write('<span>' + document.siteDetails.contact + '</span>')
}

// ------------------------------------------------------------------------------------------------------------
//	writeBio
// ------------------------------------------------------------------------------------------------------------
function writeBio()
{
	if (!document.siteDetails)
	{
		document.siteDetails = new SiteDetails()
	}
	
	document.write('<span>' + document.siteDetails.bio + '</span>')
}

// ------------------------------------------------------------------------------------------------------------
//	writeCopyrightInfo
// ------------------------------------------------------------------------------------------------------------
function writeCopyrightInfo()
{
	if (!document.siteDetails)
	{
		document.siteDetails = new SiteDetails()
	}

	document.write('<span>' + document.siteDetails.copyright + '</span>')
}

// ------------------------------------------------------------------------------------------------------------
//	writePageTitle
// ------------------------------------------------------------------------------------------------------------
function writePageTitle()
{
	if (!document.siteDetails)
	{
		document.siteDetails = new SiteDetails()
	}

	document.write(document.siteDetails.pageTitle)
}

