jquery code example

/**
* Andrey Zakharov 2009
*/

/**
* Accordion effect for my
* portfolio
* @uses drupal, jquery, .left_articles h2
* provides for css:
* .accordion-header
* #accord-1, #accord-2, and so on
*///
if ( Drupal.jsEnabled ) {
$( document ).ready( function() {
var accordionNum = 1;//accordion number
var sliding = false;

$( ".left_articles h2" ).wrap( "" ).mouseover( function( e ) {

if ( false == sliding ) {
sliding = true;

$( ".left_articles h2" ).each( function() {

if ( e.target.id == this.id ) {//we check all, and this one is event subject

if ( ! $( e.target.accordion ).is( ":visible" ) ) {//show if hidden
$( e.target.accordion ).slideDown( "fast", function() { sliding = false } );

} else {
sliding = false;
}

} else {

if ( $( this.accordion ).is( ":visible" ) ) {//close if visible all others
$( this.accordion ).slideUp( "fast", function() { sliding = false } );
}
}
} );
}

} ).each( function() {
this.accordion = $( this ).parent().next();

if ( "" == this.id ) this.id = "accord-" + accordionNum++;
} );

$( "#header-blocks" ).fadeIn( "slow" );

} );
}