function slideSwitch() {
  var $active = $('.slideShow img.active');
  
  if ($active.length == 0) $active = $('.slideShow img:last');
  
  var $next = $active.next().length ? $active.next() : $('.slideShow img:first');
  
  $active.addClass('last-active').removeClass('active');
  
  $next.css({opacity: 0.0})
       .addClass('active')
	   .animate({opacity: 1.0}, 1000, function(){
	     $active.removeClass('last-active');
  }); 
}

function autoGlide() {
  var $active = $('.portfolioHighlight2 div.active');	

  if ($active.length == 0) $active = $('.portfolioHighlight2 div:last');
  
  var $next = $active.next().length ? $active.next() : $('.portfolioHighlight2 div:first');
  
  $active.addClass('last-active').removeClass('active');
  
  $next.css({right: -369}).addClass('active').animate({right: 25}, 1000, function(){ 
    $active.removeClass('last-active');
	
	if ($('.slideShow').length != 0)
	  slideSwitch()
  });
}

function mainNavAnimate() {
 
 $('#mainNav li a').hoverIntent(function(){
	var $offset = $(this).offset().left - 137;
	var $width = $(this).width();	
	
	$('#mainNavIndicator').animate({left: $offset, width: $width}, 'slow');
  }, function(){
	  
  });	
 
    
  
}

function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}


$(document).ready(function(){
//  var IEv = vIE();

  
  setInterval("autoGlide()", 3000);




  $('#portfolioTrigger').click(function(){
	$('#portfolioPopup').toggle('fast');								   
  });
  
  $('#logo').click(function(){ window.location = 'index.html'; });
  

  
  
  
});