var globSlide = 1;
function switchImg(target){
	if(!target){
		target = globSlide;
		globSlide++;
		if(globSlide == 4){
			globSlide = 1;	
		}
	}
	var currentSlide = $('.switch.cur').attr('rel');
	var slide = target;
	if(currentSlide != slide){
		$('.switch').removeClass('cur');
		$('.switch[rel="' + target + '"]').addClass('cur');
		$('#headerImg'+slide).fadeIn(function(){
			$('#headerImg'+currentSlide).fadeOut();
		});
	}
}
$(function(){
			$('.vertMenuItem').click(function(event){
				event.preventDefault();
				$('.vertMenuItem').removeClass('cur');
				$(this).addClass('cur');
				var target = '#' + $(this).attr('rel');
				var pos = $(target).position();
				$('#contentInner').animate({'left':-pos.left + 'px','top':-pos.top + 'px'});
			});
			$('#nav li a').click(function(event){
				if($(this).text() == 'Services'){
					event.preventDefault();
				}
			});
			if(typeof imgArr != 'undefined'){
				var howMany = imgArr.length/3;
				for(var i=0;i<=howMany;i++){
					var slide = i+1;
					if(i == 0){
						$('#topThree').append('<a href="#" rel="' + slide + '" class="switch cur"></a>');
					}
					else {
						$('#topThree').append('<a href="#" rel="' + slide + '" class="switch"></a>');	
					}
				}
				var goSlide = setInterval('switchImg()',4000);
				$('.switch').click(function(event){
					event.preventDefault();
					clearInterval(goSlide);
					switchImg($(this).attr('rel'));
				});
			}
			$('#nav li').hover(function(){
				$(this).find('ul:first').stop(true,true);
				$(this).find('ul:first').fadeIn(200);
				if($(this).hasClass('expanded')){
					$(this).find('a').addClass('active');
				}
			},
			function(){
				$(this).find('ul:first').fadeOut(200);
				if($(this).hasClass('expanded')){
					$(this).find('a').removeClass('active');
				}
			});
		});
