//smooth scrool to hashtag links----------------

//script source: http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links

$(document).ready(function(){
	if($(window).width() > 750){
		  $('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
			&& location.hostname == this.hostname) {
			  var $target = $(this.hash);
			  $target = $target.length && $target
			  || $('[name=' + this.hash.slice(1) +']');
			  if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
			   return false;
			  }
			}
		  });
	}
	
	
	
	//fade effects on logo and nav buttons--------------
	$('#nav a').mouseenter(function(){$(this).stop().fadeTo(200, 0.7)}).mouseleave(function(){$(this).stop(true,true).fadeTo(200, 1.0)});
	
	$('h1#siteTitle a').mouseenter(function(){$(this).stop().fadeTo(200, 0.7)}).mouseleave(function(){$(this).stop(true,true).fadeTo(200, 1.0)});
	
	$('#switch').mouseenter(function(){$(this).stop().fadeTo(200, 0.4)}).mouseleave(function(){$(this).stop(true,true).fadeTo(200, 1.0)});
	
	$('#nav a').click(function(){
		$('.tooltip').stop(true,true).slideUp();
	});
	$('h1#siteTitle a').click(function(){
		$('.tooltip').stop(true,true).slideUp();
	});
	$('h2 a').click(function(){
		$('.tooltip').stop(true,true).slideUp();
	});
	
	//fading tooltips---------------------
	$('.item img').hoverIntent(function(){
			$('.tooltip').stop(true,true).slideUp();
			//$('.tooltip').slideUp();
			
			$(this).parent().find('.tooltip').addClass('visibleTooltip').slideDown(500);
			
			if($.browser.msie && $.browser.version=="8.0"){
				$('p#instructions').remove();
				//$('.tooltip').append('<p style="color:orange;" id="instructions">[ x ] Click here to close</p>');
			}
			
			if($.browser.msie && $.browser.version=="7.0"){
				$('.tooltip').find('#instructions').remove();
				//$('.tooltip').append('<p style="color:orange;" id="instructions">[ x ] Click here to close</p>');
			}
	
	},
	function(){});
	
	$('.item img').mouseleave(function(){
		$(this).parent().find('.tooltip').slideUp();
		
	});
	
	$('.tooltip').click(function(e){
		e.preventDefault();
		$(this).slideUp();
	});
	
	
	//show toggle instructions, hide portfolio pieces
	$('#portfolio .block h3 span.collapseInstr').show();
	//$('#portfolio .block h3').siblings().hide();
	//$('#portfolio .block').css('padding-bottom','0').css('padding','0').css('margin-bottom','-40px')
	
	//-----accordian portfolio sections code
	$('#portfolio .block h3').click(function(){
		$('.tooltip').stop(true,true).slideUp();
		$(this).siblings().stop(true,true).fadeToggle();
	});
	
});
