$(document).ready( function() {
	
	
	var bodyClass = $('body').attr('class');
	var navClass = 'nav-' + bodyClass;

	$('.li-art a').eq(0).click(function(e) {
		e.preventDefault();
		window.location = "/between-memory-and-perception/";
	});
	$('.li-bio a').eq(0).click(function(e) {
		e.preventDefault();
		window.location = "/biography-cv/";
	});
	$('.li-essays a').eq(0).click(function(e) {
		e.preventDefault();
		window.location = "/pierre-coupey-between-memory-and-perception/";
	});
	
	
	$('.li-art .nav-link-tier2').click(function(e) {
		e.preventDefault();					  
	});
	
	if ($('#nav li.li-art a').hasClass(navClass)) {
		$('#nav .li-art .nav-list-tier2').addClass('nav-sidebar');
	}
	
	if ($('#nav li.li-essays a').hasClass(navClass)) {
		$('#nav .li-essays .nav-list-tier2').addClass('nav-sidebar');
	}
	
	if ($('#nav li.li-bio a').hasClass(navClass)) {
		$nav_bio = $('#nav .li-bio .nav-list-tier2');
		$nav_bio.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><img width="200" height="157" src="http://static.coupey.ca/images/photos/coupey_painting.jpg" class="portrait"><p id="cutline">Photo &copy; Wayne Leidenfrost</p></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	}
	
	
	if ($('body.preface-to-notations-duncan-mcnaughton').length > 0) 
	{
		$nav_essays = $('#nav .li-essays .nav-list-tier2');
		$nav_essays.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><a href="/for-the-poets/"><img width="200" height="217" src="http://static.coupey.ca/images/paintings/Imaginary-Portrait-Milton-Acorn_200px.jpg" class="portrait" /></a></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	} 
	else if ($('body.ars-poetica-the-notations-of-pierre-coupey-paula-gustafson-curator').length > 0) {
		$nav_essays = $('#nav .li-essays .nav-list-tier2');
		$nav_essays.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><a href="/notations/?p=15"><img src="http://static.coupey.ca/images/paintings/notations20_m.jpg" height="237" width="200" /></a></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	} 
	else if ($('body.pierre-coupey-notations-gregory-strong').length > 0) {
		$nav_essays = $('#nav .li-essays .nav-list-tier2');
		$nav_essays.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><a href="/notations/?p=5"><img src="http://static.coupey.ca/images/paintings/notations7_200px.jpg" height="237" width="200" /></a></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	} 
	else if ($('body.tangle-the-paintings-of-pierre-coupey-darrin-martens-curator').length > 0) {
		$nav_essays = $('#nav .li-essays .nav-list-tier2');
		$nav_essays.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><a href="/tangle/?p=11"><img height="245" width="200" src="http://static.coupey.ca/images/thumbs/thicket_m.jpg" /></a></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	} 
	else if ($('body.preface-to-counterpoint-marcus-bowcott').length > 0) {
		$nav_essays = $('#nav .li-essays .nav-list-tier2');
		$nav_essays.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><a href="/counterpoint-lebanon/"><img width="200" src="http://static.coupey.ca/images/paintings/01_lebanon_lebanon.jpg" /></a></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	} 
	else if ($('body.liz-wylie').length > 0) {
		$nav_essays = $('#nav .li-essays .nav-list-tier2');
		$nav_essays.addClass('nav-sidebar');
		$('#header').append('<div id="portrait"><a href="/counterpoint-komyo/?p=8"><img width="200" src="http://lh6.ggpht.com/543sBXXfv9IBb22BbmPybeKH0wBhR9xHNUT8HmnAaLiN_Sf1HGCX42_vAUnsWBxK7SyqGnavR9Vu=s350" /></a></div>');
		$('#portrait').css('top', $('.nav-sidebar').height()+15).show();
	} 
	
	
	
	
	
	
	
	
	






	function getParameterByName(name) {
	  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	  var regexS = "[\\?&]" + name + "=([^&#]*)";
	  var regex = new RegExp(regexS);
	  var results = regex.exec(window.location.href);
	  if(results == null)
		return "";
	  else
		return decodeURIComponent(results[1].replace(/\+/g, " "));
	}
	var currentPic = 0;
	if ( getParameterByName('p').length > 0) {
		$('.slideshow-photo-item').first().hide();
		currentPic = parseInt(getParameterByName('p')) - 1;
		$('.slideshow-photo-item').eq(currentPic).show();
		$('.thumb-selected').removeClass('thumb-selected');
		$(".slideshow-thumb-pic").eq(currentPic).addClass('thumb-selected');
	}
	
	
	
	
	
});
