jQuery.noConflict();

jQuery(function(){
	jQuery('span.view-large').hide();
	jQuery('span.video-post-overlay').hide();
	myOp = 1;
	
	jQuery(window).load(function($){
		
		// Grid jQuery plugin: http://desandro.com/resources/jquery-masonry/
		
		$columnWidth = 330;
		$viewportWidth = (window.innerWidth ? window.innerWidth : $(window).width()) - 230;
		$numCols = Math.floor($viewportWidth / $columnWidth);
		
		$padding = ($viewportWidth - ($numCols * $columnWidth)) / $numCols;
		
		//alert($viewportWidth + ' . ' + $numCols + ' . ' + $padding);
		
		if ($padding > 20) {
			jQuery("#grid").css('padding-left', '20px');
			$padding = $padding - 10;
		}
		
		$columWidth = $columnWidth + $padding;
		
		//alert($columWidth);
		
		jQuery('#sort').masonry({ 
			columnWidth: $columWidth,
			animate: true,
			itemSelector: '.box',
			singleMode: true
			//easing: 'linear'
		}, 
		function() { jQuery(this).css({
			margin: '4px'
			});
		});
		
		// MouseOver Events
		
		jQuery('.box').hover(function(){
			jQuery('img', this).fadeTo("fast", 0.75).addClass('box-hover');
			jQuery('span.view-large', this).fadeTo("fast", 1);
			jQuery('span.video-post-overlay', this).fadeTo("fast", 1);
		},
		function(){
			jQuery('img', this).fadeTo("fast", myOp).removeClass('box-hover');
			jQuery('span.view-large', this).fadeTo("fast", 0);
			jQuery('span.video-post-overlay', this).fadeTo("fast", 0);
		});
		
		// Colorbox
		jQuery("a[rel='gallery']").colorbox();
		
	});
});

