$(document).ready(function() {


// top navigation
$('#nav > ul').hide();
$('#nav > li').hover(function(){
	$(this).find('ul:first').fadeIn();
}, function(){
	$(this).find('ul:first').fadeOut('fast');
});	

if ($.browser.msie && parseInt($.browser.version, 10) < 9){ $('#main').wrapInner('<div id="stupidIE"></div>'); }

//adding show/hide link, excluding blog
if ($('body').hasClass('blog') || $('body').hasClass('archive') || $('body').hasClass('single') ) {}
else {
	var showHideLnk = $('<a class="showHideLnk" href="#">show picture</a>');
	$('.photo-credits').append(showHideLnk);
	
	
	$(showHideLnk).click(function(){
		var LnkTxt = $(this).text();
		if (LnkTxt == 'show picture') {
			
			$('#main').animate( { 'opacity' : 0 }, 'fast');
			if ($.browser.msie && parseInt($.browser.version, 10) < 9){ $('#nav, #stupidIE').css({ visibility : 'hidden' }); };
			
			$('#header').animate( { 'opacity' : 0 }, 'fast', function(){
				$(showHideLnk).text('show content');
			});
			
		}
		else {
			$('.quotes li').hide();
			quoteInnerFade();
			$('#main').animate( { 'opacity' : 1 }, 'fast');
			
			$('#header').animate( { 'opacity' : 1 }, 'fast', function(){
				$(showHideLnk).text('show picture'); 
				if ($.browser.msie && parseInt($.browser.version, 10) < 9){ $('#nav, #stupidIE').css({ visibility : 'visible' }); };
			});
		}
		
		return false;
	})

}


$('.locationList li').css({ 'cursor': 'pointer'}).click(function(){
	var theLink = $('a', this).attr('href');
	window.location = theLink;
})



//quote innerfade

var quotes  = $('.quotes li');
$('.quotes li:gt(0)').hide();
var quotesTtl = quotes.length;

var cur, ind = 0;
var quoteInnerFade = function()	{
	cur = ind;
	ind++;
	if (ind == quotesTtl ) { ind = 0 };
	$(quotes[cur]).fadeOut(700, function(){
		$(quotes[ind]).fadeIn( 700);
	}); 
	
	}	

var interval = setInterval(quoteInnerFade, 5000);

$(window).blur(function() {
  clearInterval(interval);
}).focus(function() {
  interval = setInterval(quoteInnerFade, 5000);
});
	

});

