$(document).ready(function () {
 

    initHero(false, 5000);
    initRelationshipsCarousel();
    initConnectForm();
    initWorkFilters();
    initClientFilters();
    initWorkGallery();
    initGallery();
    initVideoPlayer();
    initVideoPlayerNoSocials(0);
    initHistory();
    initMultipleTestimonial();
    initOurPeople();
    initModernizer();
    initTracking();
});


var initModernizer = function(){
    if(!Modernizr.input.placeholder){

    	$('[placeholder]').focus(function() {
    	  var input = $(this);
    	  if (input.val() == input.attr('placeholder')) {
    		input.val('');
    		input.removeClass('placeholder');
    	  }
    	}).blur(function() {
    	  var input = $(this);
    	  if (input.val() == '' || input.val() == input.attr('placeholder')) {
    		input.addClass('placeholder');
    		input.val(input.attr('placeholder'));
    	  }
    	}).blur();
    	$('input:submit').submit(function() {
    	  $(this).find('input,textarea').each(function() {
    		var input = $(this);
    		if (input.val() == input.attr('placeholder')) {
    		  input.val('');
    		}
    	  })
    	});
    }
}


/*
Function: initRelationshipCarousel

Initializes home page Our Relationships module.

Parameters:

none

*/
var initRelationshipsCarousel = function () {

    var MAX_HEIGHT = 715; 	// Fixed height of the snapshot slides
    var MIN_HEIGHT = 95; // Collapsed size of carousel

    var initialLength = $('#relationship-carousel>li').length;
    var pixelWidth = initialLength * 184;
    $('#relationship-carousel').css('width', 184 * 3 * $('#relationship-carousel>li').length);
    $('#relationship-carousel').css('margin-left', (-184 * initialLength));
    var items = $('#relationship-carousel').html();
    $('#relationship-carousel').append(items).prepend(items);
    $('#relationship-carousel').css('width', 184 * 3 * $('#relationship-carousel>li').length);
    $('#relationship-carousel').css('margin-left', (-184 * initialLength));

    $('#scroll-left').click(function (e) {
        e.preventDefault();
        if ($('#relationship-carousel').is(':animated') == false) {
            var lm = parseInt($('#relationship-carousel').css('margin-left'));
            var pos = lm / 184;
            var tail = Math.abs(initialLength - 5 + (pos));

            if (parseInt($('#carousel-wrapper').css('height')) == MAX_HEIGHT) {
                $('#carousel-wrapper').animate({ 'height': MIN_HEIGHT + 'px' }, 500, function () {
                    $('#relationship-carousel li.selected').removeClass('selected'); // remove all selected classes
                    $('#relationship-carousel').animate({ 'margin-left': lm - 920 }, 500, function () {
                        if (tail == initialLength) {
                            $('#relationship-carousel').css('margin-left', (pixelWidth * -1));
                        }
                    });
                });
            } else {
                $('#relationship-carousel').animate({ 'margin-left': lm - 920 }, 500, function () {
                    if (tail == initialLength) {
                        $('#relationship-carousel').css('margin-left', (pixelWidth * -1));
                    }
                });
            }
        }
    });

    $('#scroll-right').click(function (e) {
        e.preventDefault();

        if ($('#relationship-carousel').is(':animated') == false) {
            var lm = parseInt($('#relationship-carousel').css('margin-left'));
            var pos = lm / 184;
            var tail = Math.abs(pos) + 5;

            if (parseInt($('#carousel-wrapper').css('height')) == MAX_HEIGHT) {
                $('#carousel-wrapper').animate({ 'height': MIN_HEIGHT + 'px' }, 500, function () {
                    $('#relationship-carousel li.selected').removeClass('selected'); // remove all selected classes
                    $('#relationship-carousel').animate({ 'margin-left': lm + 920 }, 500, function () {
                        var m = parseInt($('#relationship-carousel').css('margin-left')) - pixelWidth;
                        while (m <= pixelWidth * -1) { m = m + (pixelWidth); }
                        m = m - pixelWidth;
                        $('#relationship-carousel').css('margin-left', m + 'px');
                    });
                });
            } else {
                $('#relationship-carousel').animate({ 'margin-left': lm + 920 }, 500, function () {

                    var m = parseInt($('#relationship-carousel').css('margin-left')) - pixelWidth;
                    while (m <= pixelWidth * -1) { m = m + (pixelWidth); }
                    m = m - pixelWidth;
                    $('#relationship-carousel').css('margin-left', m + 'px');
                });
            }
        }
    });

    $('#relationship-carousel>li>a').click(function (e) {
        e.preventDefault();


        if ($(this).parent().hasClass('selected')) {
            $('#carousel-wrapper').animate({ 'height': MIN_HEIGHT + 'px' }, 500, function () {
                $('#relationship-carousel li.selected').removeClass('selected');
            });
        } else {
            $('#relationship-carousel li.selected').removeClass('selected');
            $(this).parent().addClass('selected');
            $('.snapshot-slide').css('height', '0');
            $(this).next().css('height', MAX_HEIGHT + 'px');
            if (parseInt($('#carousel-wrapper').css('height')) != MAX_HEIGHT) {
                $('#carousel-wrapper').animate({ 'height': MAX_HEIGHT + 'px' }, 500, function () {
                    $.scrollTo('#relationships',300);
                });
            }
        }
    });

    $('#relationship-carousel>li>section a nav').click(function (e) {
        e.preventDefault();
        $('#carousel-wrapper').animate({ 'height': MIN_HEIGHT + 'px' }, 500, function () {
            $('#relationship-carousel li.selected').removeClass('selected');
        });

    });
}


/*
   Function: initHero

   Initializes home page Hero module.

   Parameters:

      autoplay - Boolean value for autoplay
      delay - Number of milliseconds to wait before moving to the next slide

*/
var initHero = function(autoplay, delay){
	var currentSlide = 1;
	var totalSlides = 3;

	// bind click action for controls
	$("#hero-controls a").click(function(e) {
	e.preventDefault();
	//clearInterval(animLoop);
		var slideNumber = $(this).attr("id").replace("control-","");
		if(slideNumber != currentSlide){
			$("#hero-slide-" + slideNumber).fadeIn("slow");
			$("#hero-slide-" + currentSlide).fadeOut("slow");
			$("#hero-controls li").removeClass("current");
			$(this).parent().addClass("current");
			currentSlide = slideNumber;
		}
	});
	
	// animate before hovered
	if(autoplay === true){
		animLoop = window.setInterval(
						function(){
									var nextSlide = parseInt(currentSlide)+1;
									if(nextSlide>totalSlides){nextSlide = 1;}
									$("#hero-controls #control-" + nextSlide).click();
								  },
						delay
					);
		
		// stop animation on hover
		$("#hero").hover(function(){
			clearInterval(animLoop);	
		});
	}
}


/*
Function: initVideoPlayer

    Initializes Video Player.

Parameters:
    none
*/
var initVideoPlayer = function () {

    $('a.video-player').each(function (index) {

        var vHeight;
        var vWidth;

        var pattern = /url\(|\)|"|'/g;
        var splashImagePath;


        //background image
        if ($(this).css('background-image') != "none") {
            vHeight = $(this).css('height');
            vWidth = $(this).css('width');

            splashImagePath = $(this).css('background-image').replace(pattern, "");
        }
        else {
            vHeight = $("img", this).height();
            vWidth = $("img", this).width();
            splashImagePath = null;
        }

        // Set width and height of anchor that launches flowplayer, which determines player dimension
        //$(this).css('width', vWidth).css('height', vHeight);

        // Get background image url

        if ($(this)) {

            var playerID = $(this).attr('id');
            //var trackerID = $(this).attr('tracker');

            $f(playerID, {

                src: '/App_Themes/Versant/flash/flowplayer.commercial-3.2.7.swf',
                width: vWidth,
                height: vHeight,
                wmode: 'opaque',
                version: [9, 115],
                onFail: function () {
                    document.getElementById("info").innerHTML =
                                			"You need the latest Flash version to see MP4 movies. " +
                                			"Your version is " + this.getVersion()
                                		;
                }
            }, {
                key: '#$592147b68ffb3d7979f',
                clip: {
                    autoBuffering: true,
                    accelerated: true,
                    bufferLength: 2,
                    eventCategory: 'video',
                    onBegin: function () {
                        //console.log(playerID);
                        this.setVolume(100);
                    } ,
                    coverImage: splashImagePath
                },
                plugins: {
                    controls: {
                        url: '/App_Themes/Versant/flash/flowplayer.controls-3.2.5.swf',
                        all: false,
                        play: true,
                        mute: true,
                        fullscreen: true,
                        scrubber: true,
                        time: true,
                        volume: true
                    },
                    sharing: {
                        url: '/App_Themes/Versant/flash/flowplayer.sharing-3.2.1.swf'
                    },
                    gatracker: {
                        url: '/App_Themes/Versant/flash/flowplayer.analytics-3.2.2.swf',
                        debug: false,
                        events: {
                            all: true
                        },
                        trackingMode: 'Bridge',
                        accountId: 'UA-195174-1'
                    }
                }
            }).ipad();
        };
    });

}

/*
Function: initVideoPlayer

Initializes Video Player.

Parameters:
none
*/
var initVideoPlayerNoSocials = function (i) {

    $('a.video-player-no-socials').each(function (index) {

        var vHeight;
        var vWidth;

        var pattern = /url\(|\)|"|'/g;
        var splashImagePath;


        //background image
        if ($(this).css('background-image') != "none") {
            vHeight = $(this).css('height');
            vWidth = $(this).css('width');

            splashImagePath = $(this).css('background-image').replace(pattern, "");
        }
        else {
            vHeight = $("img", this).height();
            vWidth = $("img", this).width();
            splashImagePath = null;
        }


		//this is for chrome, was running the function before the image was loading so the video height/width was not being defined
		if ((vHeight === 0 || vWidth === 0) && i < 3)
		{
			setTimeout("initVideoPlayerNoSocials(" + (i + 1) + ")", 50);
			return;
		}
		
        // Set width and height of anchor that launches flowplayer, which determines player dimension
        //$(this).css('width', vWidth).css('height', vHeight);

        // Get background image url

        if ($(this)) {

            var playerID = $(this).attr('id');
            //var trackerID = $(this).attr('tracker');

            $f(playerID, {

                src: '/App_Themes/Versant/flash/flowplayer.commercial-3.2.7.swf',
                width: vWidth,
                height: vHeight,
                wmode: 'opaque',
                version: [9, 115],
                onFail: function () {
                    document.getElementById("info").innerHTML =
                                			"You need the latest Flash version to see MP4 movies. " +
                                			"Your version is " + this.getVersion()
                                		;
                }
            }, {
                key: '#$592147b68ffb3d7979f',
                clip: {
                    autoBuffering: true,
                    accelerated: true,
                    bufferLength: 2,
                    eventCategory: 'video',
                    onBegin: function () {
                        //console.log(playerID);
                        this.setVolume(100);
                    },
                    coverImage: splashImagePath
                },
                plugins: {
                    controls: {
                        url: '/App_Themes/Versant/flash/flowplayer.controls-3.2.5.swf',
                        all: false,
                        play: true,
                        mute: true,
                        fullscreen: true,
                        scrubber: true,
                        time: true,
                        volume: true
                    },
                    gatracker: {
                        url: '/App_Themes/Versant/flash/flowplayer.analytics-3.2.2.swf',
                        debug: false,
                        events: {
                            all: true
                        },
                        trackingMode: 'Bridge',
                        accountId: 'UA-195174-1'
                    }
                }
            }).ipad();
        };
    });

}

/*
Function: initTracking

    Initializes additional Google Analytics.

*/
var initTracking = function () {
    //external links
    $("a[href^='http:']").not("[href*='versantsolutions.com']").click(function (e) {
        _gaq.push(["_trackEvent", "ExternalLink", "Link", $(this).attr('href')]);
    });

    //PDFs
    $("a[href$='.pdf']").click(function (e) {
        _gaq.push(["_trackEvent", "PDF", "Download", $(this).attr('href')]);
    });

    //hero links
    $('#hero section a').click(function (e) {
        var heroType = "Hero-" + $('#hero-controls li.current a').text();
        var link = $(this).attr('href');
        _gaq.push(["_trackEvent", heroType, "Click", link]);
    });

    //relationship carousel
    $('#relationship-carousel>li>a').click(function (e) {
        var eventType = "Relationship-Carousel";
        var clientName = $(':first-child', this).attr('alt');
        _gaq.push(["_trackEvent", eventType, "Click", clientName]);
    });

    //client and work filter
    $('.dropdown-options>li>a').click(function (e) {
        var filterType = "Filter-" + $('#main-nav .current>a').text();
        var filterValue = $(this).attr('href');
        _gaq.push(["_trackEvent", filterType, "Click", filterValue]);
    });
}


/*
Function: initConnectForm

    Initializes Connect With Us form.

Parameters:
    
    none
*/
var initConnectForm = function () {
  
    if ($(".connect-form").length > 0) {

        //cancels out the .net validation summary control scrollto 0,0
        window.scrollTo = function () { }

        //text box click to open rest of form
        $('.connect-message').click(function() {
            $('#connect-details').slideDown('fast');
        });
        
        //hide form on cancel
        $('#connect-cancel').click(function(e) {
            e.preventDefault();
            $('#connect-details').slideUp('fast');
        });

        // applies classes to style hightlight border for form elements
        var connectFormElements = $("input,textarea");
        connectFormElements.focus(function() {
            connectFormElements.removeClass('focus');
            $(this).addClass("focus");

            $('.message-arrow').removeClass('focus');
            
            if ($("textarea").hasClass('focus')) {
                $('.message-arrow').addClass('focus');
            }
  
        });
    }

}

//error handling - adds a .error class to the input fields that are invalid
function BtnClick() {
    var val = Page_ClientValidate();
    if (!val) {
        var i = 0;
        for (; i < Page_Validators.length; i++) {
            if (!Page_Validators[i].isvalid) {
                $("#" + Page_Validators[i].controltovalidate).addClass("error");

                if ($("textarea").hasClass('error')) {
                    $('.message-arrow').addClass('error');
                }
            }
        }
    }
    return val;
}

/*
Function: initWorkGallery

    Initializes Individual Work Page Gallery w/ Fancybox

Parameters:
    
    none
*/
var initWorkGallery = function () {
    if ($("#work-gallery-nav").length > 0) {
        $("#work-gallery-nav").before("<img id=\"stage\" src=\"" + $("#work-gallery-nav a:first").attr("href") + "\"/>");
        $("#stage").wrap("<a id=\"stageLink\" />");
        $("#stageLink").before("<div style=\"display:none;width:620px;height:750px;position:absolute;\" id=\"stageControls\"><div style=\"opacity:.2;background:#fff;width:620px;height:750px;position:absolute;\"></div><a id=\"fullscreen\" href=\"#\" style=\"position:absolute;top:1px;right:1px;\"><img src=\"/App_Themes/versant/images/css/icon-full-screen-lightbox.png\" /></a></div>");
        $("#stageLink").mouseover(function () { $("#stageControls").show(); });
        $("#stageControls").hover(null, function () { $("#stageControls").hide(); });
        $("#work-gallery-nav a").click(function (e) {
            e.preventDefault();
            if ($("#stage").attr("src") != $(this).attr("href")) {
                var newHref = $(this).attr("href");
                $("#stage").fadeOut('normal', function () {
                    $("#stage").attr("src", newHref);
                    $("#stage").load(function () {
                        $("#stage").fadeIn('normal');
                    });
                })
                $("#stageLink").attr("href", $(this).attr("href"));
                var i = $("#work-gallery-nav li a[href*='" + $(this).attr("href") + "']").parent().index() + 1;
                //$("#fullscreen").unbind();
                //$("#fullscreen").click(function(ev){console.log(i);ev.preventDefault();$.fancybox.pos(i);});

                //setup next and previous links
                var next = i + 1;
                var prev = i - 1;
                var total = $("#work-gallery-nav li").length;
                if (next > total) { next = 1; }
                if (prev < 1) { prev = total; }
            }
        });
        $("#work-gallery-nav a:first").click()
        $("#stageLink").click(function (e) {
            e.preventDefault();
        });
    }
}

/*
Function: initGallery

    Initializes general Gallery w/ Fancybox

Parameters:
    
    none
*/
var initGallery = function () {
    if ($("#gallery-nav").length > 0) {
        $("#gallery-nav").before("<img id=\"stage\" src=\"" + $("#gallery-nav a:first").attr("href") + "\"/>");
        $("#stage").wrap("<a id=\"stageLink\" />");
        $("#gallery-nav a").click(function (e) {
            e.preventDefault();
            if ($("#stage").attr("src") != $(this).attr("href")) {
                var newHref = $(this).attr("href");
                $("#stage").fadeOut('normal', function () {
                    $("#stage").attr("src", newHref);
                    $("#stage").load(function () {
                        $("#stage").fadeIn('normal');
                    });
                })
            }
        });
        $("#gallery-nav a:first").click()
    }
}

/*
Function: initWorkFilters

    Initializes dropdown filters for work listing. Handles changes in the location hash.
    Calls filterWorkList to initiate updates to the work items listing.

Parameters:
    
    none
*/
var initWorkFilters = function(){
    if($(".work-results").length > 0){
        $(".dropdown-select>ul>li").hover(
            function(){
                $(this).children("ul").show();
                $(".dropdown-select>ul>li").removeClass("selected");
                $(this).addClass("selected");
            },
            function(){
                $(this).children("ul").hide();
                $(this).removeClass("selected");
            }
         );

         $(".dropdown-options>li>a").click(function(){
            $(this).parent().parent().hide();
         });

         $(window).hashchange(function () {
            if (location.hash != "") {
                // URL Format for filters: #/filterType/filterValue
                var parts = location.hash.split("/", 3);
                var filter = {
                filterType:parts[1],
                filterValue:parts[2]
                }
                filterWorkList(filter);
                
            }

        })

        $(window).hashchange();
    }
}

/*
Function: initClientFilters

    Initializes dropdown filters for client listing. Handles changes in the location hash.
    Calls filterClientList to initiate updates to the client items listing.

Parameters:
    
    none
*/
var initClientFilters = function(){
    if($(".clients-list").length > 0){
        $(".dropdown-select>ul>li").hover(
            function(){
                $(this).children("ul").show();
                $(".dropdown-select>ul>li").removeClass("selected");
                $(this).addClass("selected");
            },
            function(){
                $(this).children("ul").hide();
                $(this).removeClass("selected");
            }
         );

         $(".dropdown-options>li>a").click(function(){
            $(this).parent().parent().hide();
         });

         $(window).hashchange(function () {
            if (location.hash != "") {
                // URL Format for filters: #/filterType/filterValue
                var parts = location.hash.split("/", 3);
                var filter = {
                filterType:parts[1],
                filterValue:parts[2]
                }
                filterClientList(filter);
                
            }

        })

        $(window).hashchange();
    }
}

/*
Function: filterWorkList

    Takes filter object and handles update to work items list on page.

TODO:
    Uncouple this function from the page. Should return data to caller instead of
    updating the DOM directly.

Parameters:
    
    object filter
*/
var filterWorkList = function(filter){
    $.post(
            "/_utility/workList.aspx",
            {v:filter.filterValue,t:filter.filterType},
            function(data){
                if(data.length > 0){
                    $("#workItems li, .filter-status span").fadeOut('normal', function(){
                                                                                            $("#workItems").html(data);
                                                                                            $(".filter-status span").html(filter.filterValue.replace(/-/g," "));
                                                                                            $("#workItems a").ready(function(){
                                                                                                $("#workItems li, .filter-status span").fadeIn('normal');
                                                                                            });
                                                                                        });
                 }else{
                 $("#workItems li, .filter-status span").fadeOut('normal', function(){
                                                                                        $("#workItems").load("/_utility/featuredWorkItems.html");
                                                                                        $(".filter-status span").html(filter.filterValue.replace(/-/g, " "));
                                                                                        $("#workItems li").ready(function(){
                                                                                                $("#workItems li, .filter-status span").fadeIn('normal');
                                                                                            });
                                                                                     });
                 }
            }
          );
}

/*
Function: filterClientList

    Takes filter object and handles update to client items list on page.

TODO:
    Uncouple this function from the page. Should return data to caller instead of
    updating the DOM directly.

Parameters:
    
    object filter
*/
var filterClientList = function(filter){
    $.post(
            "/_utility/clientList.aspx",
            {v:filter.filterValue,t:filter.filterType},
            function(data){
                if(data.length > 0){
                    $("#clientItems li, .filter-status span").fadeOut('normal', function(){
                                                                                            $("#clientItems").html(data);
                                                                                            $(".filter-status span").html(filter.filterValue);
                                                                                            $("#clientItems a").ready(function(){
                                                                                                $("#clientItems li, .filter-status span").fadeIn('normal');
                                                                                            });
                                                                                        });
                 }else{
                 $("#clientItems li, .filter-status span").fadeOut('normal', function(){
                                                                                        $("#clientItems").load("/_utility/featuredWorkItems.html");
                                                                                        $(".filter-status span").html(filter.filterValue);
                                                                                        $("#clientItems li").ready(function(){
                                                                                                $("#clientItems li, .filter-status span").fadeIn('normal');
                                                                                            });
                                                                                     });
                 }
            }
          );
}

/*
Function: initHistory

    Initializes history slider.

Parameters:
    
    none
*/
var initHistory = function() {
    var currentSlide = 1;
    var slideWidth = 920;
    var totalSlides = 6;
    var nudge = 12;
    var speed = 1000;




    // bind click actions for year controls
    $("#history-controls a").click(function(e) {
        e.preventDefault();
        $("#history-controls li.active").removeClass("active");
        $(this).parent().addClass("active");
        currentSlide = $(this).attr("id").replace("control-", "");
        var newOffset = parseInt((currentSlide * slideWidth) - slideWidth);
        var wrapperOffset = parseInt($(this).parent().parent().offset().left);
        var buttonOffset = parseInt($(this).offset().left - ($(this).parent().width()));
        //console.log(buttonOffset);
        if (buttonOffset < parseInt(19 + wrapperOffset)) {
            buttonOffset = 19;
        } else {
            buttonOffset = parseInt(buttonOffset + nudge - wrapperOffset);
        }
        $("#history-timeline").animate({
            left: "-" + newOffset + "px"
        }, speed, 'easeOutCubic');


        $("#history-controls ul").animate({ backgroundPosition: (buttonOffset + "px") }, speed, 'easeOutCubic');

            $("#history-controls ul li:not('.active') a").animate({
            color: "#333335"
            }
            , speed
            , 'easeOutCubic'
            );

                        $("#history-controls ul li.active a").animate({
            color: "#ffffff"
            }
            , speed
            , 'easeOutCubic'
            );


        if (currentSlide >= totalSlides) {
            $("#arrow-control-right").hide();
        } else {
            $("#arrow-control-right").show();
        }

        if (currentSlide <= 1) {
            $("#arrow-control-left").hide();
        } else {
            $("#arrow-control-left").show();
        }
    });

    //bind click actions for arrow controls
    $("#arrow-control-left").click(function(e) {
        e.preventDefault();
        if (currentSlide > 1) {
            var prevSlide = currentSlide - 1;
            $("#control-" + prevSlide).click();

        }
    });

    $("#arrow-control-right").click(function(e) {
        e.preventDefault();
        if (currentSlide < totalSlides) {
            var nextSlide = parseInt(currentSlide) + 1;
            $("#control-" + nextSlide).click();

        }
    });
    $("#arrow-control-right a").focus(function() {
        $(this).addClass("focus");
    });
    $("#arrow-control-right a").blur(function() {
        $(this).removeClass("focus");
    });

    $("#history-controls a:first").click();
}

/*
Function: initMultipleTestimonial

    Initializes Multiple Testimonial interface.

Parameters:
    
    none
*/
var initMultipleTestimonial = function () {
    var currentSlide = 1;
    var slideWidth = 960;
    var totalSlides = 3;
    var nudge = 110;
    var speed = 1000;

    // bind click actions for year controls
    $("#slider-controls a").click(function (e) {
        e.preventDefault();
        $("#slider-controls li.active").removeClass("active");
        $(this).parent().addClass("active");
        currentSlide = $(this).attr("id").replace("control-", "");
        var newOffset = parseInt((currentSlide * slideWidth) - slideWidth);
        var wrapperOffset = parseInt($(this).parent().parent().offset().left);
        var buttonOffset = parseInt($(this).offset().left - ($(this).parent().width()));
        if (buttonOffset < parseInt(35 + wrapperOffset)) {
            buttonOffset = 35;
        } else {
            buttonOffset = parseInt(buttonOffset + nudge - wrapperOffset);
        }
        //console.log(buttonOffset);
        $("#multitestimonial-stage").animate({
            left: "-" + newOffset + "px"
        }, speed, 'easeOutCubic');

        $("#slider-controls ul").animate({ backgroundPosition: (buttonOffset + "px") }, speed, 'easeOutCubic');

        $("#slider-controls ul li:not('.active') a").animate({
            color: "#333335"
        }
            , speed
            , 'easeOutCubic'
            );

        $("#slider-controls ul li.active a").animate({
            color: "#ffffff"
        }
            , speed
            , 'easeOutCubic'
            );

    });

    $("#slider-controls a:first").click();
}


/*
Function: initHistory

    Initializes Our People interface.

Parameters:
    
    none
*/
var initOurPeople = function() {

// Handle mouseover fulllist

//$(".people #peopleList").hover(
//    function(){
//    $(".people #main>div>ul>li>img").addClass("deselected");
//    console.info("ok");
//    },
//    function(){
//    $(".people #main>div>ul>li>img").removeClass("deselected");
//    }
//);
            $(".people #peopleList li>ul").css("display","none");
            $(".people #peopleList li>img").css("z-index","10");
    $(".people #peopleList li").hover(
        function(e){
                    $(".people #main>div>ul>li>img").addClass("deselected");
                    $(this).children("img").removeClass("deselected");
                    $(this).children("img").addClass("selected");
                    $(".people #peopleList li>ul").css("display","none");
                    $(".people #peopleList li>ul").css("left","0");
                    $(".people #peopleList img").css("z-index","10");
                  },
        function(){
                    $(".people #main>div>ul>li>img:not('.selected')").removeClass("deselected");
                    $(this).children("img").removeClass("selected");
                  }
    );

    $(".people #peopleList img").click(
        function(){
                    if($(this).siblings("ul").css("left")=='0px'){
                        $(".people #peopleList li>img:not('.selected')").css("z-index","8");
                        $(this).siblings("ul").css("z-index","9");
                        if(($(this).parent().index()+1) % 6 > 0){
                            $(this).siblings("ul").animate({"left":"160px"},500);
                        }else{
                            $(this).siblings("ul").animate({"left":"-160px"},500);
                        }
                        //console.info();
                        $(this).siblings("ul").css("display","block");
                    }
                  }
    );

}
