﻿$.fn.orphans = function() {
    var ret = [];
    this.each(function() {
        $.each(this.childNodes, function() {
            if (this.nodeType == 3 && $.trim(this.nodeValue)) ret.push(this)
        })
    });
    return $(ret);
}
//http://www.learningjquery.com/2008/02/simple-effects-plugins
jQuery.fn.blindToggle = function(speed, easing, callback) {
    var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
    return this.animate({ marginTop: parseInt(this.css('marginTop')) < 0 ? 0 : -h }, speed, easing, callback);
};
jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({ opacity: 'toggle', height: 'toggle' }, speed, easing, callback);
};
$(document).ready(function() {
    //s/jq/a
    $('.expand').css('cursor', 'pointer').orphans().wrap('<a href="#expand/collapse" title="expand/collapse"></a>');
    $('.collapse').hide();

    $('.fade .expand').click(function() {
        $(this).toggleClass("arrow-up");
        $(this).next('.normal').fadeToggle();
        $(this).next('.slow').fadeToggle('slow');
    });
});
