$(document).ready(function() {

/* Toggle Drop Down Navgation */
$(".dropdown").click(function () {
$(".navigation").toggle();

});

/* Center Drop Down Navgation */
var popNavigtion = $('.navigation');
popNavigtion.css({
    position: 'absolute',
    left: '50%',
    'margin-left': 0 - (popNavigtion.width() / 2)
});

/* Hide Drop Down Navgation on Click*/
$(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("toolbar"))
                    $(".navigation").fadeOut(100);
});

/* Large Tumblr Video Embeds and Photosets */
var $vidPlayer = $(".video-frame embed, .video-frame span embed, .video-frame iframe, .video-frame object, .photo embed");
var playerWidth = $(".post").width();

$vidPlayer.each(function(){
    var $this = $(this);
    var aspect = $this.attr("height") / $this.attr("width");

    $(window).resize(function() {
          $this.width(playerWidth).height(playerWidth * aspect);
    }).trigger("resize");
})
						
});

/**********************************************************************************************
**  jQuery Kill Photoset v1.0 (for Tumblr themes)
**  This gets rid of the flash slideshow Tumblr forces photo posts with multiple images to use.
**  
**  Copyright © 2010 Chris Kalani
**  MIT License - http://www.opensource.org/licenses/mit-license.php
**  Project URL: http://chriskalani.com/killphotoset
**********************************************************************************************/

;(function($){

	var defaults = {
		photoSize: 1280
	};
	
	$.fn.killPhotoset = function(options){ 
	
		var o =  $.extend(defaults, options);
		
		return this.each(function(){
		
			var $this = $(this);
			
			$this.empty();
			
			var set = $this.attr("id");
			var id = set.split("_")[1];
			
			$.getJSON("/api/read/json?id="+id+"&callback=?", function(boom){
			
				var pix = boom["posts"][0]["photos"];
				
				$.each(pix, function(){
					var img = this["photo-url-"+o.photoSize];
					$this.append('<p><img src="'+img+'" /></p>');
				});
			
			});
		});
	};
})(jQuery);


