
/* - ++resource++sbrbanking.theme.javascripts/custom_jq.js - */
/*
 * Custom jQuery functions for SRB banking
 */

/*******************************************************************************
		     Custom accordion-like system
Two CSS classes must be applied:
 - appear_desciption to the element that will appear
 - appear_title to the element that makes the previous one appear

Both elements must have a common parent, for example.
<div>
  <div class="appear_title">First element</div>
  <div class="appear_description">First element description</div>
</div>
<div>
  <div class="appear_title">Second element</div>
  <div class="appear_description">Second element description</div>
</div>

*******************************************************************************/
/* Makes the description appear */
display_desc = function() {
    desc = jq(this).parent().find('.appear_description');
    
    //desc.show(1000);
    //desc.fadeIn(1000);

    desc.animate({'height': desc.attr('rel') + 'px'}, 500);
    desc.removeClass('appear_description');
    jq(this).removeClass('appear_title');
}

/* Saves the description's height in the rel attribute,
   then sets it to 0*/
save_desc_height = function() {
    desc = jq(this);
    desc.attr('rel', desc.height());
    desc.css({'height': '0px'});
    //desc.hide();
}

/* Apply our accordion */
make_accordion = function() {
    jq('.appear_title').mouseenter(display_desc);
    jq('.appear_description').each(save_desc_height);
}

/*******************************************************************************
		      Starts our custom scripts
*******************************************************************************/
jq(window).load(function() {
    make_accordion();
});
