// JavaScript Document

$(document).ready(function() {
	 $('#fbIcon').hover(function(){
		$(this).animate({top: "0px"}, 200)}, 
		function(){$(this).animate({top: "8px"}, 200)
	 });
	 
	 $('#twitIcon').hover(function(){
		$(this).animate({top: "0px"}, 200)}, 
		function(){$(this).animate({top: "8px"}, 200)
	 });
	 
	 $('#emIcon').hover(function(){
		$(this).animate({top: "0px"}, 200)}, 
		function(){$(this).animate({top: "8px"}, 200)
	 });
});
		
	
	/*Nav Menu Drop Down */
	$(function () {
		$(".dropdown").each(function () {
			$(this).parent().eq(0).hover(function () {
				$(".dropdown:eq(0)", this).fadeIn(300);
			}, function () {
				$(".dropdown:eq(0)", this).fadeOut(400);
			});
			
			$(this).parent().eq(0).mouseleave(function(event){
			  event.stopPropagation();
			});

		});
	});
	
	$(".first").mouseleave(function(event){event.stopPropagation();});
	
	//This is the slideshow on the homepage
	function slideSwitch() {
		 var $active = $('#photoSlideShow img.active');
	
		 if ( $active.length == 0 ) $active = $('#photoSlideShow img:last');
	
		 var $next =  $active.next().length ? $active.next()
			  : $('#photoSlideShow img:first');
	
		 $active.addClass('last-active');
	
		 $next.css({opacity: 0.0})
			  .addClass('active')
			  .animate({opacity: 1.0}, 500, function() {
					$active.removeClass('active last-active');
			  });
	}
	
	$(function() {
		 setInterval( "slideSwitch()", 3100 );
	});
	
	//Portfolio Gallery Functionality
	$(document).ready(function() {
		$('.left-col-thumbs img').each(function(){
			$(this).click(function(){
				switchImage($(this).attr("rel"), $(this).attr("alt"), $(this).attr("src"));
			});
		
		//$('.left-col-thumbs a').each(function(){
		//	$(this).click(function(){
		//	});
		});
		
		//Switch Image in larger portfolio area
		function switchImage(imageName, alt, src){
			$('.right-col-picture a').attr("href", src.replace('thumbs', 'full-size'));
			$('.right-col-picture img').fadeOut(400, function(){
					$('.right-col-picture img').attr("src", src.replace('thumbs', 'medium'));});
			$('.right-col-picture img').attr("alt", alt);
			$('.right-col-picture img').fadeIn(300);
		};
	});