(function($){  
	$.fn.extend({   
		//plugin name - animatemenu  
		resizeHeight: function(options) {  
			var defaults = {  
				marginHeight: 260,
				minimum: 400
			};  
			var options = $.extend(defaults, options);  

			return this.each(function() { 
				if($(this).data("ratio") == null) {
					$(this).data("ratio", $(this).attr("width")/$(this).attr("height"))
				}  
				var sHeight = Math.max($(window).height() - options.marginHeight, options.minimum);
				
				$(this).attr("height",sHeight)
				$(this).attr("width",sHeight*$(this).data("ratio"))
				
				if($(this).parent().parent().hasClass("box")) {
					$(this).parent().parent().width($(this).attr("width"))
					$(this).parent().parent().height($(this).attr("height"))
					$(this).parent().parent().find(".cover").css("top", $(this).attr("height")+"px")
				}
			});  
		}  
	});  
})(jQuery);
(function($){  
	$.fn.extend({   
		//plugin name - animatemenu  
		resizeProp: function(options) {  
			var defaults = {  
				marginWidth: 200,
				marginHeight: 260,
				minimum: 400
			};  
			var options = $.extend(defaults, options);  

			return this.each(function() { 
				if($(this).data("propW") == null) {
					$(this).data("propW", $(this).attr("width")/$(this).attr("height"))
					$(this).data("propH", $(this).attr("height")/$(this).attr("width"))
					$(this).data("maxW", $(this).attr("width"))
					$(this).data("maxH", $(this).attr("height"))
				}  
				var sWidth = Math.max($(window).width() - options.marginWidth, options.minimum);
				var sHeight = Math.max($(window).height() - options.marginHeight, options.minimum);
				
				if(sHeight >= sWidth) {
					if($(this).data("propH") <= (sHeight/sWidth)) {
						$(this).attr("width",sWidth)
						$(this).attr("height",$(this).attr("width") / $(this).data("propW"))
					} else {
						$(this).attr("height",sHeight)
						$(this).attr("width",$(this).attr("height") / $(this).data("propH"))
					}
				} else {
					if($(this).data("propW") <= (sWidth/sHeight)) {
						$(this).attr("height",sHeight)
						$(this).attr("width",$(this).attr("height") / $(this).data("propH"))
					} else {
						$(this).attr("width",sWidth)
						$(this).attr("height",$(this).attr("width") / $(this).data("propW"))
					}
				}

				$(this).attr("width",Math.min($(this).attr("width"), $(this).data("maxW")))
				$(this).attr("height",Math.min($(this).attr("height"), $(this).data("maxH")))
				
				if($(this).parent().parent().hasClass("box")) {
					$(this).parent().parent().width($(this).attr("width"))
					$(this).parent().parent().height($(this).attr("height"))
					$(this).parent().parent().find(".cover").css("top", $(this).attr("height")+"px")
				}
			});  
		}  
	});  
})(jQuery);

$(function() {
	$("ul.menu li:not(:first), ul.set li:not(:first)").prepend(" - ");
	$(".blog-post:first").addClass("blog-post-first");
	margin = 6;
	if(!mobileBrowser) {
		$('.box:not(.no-animation)').hover(function(){  
	        $(".cover", this).stop().animate({top:(($(this).height()+margin)-$(".cover", this).height())+'px'},{queue:false,duration:160});  
	    }, function() {  
	        $(".cover", this).stop().animate({top:($(this).height()+margin)+'px'},{queue:false,duration:160});  
	    }).each(function() {
			$(".cover", this).css("top", ($(this).height()+margin)+'px'); 
		})
	}
	
	$(window).resize(function() {
		$(".photo").resizeProp();
	});
	$(".photo").resizeProp();
	/*
	$(window).resize(function() {
		$(".photoSet").resizeHeight({marginWidth:350});
	});
	$(".photoSet").resizeHeight({marginWidth:350});
	*/
})	


