$('document').ready(function(){

	//center portfolio images
	if($.browser.msie) {
		$('.pItem img, #portfolioCase img, .single-portfolio .pImg img').each(function(){
			var imgHeight = $(this).height();
			var padding = (160 - imgHeight)/2;
			$(this).css('padding-top', padding);
		});
		$('.pItem img, #portfolioCase img, .single-portfolio .pImg img').each(function(){
			var imgWidth = $(this).width();
			if(imgWidth > 180) {
				$(this).width('190px');
			}
		}); 

	}

	//news and events pages tabs
	$('a#newsLink').click(function() {
			$('#eventItems').hide();
			$('#newsItems').show();
			$('a#eventsLink').removeClass('active');
			$('a#newsLink').addClass('active');
    });
   
   $("a#eventsLink").click(function() {
			$('#newsItems').hide();
			$('#eventItems').show();
			$('a#newsLink').removeClass('active');
			$('a#eventsLink').addClass('active');
    });
    
    //remove margin-right from last portfolio item of the row
	$('.pContainer div:nth-child(3n)').addClass('last');
    
    //make all of the portfolio item divs same height
    $(".pContainer").each(function(thisWrapper){
		var maxHeight = 0;
		
		$(this).find(".pItem").each(function() {
			maxHeight = Math.max(maxHeight, $(this).height()); 
		});
		
		$(this).find('.pItem').height(maxHeight);	
	});

});
