$(function() {
	$('.storycontent img').lazyload({effect : "fadeIn"});

	$('div.add_comment').hide()
	$('div.send_to_friend').hide()
		
	$('.comments_box .buttons a').click(function() {
		elem = $(this).attr('class')
		parent = $(this).parent().parent()

		if(elem == 'add_comment' && $(parent).find('div.add_comment:hidden').size() > 0) {
			$(parent).find('div.add_comment').slideDown(1000)
			$(parent).find('div.send_to_friend').slideUp(1000)
		} else if(elem == 'send_to_friend' && $(parent).find('div.send_to_friend:hidden').size() > 0) {
			$(parent).find('div.send_to_friend').slideDown(1000)
			$(parent).find('div.add_comment').slideUp(1000)
		} else {
			$(parent).find('div.' + elem).slideUp(1000)
		}
		
		if(elem == 'link_to_post') {
			alert($(this).attr('href'))
		}
		
		return false;
	})
	
	$('.scroll-pane').jScrollPane({scrollbarWidth: 17});
	
	$('#menu dl').hover(function() {
		$(this).find('ul:first').css({display: 'block'})
	}, function() { 
		$(this).find('ul:first').css({display: 'none'})
	})

        $('.post').each(function(i) {
            $(this).find('.postcontent_whole:first').slideToggle('slow');
            
            var the_post = this
            var first_img = $(this).find('.postcontent_whole img:first')
            var postheader = $(this).find('.postheader')
            $(postheader).html(first_img)

            $(this).find('.storytitle h3:first').click(function() {
                $(the_post).find('.postcontent_whole:first').slideToggle('slow');
				$(postheader).slideToggle('slow');
            })
            $(postheader).click(function() {
                $(the_post).find('.postcontent_whole:first').slideToggle('slow');
				$(postheader).slideToggle('slow');
            })
        })
})

/* Focusing Text Elements */
function textOnFocus(element) {
	if(element.value == element.defaultValue) {
		element.value = "";
	}
}

function textOnBlur(element) {
	if(element.value == "") {
		element.value = element.defaultValue;
	}
}
/* END Focusing Text Elements */



