jQuery(document).ready(function($) {
	
	//prevent default on links with # as href
	$('body a[href=#]').click(function(event) { event.preventDefault(); });
		
	
	//size main nav
	/*
	$('#nav').each(function() {
		var w = 0;
		$(this).find('ul:NOT(ul.hover) li').each(function() { if(!$(this).parent('ul').hasClass('hover')) { w = w + $(this).innerWidth(); } });
		$(this).width(w);
	});*/
	
	//nav dd
	$('#nav ul li.mainnav').each(function() {
		var li = $(this), ul = $(this).find('ul.hover');
		
		if(ul.length > 0) {
			ul.find('li').eq(1).css('padding-left', 0);
			
			if(ul.length > 0) {
				var w = 0;
				ul.find('li').each(function() { w = w + $(this).innerWidth(); });
				ul.find('li').eq(0).css('margin-left', 250-(w/2));
				ul.hide().css('top', '10px');
			}
			
			//hover
			li.hover(function() {				
				if(ul.css('display') == 'none') {
					ul.show("slide", {direction:"left"}, 300);
				}
			}, function() {
				//ul.hide();
				if(ul.css('display') != 'none') {
					ul.hide("slide", {direction:"right"}, 300);
				}
			});
		}
		
	});
		
	//comment scroll
$('#posts div.comments-wrap').jScrollPane(
{
verticalDragMinHeight: 30,
			verticalDragMaxHeight: 30,
}
);
	
	
	
	//remove margin on first archive
	$('.archives .archive:first').css('margin-left', 0);
	
	//post slideshow
	$('#posts .post .post-content .post-slideshow').each(function() {
		var wrap = $(this);
		var prev = wrap.find('.prev'), next = wrap.find('.next');
		wrap.find('.images').cycle({
								   timeout:0,
								   speed:500,
								   fx:'scrollHorz',
								   prev:prev,
								   next:next
								   });
	});
	
	//social links in footer
	$('#footer .social').each(function() {
		var f = $(this);
		
		f.find('a.s1').click(function(e) {
			e.preventDefault();
			window.open('http://facebook.com/DanLanning/');
			window.open('http://facebook.com/CandiceLanning/');
		});
		
		f.find('a.s2').click(function(e) {
			e.preventDefault();
			window.open('http://twitter.com/DanLanning/');
			window.open('http://twitter.com/CandiceLanning/');
		});
		
	});
		
});
