$(function(){
	// Masonry
	var $wall = $('#content');
	$wall.masonry({ 
	  columnWidth: 175, 
	  itemSelector: '.galleryItem:visible' 
	});
	$('.galleryItem').each(function(){
			var huer = Math.floor((240-220)*Math.random()) + 230;
			var col = 'rgb(' + huer + ',' + huer + ',' + huer + ')';
			$(this).css("background-color", col);
	});
	
		});
	// Show submenus
	$(".sub-menu").each(function(){
		var thisParent = $(this).parent();
		if (thisParent.hasClass('current-post-ancestor') || thisParent.hasClass('current-menu-item') || thisParent.hasClass('current-menu-ancestor')) {
			$(this).show();
		}
	});
		
	// Social hovers
	$(".iconSocial").hover(function() {
		$(this).attr("src",$(this).attr("src").replace('_off','_on'));
	}, function() {
		$(this).attr("src",$(this).attr("src").replace('_on','_off'));
	});

	$('.commentInput textarea').autoResize({
    // On resize:
    onResize : function() {
        $(this).css({opacity:0.8});
    },
    // After resize:
    animateCallback : function() {
        $(this).css({opacity:1});
    },
    // Quite slow animation:
    animateDuration : 300,
    // More extra space:
    extraSpace : 17
	});


	// Hover Colours
	$(".galleryItem").each(function(){
		//var originalImage = $(this).find('.category li').css('background-image');
		//var originalPath = originalImage.substring(originalImage.indexOf('"'), originalImage.lastIndexOf('/images'));
		//alert (originalPath);
		$(this).hover(function(){
			$(this).css("background","none");
			if ($(this).hasClass('Light')) {
      	$(this).find('h2').css({'color' : '#ffffff' });
				$(this).find('.sub_heading li').css({'color' : '#ffffff' });
				$(this).find('h5').css({'color' : '#ffffff' });
				$(this).css({'text-shadow' : 'rgba(0, 0, 0, 0.25) 1px 1px' });
		}else {
				$(this).find('h2').css({'color' : '#000000' });
				$(this).find('.sub_heading li').css({'color' : '#000000' });
				$(this).find('h5').css({'color' : '#000000' });
				$(this).css({'text-shadow' : 'rgba(255, 255, 255, 0.25) 1px 1px' });
			}		
		}, function () {
			var huer = Math.floor((240-220)*Math.random()) + 230;
			var col = 'rgb(' + huer + ',' + huer + ',' + huer + ')';
			$(this).css("background-color", col);
			$(this).find('h2').css({'color' : '#666666' });
			$(this).find('.sub_heading li').css({'color' : '#666666'});
			$(this).find('h5').css({'color' : '#999999' });
			$(this).css({'text-shadow' : 'none' });
		});
		
		$(".menu-item-object-category").each(function() {
			$(this).hover(function() {
				var categore = $(this).find('a').attr('href').toString().split("/")[4];
				//alert(categore);
	
				$("#content").find('.'+categore).each(function(){
					//var originalImage = $(this).find('.category li').css('background-image');
					//var originalPath = originalImage.substring(originalImage.indexOf('"'), originalImage.lastIndexOf('/images'));
					//alert (originalPath);
	
						$(this).css("background","none");
						if ($(this).hasClass('Light')) {
							$(this).find('h2').css({'color' : '#ffffff' });
							$(this).find('.sub_heading li').css({'color' : '#ffffff' });
							$(this).find('h5').css({'color' : '#ffffff' });
							$(this).css({'text-shadow' : 'rgba(0, 0, 0, 0.25) 1px 1px' });
					}else {
							$(this).find('h2').css({'color' : '#000000' });
							$(this).find('.sub_heading li').css({'color' : '#000000' });
							$(this).find('h5').css({'color' : '#000000' });
							$(this).css({'text-shadow' : 'rgba(255, 255, 255, 0.25) 1px 1px' });
						}		
				});
				
			}, function() {
				
				$(".galleryItem").each(function(){
					//var originalImage = $(this).find('.category li').css('background-image');
					//var originalPath = originalImage.substring(originalImage.indexOf('"'), originalImage.lastIndexOf('/images'));
					//alert (originalPath);
					var huer = Math.floor((240-220)*Math.random()) + 230;
					var col = 'rgb(' + huer + ',' + huer + ',' + huer + ')';
					$(this).css("background-color", col);
					$(this).find('h2').css({'color' : '#666666' });
					$(this).find('.sub_heading li').css({'color' : '#666666'});
					$(this).find('h5').css({'color' : '#999999' });
					$(this).css({'text-shadow' : 'none' });
				});
	  		
				});
		});
});
	
	
	

	
	
