function cultureBuild(){
	
	// Place team members in grid
	function teamMember(){
		$('#loading-bay .team_member').each(function(i){
				$('#inside_list .team_member').eq(i).append(($(this).html()));
			});
		}
	// Place twitter posts in grid
	function twitterStream(){
		$('#loading-bay .tweet').each(function(i){
				$('#inside_list .tweet').eq(i).append(($(this).html()));
			});
		}
		
	// Place Apply ads in grid
	function applyHere(){
		$('#loading-bay .apply').each(function(i){
				$('#inside_list .apply').eq(i).append(($(this).html()));
			});
		}
	
	// Get music from servcice
	function getMusic(){

		// Make album request
		$.ajax({
			type: "GET",
			url: "http://ws.audioscrobbler.com/2.0/?method=library.getalbums&api_key=9e92c9107fca48169678462f3b0e900a&user=prplrock",
			dataType: "xml",
			success: parseAlbum
		});
		
		// Parse albums
		function parseAlbum(xml) {
		    $(xml).find("album").each(function () {
		        $("#loading-bay").append('<div class="album"><div class="heading"><div class="title">' + $(this).find("name").first().text() + '</div><div class="artist">' + $(this).find("name").last().text() + '</div></div><div class="cover"><img src="' + $(this).find("image").last().text() + '"/></div></div>');
				});
			
			// Place album in grid
			$('#loading-bay .album').each(function(i){
				$('#inside_list .music').eq(i).append(($(this).html()));
				});
			}
			
			//setTimeout (($('#loading-bay').remove()),10000)
		}
	
	//Execute
	getMusic();
	applyHere();
	twitterStream();
	teamMember();
	
	}
	
$(document).ready(function(){


	//Build Culture Page
	cultureBuild();
	
	//TODO: Tempfix while twitter is acting stupid (JE)
//	$('#inside_list .tweet').eq(5).append($('#loading-bay .tweet').eq(1).html());
//    $('#inside_list .tweet').eq(6).append($('#loading-bay .tweet').eq(2).html());
//	$('#inside_list .tweet').eq(7).append($('#loading-bay .tweet').eq(3).html());
		
    // Homepage Hero Slider
    $('#homepage_hero').flexslider({
        animationDuration: 600,
        pauseOnHover: true,
        prevText: 'Prev',
        slideshow: false,
        start: function(slider) {
            slider.slides.eq(slider.currentSlide).addClass('active');
        },
        before: function(slider) {
            slider.slides.removeClass('active').eq(slider.animatingTo).addClass('active');
        }
    });
    
    // Work Filter
    $('#content.work .sub_nav li a').click(function() {
        $('#content.work .sub_nav li').removeClass('current');
        $(this).parent('li').addClass('current');
        thisItem = $(this).attr('rel');
        if(thisItem != 'all') {
            $('#work_list article[rel~='+thisItem+']').stop().animate({
                'opacity' : 1
            }, 200);
            $('#work_list article:not([rel~='+thisItem+'])').stop().animate({
                'opacity' : 0.1
            }, 200);
            } else {
            $('#work_list article').stop().animate({
                'opacity' : 1
            }, 200);
        }
    });
    
    // Work Sticky Nav
    $(function(){ 
		var scrollTimer = window.setInterval(scrollEnded, 0); 
        function scrollEnded(){ 
            offset = Math.round(window.pageYOffset); 
			if(offset >= 170) {
                $('#content.work hgroup nav, #content.services hgroup nav, #content.contact nav').addClass('fixed');
            } else {
                $('#content.work hgroup nav, #content.services hgroup nav, #content.contact nav').removeClass('fixed');
            } 
        } 
    })
    
    // Work Services
    $('#wrapper.work-subpage #content .solutions ul li:nth-child(2n)').addClass('last');

    // Services Nav
    $(function(){
		var scrollTimer = window.setInterval(scrollEnded, 200);
        function scrollEnded(){
            offset = Math.round(window.pageYOffset);
			if(offset <= 650) {
                $('#content.services .sub_nav li:eq(1)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(1)').removeClass('current');
            }
            if(offset <= 1020 && offset >= 650) {
                $('#content.services .sub_nav li:eq(2)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(2)').removeClass('current');
            }
            if(offset <= 1380 && offset >= 1020) {
                $('#content.services .sub_nav li:eq(3)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(3)').removeClass('current');
            }
            if(offset <= 1690 && offset >= 1380) {
                $('#content.services .sub_nav li:eq(4)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(4)').removeClass('current');
            }
            if(offset <= 2090 && offset >= 1690) {
                $('#content.services .sub_nav li:eq(5)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(5)').removeClass('current');
            }
            if(offset <= 2470 && offset >= 2090) {
                $('#content.services .sub_nav li:eq(6)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(6)').removeClass('current');
            }
            if(offset >= 2470) {
                $('#content.services .sub_nav li:eq(7)').addClass('current');
                } else {
                $('#content.services .sub_nav li:eq(7)').removeClass('current');
            }
//            if ($(window).scrollTop() >= $(document).height() - $(window).height() - 5) {
//                $('#content.services .sub_nav li').removeClass('current');
//                $('#content.services .sub_nav li:eq(7)').addClass('current');
//            }
        }
    });
    
    // Services Pop-up Sections
    $('#services_list li a').click(function() {
        $('#services_list li, #services_list article').removeClass('active');
        $(this).parent().addClass('active');
        $(this).closest('article').addClass('active');
        return false;
    });
    
    $('#services_list li figure').append('<a class="close" href="javascript:;">&times;</a>');
    
    $('#services_list li a.close').click(function() {
        $('#services_list li, #services_list article').removeClass('active');
    });
    
        // Services ScrollTo's
        if(window.location.hash) {
            $('#services_list li a[rel=' + window.location.hash + ']').parent().addClass('active');
            $('#services_list li a[rel=' + window.location.hash + ']').closest('article').addClass('active');
        }
        
        if(window.location.hash.search('strategy_') !== -1) {
            $(this).scrollTo('#services_strategy');
        }
        
        if(window.location.hash.search('design_') !== -1) {
            $(this).scrollTo('#services_design');
        }
        
        if(window.location.hash.search('marketing_') !== -1) {
            $(this).scrollTo('#services_marketing');
        }
        
        if(window.location.hash.search('social_') !== -1) {
            $(this).scrollTo('#services_social');
        }
        
        if(window.location.hash.search('technology_') !== -1) {
            $(this).scrollTo('#services_technology');
        }
        
        if(window.location.hash.search('testing_') !== -1) {
            $(this).scrollTo('#services_testing');
        }
        
        if(window.location.hash.search('evolution_') !== -1) {
            $(this).scrollTo('#services_evolution');
        }
    
    // Culture Isotope
    $('#inside_list').isotope({
        itemSelector: 'article',
        resizable: false,
        masonry: { 
            columnWidth: 250
        }
    });

    // Culture Pictures Slideshow
    $('#inside_intro .slideshow').flexslider({
        animation: "slide",
        controlNav: false,
        directionNav: true,
        pauseOnHover: true,
        prevText: "Prev",
        slideDirection: 'horizontal'
    });
    
    // Culture Team Slideshow
    $('.team_member figure').each(function() {
        $(this).cycle({
    		fx: 'fade',
    		next: $(this),
    		speed:  500,
       		timeout: 0 
    	});
    });
	
//	$('#inside_list .team_member figure').cycle('pause');
//	
//	$('#inside_list .team_member figure').mouseenter(function() {
//		$(this).cycle('resume');
//	});
//	
//	$('#inside_list .team_member figure').mouseleave(function() {
//		$(this).cycle('pause');
//	});
    
    // Process Slideshow
    $('#process_list').flexslider({
        animation: "slide",
        animationDuration: 400,
        directionNav: false,
        manualControls: ".pager li a",
        pauseOnHover: true,
        slideshow: false,
        slideshowSpeed: 4000,
        start: function(slider) {
            slider.slides.eq(slider.currentSlide).addClass('active');
        },
        before: function(slider) {
            slider.slides.removeClass('active').eq(slider.animatingTo).addClass('active');
        }
    });
    
    $('#process_list .sub_slides').cycle({
        cleartypeNoBg: true,
		fx: 'fade',
		speed:  500,
   		timeout: 5000,
        pager:  "#process_list .sub_pager",
        pagerAnchorBuilder: function (index) {
            return '<li><a href="#"><span>#</span></a></li>';
        },
        before: function(){
            $(this).parent().find("li.active").removeClass();
        },
        after: function(){
            $(this).addClass("active");
        }
	});
    
    // Contact Nav
    $(function(){
		var scrollTimer = window.setInterval(scrollEnded, 200);
        function scrollEnded(){
            offset = Math.round(window.pageYOffset);
            if(offset <= 1517 && offset >=170) {
                $('#contact_forms .right_column').addClass('fixed');
            } else {
                $('#contact_forms .right_column').removeClass('fixed');
            }
			if(offset <= 770) {
                $('#content.contact .sub_nav li:eq(1), #contact_client .right_column').addClass('current');
            } else {
                $('#content.contact .sub_nav li:eq(1), #contact_client .right_column').removeClass('current');
            }
            if(offset <= 1350 && offset >= 771) {
                $('#content.contact .sub_nav li:eq(2), #contact_speaker .right_column').addClass('current');
            } else {
                $('#content.contact .sub_nav li:eq(2), #contact_speaker .right_column').removeClass('current');
            }
            if(offset >= 1350) {
                $('#content.contact .sub_nav li:eq(3), #contact_resume .right_column').addClass('current');
            } else {
                $('#content.contact .sub_nav li:eq(3), #contact_resume .right_column').removeClass('current');
            }
        }
    });
    
    // Contact Forms
    $('#client_form').submit(function() {
		$('#client_form .error').remove();
		var hasError = false;
		$('#client_form .requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot your '+labelText+'</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('#client_form').addClass("success").each(function() {			   
					$('#contact_client figure').addClass('active');
				});
				$("#client_form .submit_form").attr("onClick", "_gaq.push(['_trackPageview', '/client-submitted'])");
			});
		}
		return false;
	});
	
	$('#event_form').submit(function() {
		$('#event_form .error').remove();
		var hasError = false;
		$('#event_form .requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot your '+labelText+'</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('#event_form').addClass('success').each(function() {			   
					$('#contact_speaker figure').addClass('active');
				});
				$("#event_form .submit_form").attr("onClick", "_gaq.push(['_trackPageview', '/speaker-submitted'])");
			});
		}
		return false;
	});
	
	$('#resume_form').submit(function() {
		$('#resume_form .error').remove();
		var hasError = false;
		$('#resume_form .requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot your '+labelText+'</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('#resume_form').addClass("success").each(function() {			   
					$('#contact_resume figure').addClass('active');
				});
				$("#resume_form .submit_form").attr("onClick", "_gaq.push(['_trackPageview', '/resume-submitted'])");
			});
		}
		return false;
	});

	$('#resume_form, #event_form, #client_form').append('<input type="hidden" name="key" value="60423939197c65e66aa1ede7f3213bc1" />');
    
	// Parallax BG
	$('#wrapper').not('.blank').parallax({ "coeff":-0.40 });
	
	// ScrollTo
	$.localScroll();

});

