// Google Analytics

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24168428-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


// Home page slider

var ec_slide = {
    'settings' : {
        'speed' : 4000,
        'count' : 0,
        'width' : 610,
        'container' : "#slider-panel-container",
        'child' : ".slider-panel"
    },
    'init' : function() {
        this.settings.count = $(this.settings.container).children(this.settings.child).length;
        $(this.settings.container).css('width', this.settings.count * this.settings.width);
        this.timeout = setTimeout('ec_slide.animate()', this.settings.speed);
        var that = this;
        $(this.settings.container).mouseover(function() {
            clearTimeout(that.timeout);
        });
        $(this.settings.container).mouseout(function() {
           that.timeout = setTimeout('ec_slide.animate()', that.settings.speed);
        });
    },
    'animate' : function() {
        var current_margin_left = parseInt($(this.settings.container).css("margin-left"), 10);
        if (current_margin_left == -1 * ( this.settings.count - 1 ) * this.settings.width) current_margin_left = this.settings.width;
        var that = this;
        $(this.settings.container).animate({marginLeft: (current_margin_left - this.settings.width)}, 1000, 'easeInOutExpo', function() {
            that.timeout = setTimeout('ec_slide.animate()', that.settings.speed);
        });
    }
};

$(function() {
    ec_slide.init();
});



// Team Page 

$(function() {
    // Hide by default
    $(".team-panel").hide();
    
    // On Click Fade
    $("ul#team-photos a").click(function() {
        
        if (!$(this).hasClass("active")) {
            $(".team-panel").fadeOut();
            $("ul#team-photos a").animate({opacity:"0.3"}, {queue: false, duration: 500}).removeClass("active");
            $(this).animate({opacity:"1"}, {queue: false, duration: 800}).addClass("active");
            $("#panel-" + this.href.split("#")[1]).fadeIn();return false;
        } else
            $(".close-button").trigger("click");
        
        return false;
        
    });
    
    
    // Close Button
    $(".close-button").click(function() {
        $(".team-panel").fadeOut();
        $("ul#team-photos a").animate({opacity:"1"}, {queue: false, duration: 800}).removeClass("active");
        return false;
    });
});


