jQuery.noConflict();
(function($) {
	
	/* =======================================================
						Hide Filter Menu
	======================================================= */
	$('#filtering-nav ul').slideToggle();
	$('a.filter-btn').click(function(){
		$('#filtering-nav ul').slideToggle();
		return false;
	});
	
	// MouseOver Events
		
	$('.box').hover(function(){
			$('.img-container img', this).fadeTo("fast", 0.65).addClass('box-hover');
			$('.actions', this).fadeTo("fast", 1);
		},
		function(){
			$('img', this).fadeTo("fast", 1).removeClass('box-hover');
			$('.actions', this).fadeTo("fast", 0);
	});
	
	// Sidebar Ads
	$('.shaken_sidebar_ads a:odd img').addClass('last-ad');
	
	/* =======================================================
							Share Icons
	======================================================= */
	$('.share-container').hide();
	
	$('.share').click(function(){
		var myParent =  $(this).parent();
		$('.share-container', myParent).slideToggle('fast');				   
	});
	
	// ======== Find the spaces and replace with %20 =========
	$(".share-icons a").each(function(){
	  $(this).attr( 'href', encodeURI( $(this).attr("href") ) );
	});
	
	/* =======================================================
							Color Box
	======================================================= */
	$('.gallery-icon a').attr('rel', 'post-gallery');
	$("a[rel='gallery'], a[rel='lightbox'], .gallery-icon a").colorbox({
		maxWidth: '85%',
		maxHeight: '85%'	
	});
	
	
	$(window).load(function(){
	
		/* =======================================================
								Masonry Setup
		======================================================= */
		
		speed = 500;
		
		$('.sort, #sort').masonry({ 
			columnWidth: 175,
			itemSelector: '.box:not(.invis)',
			animate: true,
			animationOptions: {
				duration: speed,
				queue: false
			}
		});
		
		/* =======================================================
							Masonry Filtering
		======================================================= */
		$('#filtering-nav li a').click(function(){
			var colorClass = '.' + $(this).attr('class');
			
			if(colorClass=='.all') {
				// show all hidden boxes
				$('#sort, .sort').children('.invis').toggleClass('invis').animate({opacity: 1},{ duration: speed });
			} else {    
				// hide visible boxes 
				$('#sort, .sort').children().not(colorClass).not('.invis').toggleClass('invis').animate({opacity: 0},{ duration: speed });
				// show hidden boxes
				$('#sort, .sort').children(colorClass+'.invis').toggleClass('invis').animate({opacity: 1},{ duration: speed });
			}
			$('#sort, .sort').masonry();
		
			return false;
		});
		
	});
})(jQuery);

// Setup the function for the Tweet Button
function twitPop(myURL, myTitle, myRelated) {
	var width  = 650;
	var height = 500;
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	var params = 'width='+width+', height='+height;
	params += ', top='+top+', left='+left;
	params += ', directories=no';
	params += ', location=no';
	params += ', menubar=no';
	params += ', resizable=no';
	params += ', scrollbars=no';
	params += ', status=no';
	params += ', toolbar=no';
	newwin=window.open("http://twitter.com/share?url="+myURL+"&text="+myTitle+"&related="+myRelated,'Share via Twitter', params);
	if (window.focus) {newwin.focus();}
	return false;
}
