$(document).ready(function(){

	// ***** highlight current topnav list elements

		$("#topnav li").find('a[href="'+document.location.href+'"]').each(function() { 
			$(this).parent('li').addClass("active");
		});

	// ***** highlight current bottomnav list elements

		$("#bottomnav li").find('a[href="'+document.location.href+'"]').each(function() { 
			$(this).addClass("active");
		});	

	// ***** open in new window when a rel="external"

		$('a[rel=external]').each(function() {
			if ($(this).attr('rel') == 'external') {
				$(this).attr('target', '_blank');
			}
		});

	// ***** image swapper
		
		$.swapImage(".swap-image"); 

	// ***** jquery carousel lite

		$("#recentwork-carousel").jCarouselLite({
		    btnNext: ".carousel-next",
		    btnPrev: ".carousel-prev",
			visible: 1,
			speed: 500,
			circular: true
		});

	// ***** service lists	

		$(".service").hover(
			function () {
				$(this).addClass("active");
			}, 
			function () {
				$(this).removeClass("active");
			}
		);
		
		$(".services-provided li").hover(
			function () {
				$(this).addClass("active");
			}, 
			function () {
				$(this).removeClass("active");
			}
		);
		
		$(".services-provided li:last").addClass("last");

	// ***** highlight current service list element

		$(".service").find('a[href="'+document.location.href+'"]').each(function() { 
			$(this).parent().parent().addClass("current"); //.find('p').fadeIn('slow');
		});

	// ***** work grid	

		$("#work-grid .grid-3").hover(
			function () {
				$(this).addClass("active");
			}, 
			function () {
				$(this).removeClass("active");
			}
		);	

	// ***** work gallery	
		
		/*
		$('#gallery-navigation li:first a').addClass("active");
	
		$('#gallery-navigation li a').click(function(){ 
			$("#gallery-navigation li a").removeClass("active");
			$(this).addClass("active");
			$('#gallery-image img').hide().attr('src', this.href).fadeIn("slow").attr('alt', this.title); 
			$('#gallery-image-caption').hide().html(this.title).fadeIn("slow"); 
			return false;
		}); 
	
		$("#gallery-navigation li a").each(function(){ 
			//alert(this.href);
			$.preloadImages(this.href);
		});
		*/

	// ***** clear input.text on focus, if still in default

		$('input#captcha').focus(function() {	
			if($(this).val()==$(this).attr('alt')) {
		    	$(this).val('');
			}
		});
	
	// ***** if field is empty afterward, add text again

		$('input#captcha').blur(function() {
			if($(this).val()=='') {
				$(this).val($(this).attr('alt'));
			}
		});
	
	// ***** open link (image) via fancybox
		
		$("a.fancybox").fancybox({
			'zoomSpeedIn':		300, 
			'zoomSpeedOut':		300, 
			'overlayColor':		'#000',
			'overlayOpacity':	.75
		});
	
});
