ptemedia 0 Light Poster

Hi,

This may seem like a really easy fix but I'm new to JQuery and I've been staring at my code for ages now and can't find the solution.

The code is for a two line navigation system. It works fine except when the user stops hovering over 'wrap' the default line must show. This will be done with $alwaysactive. The default is initially "Type" but this will change when the user clicks on the other main categories.

The window alert works so I think my variable is ok. But the 2 lines before that do not work. Can anyone spot what I am doing wrong?

Thanks

Patrick

Here is the code:

$(document).ready(function () {

    $(Type).siblings(".sub-links").show();
    $(Type).addClass("hovactive");
    var $alwaysactive = null;
    $alwaysactive = "$Type"; 

    $("#main-nav li a.main-link").hover(function () {
        $("#main-nav li a.main-link").removeClass("hovactive");
        $(this).addClass("hovactive");
        $(".sub-links").hide();
        $(this).siblings(".sub-links").show();
    });

    $("#wrap").hover(function () {
        //do nothing
    }, function () {
        $("#main-nav li a.main-link").removeClass("hovactive");
        $(".sub-links").hide();
        $alwaysactive.siblings(".sub-links").show();
        $alwaysactive.addClass("hovactive");
        window.alert("The active tab is " + $alwaysactive + ".");
    });

    $("#main-nav li a.main-link").click(function () {
        alwaysactive = (this);
    });

});