if (window.location.toString().indexOf('empirestaging') < 0) {
  try {
  var pageTracker = _gat._getTracker("UA-7505942-1");
  pageTracker._trackPageview();
  } catch(err) {}
}

$(document).ready(function() {
  
  // Testimonial Widget
  var totalNum = 12;
  var rndNum = Math.floor(Math.random() * totalNum);
  $.getJSON('/js/testimonials.js', function(json){
    var testimonial = json.data.testimonials[rndNum];
    $('#t_quote').empty();
    $('#t_author').empty();
    $('#t_location').empty();
    $('#t_quote').html('"' + testimonial.quote + '"');
    $('#t_author').html('<strong>' + testimonial.author + '</strong');
    $('#t_location').html('<em>' + testimonial.location + '</em>');
  });
  
  // Portfolio Widget
  $('#portland li a').click(function() {
    $('.portfolio_menu_nav li').removeClass('active');
    $(this).parent().addClass('active');
    var city = $(this).attr('rel');
    $.getJSON('/js/portland.js', function(json){
      var currIndex = 0;
      for(i=0; i < json.portland.projects.length; i++){
        if(json.portland.projects[i].city == city){
          currIndex = i;
        }
      }
      
  
      var project = json.portland.projects[currIndex];
      $('#portfolio_image').attr('src', ''+ project.path +'');
      $('#portfolio_text').html(project.city);
    });
    return false;
  });
  $('#seattle li a').click(function() {
    $('.portfolio_menu_nav li').removeClass('active');
    $(this).parent().addClass('active');
    var city = $(this).attr('rel');
    $.getJSON('/js/seattle.js', function(json){
      var currIndex = 0;
      for(i=0; i < json.seattle.projects.length; i++){
        if(json.seattle.projects[i].city == city){
          currIndex = i;
        }
      }
      
  
      var project = json.seattle.projects[currIndex];
      $('#portfolio_image').attr('src', ''+ project.path +'');
      $('#portfolio_text').html(project.city);
    });
    return false;
  });
  $('#display_arrow_left').click(function() {
    var prevItem = $('.portfolio_menu_nav li.active').prev();
    $('.portfolio_menu_nav li').removeClass('active');
    prevItem.addClass('active');
    prevItem.children().click();
    return false;
  });
  $('#display_arrow_right').click(function() {
    var nextItem = $('.portfolio_menu_nav li.active').next();
    $('.portfolio_menu_nav li').removeClass('active');
    nextItem.addClass('active');
    nextItem.children().click();
    return false;
  });
  
  /* Random Project - Home Page */
  var totalProjects = 12;
  var rndProject = Math.floor(Math.random() * totalProjects);
  $.getJSON('/js/portland.js', function(json){
    var project = json.portland.projects[rndProject];
    $('#featured_project').attr('src', ''+ project.path +'');
    $('#featured_text').html(project.city);
  });
  
});
