
	$(document).ready(function(){
		
		
		// ! Galleria
		// ----------------------------------------------------------
			$('#gallery').galleria({
				autoplay: 5000,
				transitionSpeed: 800,
				transition: "fade",
        height:500
    	});
		
		
		// ! home page image rollovers
		// ----------------------------------------------------------
			$('#home_header .hm_img').each(function(){
				$(this).find('img').hover(
					function(){
						$(this).addClass('nofade');
						$('#home_header img:not(.nofade)').stop(true, false).animate({opacity: .50});
						},
					function(){
						$(this).removeClass('nofade');
						$('#home_header img:not(.nofade)').stop(true, false).animate({opacity: 1.0})
						}
				);
			});
		
		
		
		// ! event page gallery button rollovers
		// ----------------------------------------------------------
			$('#gallery_list li a.big_button').each(function(){
				
				$(this).css({ 'background-position' : '0 0', 'opacity' : 0 });
				
				$(this).hover(
					function(event){
						event.preventDefault();
						$(this).animate({ opacity: 1.0 }, 'slow');
						},
					function(event){
						event.preventDefault();
						$(this).animate({ opacity: 0 }, 'slow')
						}
				);
				
				var uls = $(this).next().hide();
				$(this).click(function(){
					
					if ($(this).next().hasClass('open')) {
						$(this).next().slideUp('slow').removeClass('open');
					} else {
						$('#gallery_list ul').slideUp('slow').removeClass('open');
						$(this).next().slideDown('slow').addClass('open');
					}
					return false;
				
				});
				
			});
		
		
		// ! columnize paragrphs
		// ----------------------------------------------------------
		$('.columnize').each(function(){
			$(this).columnize({columns: 2, balanced: true}).append('<div class="clear"></div>');
			$(this).find('.column:last').addClass('last_column');
		});
		
		$('.column ul li').each(function(){
			if ($(this).text() == "") {
				$(this).remove();
			}
		});
		
		
		// ! team page image rollovers
		// ----------------------------------------------------------
			$('#team_matrix_list li').each(function(){
				$(this).hover(
					function(){
						$(this).addClass('nofade');
						$('#team_matrix_list li:not(.nofade)').stop(true, false).animate({opacity: .50});
						},
					function(){
						$(this).removeClass('nofade');
						$('#team_matrix_list li:not(.nofade)').stop(true, false).animate({opacity: 1.0})
						}
				);
			});
		
		
		// ! team page fancy box
		// ----------------------------------------------------------
			$('#team_matrix_list a').fancybox({
																	'hideOnContentClick': true,
																	'overlayColor' : '#000',
																	'overlayOpacity' : .5,
																	'autoDimensions' : true,
																	'titleShow' : false,
																	'padding' : 20
																	});

		
		
		// ! #footer_hldr goes on the bottom all the time!
		// ----------------------------------------------------------
			// get the window height
			function getWindowHeight() {
				var windowHeight = 0;
				windowHeight = $(window).height();
				return windowHeight;
			}
			
			
			// set the footer size
			function setFooter() {
					
				var windowHeight = getWindowHeight();
				
				if (windowHeight > 0) {
				
					var wrapperHeight = $('#wrapper').outerHeight();
					var footerHeight = $('#footer_hldr').outerHeight();
					
					if (windowHeight - (wrapperHeight+footerHeight) >= 0) {
					
						$("#wrapper").css('height', (windowHeight - (wrapperHeight+footerHeight)) + wrapperHeight + "px");
					
					} else {
						
						$("#wrapper").css('height', 'auto');
			
					}
					
				}
			}
			
			setFooter();
			
			// place footer
			$(window).resize(function(){
				setFooter();
			});
		
		
		// ! inputs get selected on focus
		// ----------------------------------------------------------
			$("input[type=text], textarea").focus(function(){
		    this.select();
			});
			
		
		// ! add has_img to blog .post_content <p> that contain <img>
		// ----------------------------------------------------------
			$('.post_content p img').each(function(){
				$(this).parent('p').addClass('has_img');
			});
		
		
		// ! add no_margin class to every third list element
		// ----------------------------------------------------------
			$('#team_matrix_list li:nth-child(3n)').addClass('no_margin');
		
		
		// ! add no_margin class to every third list element
		// ----------------------------------------------------------
		$("#flash_intro").fancybox({
			'padding'           : 0,
			'autoScale'     		: false,
			'hideOnContentClick': true,
			'overlayColor' 			: '#000',
			'overlayOpacity' 		: .5,
			'autoDimensions' 		: true,
			'titleShow' 				: false,
			'width'							: 675,
			'height'						: 494
		});
		$("#flash_intro").trigger('click');


			/*
var flashvars = {};
			var params = {};
			var attributes = { id: "intro", name: "intro" };
			swfobject.embedSWF("/wp-content/themes/switch_blank/_swf/flash_intro.swf", "flash_intro", "675", "428", "10", "/path/to/expressinstall.swf", flashvars, params, attributes);
*/
		
	});
