$(function() {

			// Options for SuperBGImage
			$.fn.superbgimage.options = {
				showimage: 1, // number of first image to display
				randomtransition: 0, // 0-none, 1-use random transition (0-7)
				vertical_center: 1, // 0-align top, 1-center vertical
				transition: 1, // 0-none, 1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide right, 6-blind horizontal, 7-blind vertical, 90-slide right/left, 91-slide top/down
				transitionout: 1, // 0-no transition for previous image, 1-transition for previous image
				slideshow: 1, // 0-none, 1-autostart slideshow
				slide_interval: 20000, // interval for the slideshow
				randomimage: 0, // 0-none, 1-random image
				showtitle: 1, // 0-none, 1-show title
				preload: 1, // 0-none, 1-preload images
				speed: 'slow', // animation speed
				onShow: title, // function-callback show image
				onHide: hide_title, // function-callback hide image
				
				
			};

			// initialize SuperBGImage
			$('#thumbs').superbgimage();
			
			// prev slide
			$('a.prev').click(function() {
				return $('#thumbs').prevSlide();
			});
		
			// next slide
			$('a.next').click(function() {
				return $('#thumbs').nextSlide();
			});
			
			$('a.info').hover(function() {
				//$('#showtitle').fadeIn('slow');
				$('#showtitle').animate({opacity: "show", width: "250px"}, "fast");
			}, function() {
				$('#showtitle').animate({opacity: "hide", width: "250px"}, "fast");;
			});

		});
		
		
		$(document).ready(function(){
			// Main Navigation Bar			
			$("#main-nav li").hover(function(){
				$(this).fadeTo("fast", 1.0); 
			},function(){
				$(this).fadeTo("fast", 0.8); 
			});
			
			// Social Media Icons			
			$("#socialbar img").hover(function(){
				$(this).fadeTo("fast", 1.0); 
			},function(){
				$(this).fadeTo("fast", 0.3); 
			});
			
			// Newgray Info
			$("h1#newgray").hover(function(){
				$('#newgrayinfo').animate({opacity: "show", bottom: "0px"}, "fast");
			},function(){
				$('#newgrayinfo').animate({opacity: "hide", bottom: "100px"}, "fast");				
			});
			
			// Popups
			$('a#work').click(function(){
				$('li#w').css('background-color', '#fff');
				$('li#w a').css('color', '#000');
				$('li#t, li#c').css('background-color', '#000');
				$('li#t a,li#c a').css('color', '#fff');
				$('#work-popup').animate({opacity: "show", top: "-425px"}, "fast");
				$('#team-popup').animate({opacity: "hide", top: "-240px"}, "fast");
				$('#contact-popup').animate({opacity: "hide", top: "-240px"}, "fast");
			});
			$('a#team').click(function(){
				$('li#t').css('background-color', '#fff');
				$('li#t a').css('color', '#000');
				$('li#w, li#c').css('background-color', '#000');
				$('li#w a,li#c a').css('color', '#fff');
				$('#team-popup').animate({opacity: "show", top: "-425px"}, "fast");
				$('#work-popup').animate({opacity: "hide", top: "-240px"}, "fast");
				$('#contact-popup').animate({opacity: "hide", top: "-240px"}, "fast");
			});
			$('a#contact').click(function(){
				$('li#c').css('background-color', '#fff');
				$('li#c a').css('color', '#000');
				$('li#t, li#w').css('background-color', '#000');
				$('li#t a,li#w a').css('color', '#fff');
				$('#contact-popup').animate({opacity: "show", top: "-425px"}, "fast");
				$('#team-popup').animate({opacity: "hide", top: "-240px"}, "fast");
				$('#work-popup').animate({opacity: "hide", top: "-240px"}, "fast");
			});
			$('a.close').click(function(){
				$('.popup').animate({opacity: "hide", top: "-240px"}, "fast");
				$('#main-nav li').css('background-color', '#000');
				$('#main-nav li a').css('color', '#fff');
			});
			
			// Slides			
			$('#slides-work').after('<div id="snav1" class="snav">') 
				.cycle({ 
			    fx:     'scrollLeft', 
			    speed:  'fast', 
			    timeout: 0, 
			    pager:  '#snav1' 
			});
			$('#slides-team').after('<div id="snav2" class="snav">') 
				.cycle({ 
			    fx:     'scrollLeft', 
			    speed:  'fast', 
			    timeout: 0, 
			    pager:  '#snav2' 
			});
			$('#slides-contact').after('<div id="snav3" class="snav">') 
				.cycle({ 
			    fx:     'scrollLeft', 
			    speed:  'fast', 
			    timeout: 0, 
			    pager:  '#snav3' 
			});
			
			
		});
		
	
		function title(img) {
			$('#superbgimage').append($('#showtitle'));
			$('#showtitle p.imagecount').html('image ' + img + ' of ' + $.superbg_imgIndex);
			$('#showtitle p.title').html($('#thumbs a' + "[rel='" + img + "']").attr('title'));
		}
		
		function hide_title(img) {
			$('#showtitle').fadeOut('fast');
		}
