(function($) {
	$(document).ready(function() {
		if ( $('#skillsSpecification').length ) { 
			$('#skillsSpecification').delay(3000).fadeIn(3000);
		}
		
		$('#skillsSpecification a').hover(function() {
			// Add active class to selected <a> tag.
			$(this).addClass(' active');
			
			if ( $(this).attr('rel') == 'left' ) { 
				if ( $('#leftDetailsBox').css('left') == '-239px' ) { 
					var heading = $(this).text();
					$.post('templates/skills.php', {skill:heading}, function(data) {
						$('#leftDetailsBox h6').text( heading );
						$('#leftDetailsBox p.description').text( data );
						$('#leftDetailsBox').show().animate({ left: '0' }, 'fast');
					});
				}
			}
			else if ( $(this).attr('rel') == 'right' ) { 
				if ( $('#rightDetailsBox').css('right') == '-239px' ) { 
					var heading = $(this).text();
					$.post('templates/skills.php', {skill:heading}, function(data) {
						$('#rightDetailsBox h6').text( heading );
						$('#rightDetailsBox p.description').text( data );
						$('#rightDetailsBox').show().animate({ right: '0' }, 'fast');
					});
				}
			}
			
			//$('div.boxToggle div.redBoxBg').append('<p class="close"><a href="#" onclick="hideDetailsBox(this); return false;">Close [X]</a></p>');
			return false;
		}, function() {
			// Hide Left and Right Boxes 
			$('#leftDetailsBox').animate({left:'-239'}, 'fast');
			$('#rightDetailsBox').animate({right:'-239'}, 'fast');
			$('p.close').remove();
			
			// Clear active class from all <a> tags before adding the class to active tag.
			$('#skillsSpecification a').each(function() {
				$(this).removeClass(' active');
			});
		}); // end skillsSpecification a hover function 
		
		$('div.clientList a[rel]').click(function() {
			$('div.clientList a.active').each(function() {
				$(this).removeClass('active');
			});
			
			var divName = $(this).attr('rel');
			$(this).addClass('active');
			$('div.selectedWorkTestimonial blockquote').html( $('.' + divName + ' div.testimonial').html() );
			$('div.testimonialName p.red').html( $('.' + divName + ' div.clientName').html() );
			return false;
		}); // end div.clientList a[rel] function
		
	}); // end document.ready function 
})(jQuery);

function hideDetailsBox(element) {
	(function($) {
		var parentID = $(element).parent().parent().parent().attr('id');
		var direction = parentID.replace(/DetailsBox/, '');
		var statement = "$('#" + parentID + "').animate({ " + direction + ": '-239' }, 'normal');";
		
		eval(statement);
		// Clear active class from all <a> tags before adding the class to active tag.
		$('#skillsSpecification a').each(function() {
			$(this).removeClass(' active');
		});
		return false;
	})(jQuery);
}
