jQuery.noConflict();
(function($) {
	
	// Show/Hide Filter Menu
	//$('#filtering-nav ul').slideToggle();
	//$('a.filter-btn').click(function(){
	//	$('#filtering-nav ul').slideToggle();
	//	return false;
	//});
	
	$('#login-details-panel').hide();
	
	$('.btn-login').click(function(){ 
		$('#login-panel').hide();
		$('#login-details-panel').show();
	});
	
	// 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);
	});
	
	// Submenus
	$('.header-nav ul > li').not(".header-nav ul li li").hover(
	function(){
		$('ul', this).fadeIn(100);
	}, 
	function(){
		$('ul', this).delay(400).fadeOut(200);
	});
	
	// 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") ) );
	});
	
	// Colorbox Init
	$('.gallery-icon a').attr('rel', 'post-gallery');
	$("a[rel='gallery'], a[rel='lightbox'], .gallery-icon a, .colorbox").colorbox({
		maxWidth: '85%',
		maxHeight: '85%'	
	});
	
	// Remove margins
	$('.gallery-thumb:nth-child(3n)').addClass('last');
	
	// Slider Init
	$('.slider').slides({
		play: 4500,
		pause: 2500,
		hoverPause: true,
		effect: 'fade',
		generatePagination: true
	});
	
	// Vertically center all images in the slider
	$('.slides_container').each(function(){
		var $container = $(this).height();
		$('img', this).each(function(){
			var $img = $(this).height();	
			if($img != $('.slides_container').height()){
				var $margin = ($container - $img)/2; 
				$(this).css('margin-top', $margin);
			}
		});
	});
	
	// Isotope
	$(window).load(function(){
	
		// Init		
		$('.sort, #sort').isotope({
			itemSelector : '.box:not(.invis)',
			transformsEnabled: false,
			masonry: {
				columnWidth : 190
			}
		});
		
		// Filtering
		$('#filtering-nav li a').click(function(){
		  var selector = $(this).attr('data-filter');
		  $('#sort, .sort').isotope({ filter: selector });
		  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;
}

//jQuery(document).ready(function(){
//    jQuery('#filtering-nav a').click(function(){
//        jQuery('div.isotope div').css('-moz-transform', '');
//    });
//});

/* IE PNG fix multiple filters */
(function ($) {
    if (!$) return;
    $.fn.extend({
        fixPNG: function(sizingMethod, forceBG) {
                if (!($.browser.msie)) return this;
                var emptyimg = "empty.gif"; //Path to empty 1x1px GIF goes here
                sizingMethod = sizingMethod || "scale"; //sizingMethod, defaults to scale (matches image dimensions)
                this.each(function() {
                        var isImg = (forceBG) ? false : jQuery.nodeName(this, "img"),
                                imgname = (isImg) ? this.src : this.currentStyle.backgroundImage,
                                src = (isImg) ? imgname : imgname.substring(5,imgname.length-2);
                        this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
                        if (isImg) this.src = emptyimg;
                        else this.style.backgroundImage = "url(" + emptyimg + ")";
                });
                return this;
        }
    });
})(jQuery);
