$
(document
).
ready
(
function
(
)
{
var hide =
false;
// Shows the DIV on hover with a fade in
$
(
"li#sub-one a"
).
click
(
function
(
)
{
if
(hide
) clearTimeout
(hide
);
$
(
"#guitar-course"
).
fadeIn
(
);
// The main nav menu item is assigned the 'active' CSS class
$
(
this
).
addClass
(
"active"
);
},
function
(
)
{
// Fades out the DIV and removes the 'active' class from the main nav menu item
hide = setTimeout
(
function
(
)
{$
(
"#guitar-course"
).
fadeOut
(
"fast"
);
}
);
$
(
"li#sub-one a"
).
removeClass
(
"active"
);
}
);
// Ensures the DIV displays when your mouse moves away from the main nav menu item
$
(
"#guitar-course"
).
hover
(
function
(
)
{
if
(hide
) clearTimeout
(hide
);
$
(
"li#sub-one a"
).
addClass
(
"active"
);
},
function
(
)
{
// If your mouse moves out of the displayed hidden DIV, the DIv fades out and removes the 'active' class
hide = setTimeout
(
function
(
)
{$
(
"#guitar-course"
).
fadeOut
(
"fast"
);
}
);
$
(
"#guitar-course"
).
stop
(
).
fadeIn
(
);
$
(
"li#sub-one a"
).
removeClass
(
"active"
);
}
);
}
);