/* Author:

*/

$(document).ready(function(){
  // init input helper
  var inputHelper = $('.input-helper');
  inputHelper .length > 0 ? inputHelper.inputHelper() : '';
  
  // sub nav drop bg init
  var navState = 1;
   
  // main nav helper functions
  $('a.has-sub').mouseenter(function() {
      $('#sub-nav-bg').removeClass('hidden');
  }).mouseleave(function(){
      $('#sub-nav-bg').addClass('hidden');
  });

  $('#content').hover(function(){
    if(navState != 1){
      $('#sub-nav-bg').addClass('hidden');
    }
  });
  
  $('li.has-sub ul').mouseenter(function() {
      $(this).parent('div').parent('li').addClass('current');
      $('#sub-nav-bg').removeClass('hidden');
  }).mouseleave(function(){
      $(this).parent('div').parent('li').removeClass('current');
      $(this).parent('div').parent('li').find('a').removeClass('current');
      $('#sub-nav-bg').addClass('hidden');
  });
  
  // add active class to main nav
  var location = window.location.pathname;
  location = location.split('/');
  //console.log(location);
  if (location[1] == '') {
      $('#nav-wrap a[href="/' + location[1] + '/"]').addClass('current');
  } else if (location[2] == '') {
      $('#nav-wrap a[href="/' + location[1] + '/"]').addClass('current');
  } else if (location[2] != '') {
      $('#nav-wrap a[href="/' + location[1] + '/"]').addClass('current');
      $('#nav-wrap a[href="/' + location[1] + '/"]').parent().addClass('current');
      $('#sub-nav-bg').removeClass('hidden');
  }
  
  if (location[1] == 'portfolio' || location[1] == 'careers') {
    $('#sub-nav-bg').addClass('hidden');
  }

});


var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-194363-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);
})();

