$(document).ready(function() {
  slideShow();
  
  $('.conport_left').children().not('.show').hide();
  $('.conport_left').children().children().not('.show').hide();
  $("#tabs").tabs();
  $('#cont_top a').not('.show').hide();
  
  $('#port_nav li').click(function() {
      var currentParent = $('.conport_left .show');
      currentParent.hide().removeClass('show');
      
      var currentLi = $('#port_nav .active');
      currentLi.removeClass('active');
      $(this).addClass('active');
      
      var id = '#' + $(this).attr('title');
      $(id).show().addClass('show');
      $(id).children(':first').fadeIn().addClass('show');

  });
$(document).ready(function() { //justifies form labels
    var max = 0;
    $("label").each(function(){
        if ($(this).width() > max)
            max = $(this).width();   
    });
    $("label").width(max);
});//end of form label justification
  
  $('#arrow_l').click(function() {//portfolio slideshow arrows
    moveSlide('prev');
  });  
  $('#arrow_r').click(function() {
    moveSlide();
  });
});//end of port slideshow arrows

function slideShow() {//slideshow
    var current = $('#cont_top .show');
    var next = '';
    
    if (current.next().length) {
      next = current.next();
    } else {
      next = current.parent().children(':first');
    }
    
    current.hide().removeClass('show');
    next.fadeIn('slow').addClass('show');

    setTimeout(slideShow, 5000)
}

function moveSlide(direction) {
    var currentSlide = $('.conport_left .show .show');
    var next = currentSlide.next().length ? currentSlide.next() : currentSlide.parent().children(':first');
    
    if (direction == 'prev') {
      next = currentSlide.prev().length ? currentSlide.prev() : currentSlide.parent().children(':last');
    }
    
    currentSlide.hide().removeClass('show');
    next.fadeIn().addClass('show');
    
}//end slideshow


