var carLastActive = "car-intro";
var carLastIndex  = 1;

var shieldPreloader = {};

var navTypes = [ "contact", "employment", "gallery", "home", "services"];

(function($){
	
	/*
	$.each(navTypes, function(i, e) {
		var active = "images/nav-active-" + e + ".png";
		var down= "images/nav-down-" + e + ".png";
		var up = "images/nav-up-" + e + ".png";
		
		shieldPreloader[active] = new Image();
		shieldPreloader[down] = new Image();
		shieldPreloader[up] = new Image();
		
		shieldPreloader[active].src = active;
		shieldPreloader[down].src = active;
		shieldPreloader[up].src = active;
	});
	*/
	
	
	$(document).ready(function(){
		
		
		
		
		/* GALLERY */
		
		$('#nav-list li a').hover(
			// mouseEnter
			function(e){
				var item = $(this).attr('item');
				var textClass = 'nav-text-' + item;
				var buttonClass = 'nav-down-' + item;
				$('#nav-text').addClass(textClass);
				$(this).attr('class', buttonClass);
			},
			
			// mouseLeave
			function(e){
				$('#nav-text').attr('class','');
				$(this).attr('class', $(this).attr('orig-class'));
			}
		);
		
		
		$("li.thumb").hover(
			// mouseenter		
			function() {
				$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
				$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
					.animate({
						marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
						marginLeft: '-110px',
						top: '50%',
						left: '50%',
						width: '180px', /* Set new width */
						height: '135px' /* Set new height */
					}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
		
			} ,
			
			// mouseleave
			function() {
				$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
				$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
					.animate({
						marginTop: '12px', /* Set alignment back to default */
						marginLeft: '12px',
						top: '0',
						left: '0',
						width: '128px', /* Set width back to default */
						height: '89px' /* Set height back to default */
					}, 400);
		});
		
		$("li.thumb img").click(function(){
			var src = $(this).attr('src');
			var m = src.match(/(images\/photos\/thumbs\/)(.*)/);
			var newSrc = 'images/photos/' + m[2];
			$('#image-container').css('z-index', '15');
			$('#image').attr('src', newSrc);
			$('#image').animate( {left: '0px'}, { duration: 1000, easing: 'easeOutBounce' } );
		});

		$('#image-container').click(function() {
			$('#image').animate(
				{ left: '500px' },
			    { duration: 400,
				  easing: 'easeOutElastic',
                  complete: function() {
				      $('#image-container').css('z-index', '-1000');
			      }
				}
			);	
		});



		var opt = {
			api_key: '6682e529b68ecbad4ffe38eb06c2a7b2',
			photoset_ids: [
				'72157624992285341',
				'72157625225599940',
				'72157625109334145',
				'72157625109338379',
				'72157625234131596'
			],
			loading_msg: '<div align="center"><div>Loading from flickr...</div><br><div class="ajax-loader"></div></div>',
			thumb_click_hide: true
		};
		$('#flickr-gallery').flickrGallery(opt);

		$.preloadCssImages();
		
		

	});
})(jQuery);

