/* ***********************************
 * main.js
 *
 * site:	www.geoffscottphotography.com
 * author:	Geoff Scott
 * version:	1.0.0
 * update:  2010.06.19
 *
 *********************************** */

function CopyrightNotice()
{
	document.write('<div id="copyright">');
	document.write('&copy; 2006-2011 by Geoff Scott');
	document.write('</div>');
}

function EmailAddress()
{
	// Email obfuscator script 2.1 by Tim Williams, University of Arizona
	// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
	// This code is freeware provided these four comment lines remain intact
	// A wizard to generate this code is at http://www.jottings.com/obfuscator/

	coded = "If8ee@If8ee9T8WW0Q8W8IDd0QU.T8v";
	key = "Sn2ZjN9F8cpiOrYug4UqdfblvWkJ53hM7ECKRsBoT0PwD6GIzyXaeVLmtxAH1Q";
	shift = coded.length;
	link = "";
	for (i = 0; i < coded.length; i++)
	{
		if (key.indexOf(coded.charAt(i)) == -1)
		{
			ltr = coded.charAt(i);
			link += (ltr);
		}
		else
		{     
			ltr = (key.indexOf(coded.charAt(i)) - shift + key.length) % key.length;
			link += (key.charAt(ltr));
	    }
	}
	document.write("<a href='mailto:" + link + "'>" + link + "</a>");
}

function ContactInfoFooter()
{
	document.write('<div id="contact">');
	document.write('<span id="phone">858.413.5844</span>');
	document.write('<span id="email">');
	EmailAddress();
	document.write('</span>');
	document.write('</div>');
}

function SiteNavPlate(depth, active, extra)
{
	var path_pre = "";
	for (i = 0; i < depth; i++)
	{
		path_pre = path_pre + "../";
	}
	
	var bIncludeMouseOver = true;
	if (extra == "Concrete" || extra == "Locals" || extra == "CoWorkers" || extra == "Recent" || extra == "All")
	{
		bIncludeMouseOver = false;
	}
	
	var m1 = "'m1'";	// quote problem hack
	
	document.write('<div id="site_nav">');
	document.write('<ul id="sddm">');
	document.write('<li><a href="' + path_pre + 'index.html"' + MarkActive(active, "Home") + '>Home</a></li>');

	document.write('<li><a href="' + path_pre + 'projects/index.html"' + MarkActive(active, "Projects"));
	if (bIncludeMouseOver)
	{
		document.write(' onmouseover="mopen('+ m1 + ')" onmouseout="mclosetime()"');
	}
	document.write('>Projects</a></li>');

	document.write('<li><a href="' + path_pre + 'links/index.html"' + MarkActive(active, "Links") + '>Links</a></li>');
	document.write('<li><a href="' + path_pre + 'about/index.html"' + MarkActive(active, "About") + '>About</a></li>');
	document.write('</ul>');

	document.write('<ul id="m1"');
	if (bIncludeMouseOver)
	{
		document.write(' onmouseover="mcancelclosetime()" onmouseout="mclosetime()" style="visibility:hidden;"');
	}
	else
	{
		document.write(' style="visibility:visible;"');
	}
	document.write('>');

	document.write('<li><a href="' + path_pre + 'projects/concrete_curves/index.html"' + MarkActive(extra, "Concrete") + '>Concrete Curves</a></li>');
	document.write('<li><a href="' + path_pre + 'projects/local_artists/index.html"' + MarkActive(extra, "Locals") + '>Local Artists</a></li>');
	document.write('<li><a href="' + path_pre + 'projects/coworkers/index.html"' + MarkActive(extra, "CoWorkers") + '>Co-Workers</a></li>');
	document.write('<li><a href="' + path_pre + 'projects/recent/index.html"' + MarkActive(extra, "Recent") + '>Recent</a></li>');
	document.write('<li><a href="' + path_pre + 'projects/index.html"' + MarkActive(extra, "All") + '>Archive</a></li>');
	document.write('</ul>');
	document.write('</div>');
}

function MarkActive(active, current)
{
	if (active == current)
		return(' id="current"');
	else
		return('');
}

function Page_Nav(current, total)
{
	if (current <= total && current > 0 && total > 0)
	{
		document.write('<div id="page_nav">');
		document.write('<ul id="page_list">')
		
		// written in reverse order because of float right style
		// last
		document.write('<li><a href="index' + total + '.html">last  &gt; &gt;</a></li>');

		// next		
		if (current == total)
		{
			document.write('<li><a href="index.html">next &gt;</a></li>');
		}
		else
		{
			document.write('<li><a href="index' + (current + 1) + '.html">next &gt;</a></li>');
		}
	
		// put page menu here
		var m2 = "'m2'";	// quote problem hack

		document.write('<li><a href="#" onmouseover="mopen(' + m2 + ')" onmouseout="mclosetime()">&#x25BC; ' + current + ' of ' + total + '</a>');
		document.write('<div id="m2" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">');

		for (i = 1; i <= total; i++)
		{
			if (i == 1)
			{
				document.write('<a href="index.html">' + i + '</a>');
			}
			else
			{
				document.write('<a href="index' + i + '.html">' + i + '</a>');				
			}
		}
		
		document.write('</div>');	// end of m2
		document.write('</li>');

		// previous
		if (current == 1)
		{
			document.write('<li><a href="index' + total + '.html">&lt; prev</a></li>');
		}
		else if (current == 2)
		{
			document.write('<li><a href="index.html">&lt; prev</a></li>');
		}
		else
		{
			document.write('<li><a href="index' + (current - 1) + '.html">&lt; prev</a></li>');
		}
	
		// first
		document.write('<li><a href="index.html">&lt; &lt; first</a></li>');
		
		document.write('</ul>')
		document.write('</div>');
	}
}

function ContactInfo()
{
	document.write('<ul>');
	document.write('<li>858.413.5844</li>');
	document.write('<li>');
	EmailAddress();
	document.write('</li>');
	document.write('<li><a href="http://www.facebook.com/geoffscottphotography">Facebook</a></li>');
	document.write('<li><a href="http://www.linkedin.com/pub/1/2b3/947">LinkedIn</a></li>');
	document.write('</ul>');
}

function SiteIcon()
{
	document.write('<link rel="Shortcut Icon" href="/favicon.ico">');
}

function AnalyticsHeadEnd()
{
	SiteIcon();
	
	// Google Analytics (asynchronous)
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-10276438-1']);
	  _gaq.push(['_trackPageview']);

	  (function() {
	    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();
}

function AnalyticsBodyEnd()
{
	// Google Analytics (traditional)
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	
	try
	{
		var pageTracker = _gat._getTracker("UA-10276438-1");
		pageTracker._trackPageview();
	}
	catch(err) {}
}
