﻿/*-------------------------------------------------------------------       
Script name:    Multi level navigation system
Description:    Script to provide 4 levels of site navigation
Version:        v1.0
Dependancies:   jQuery v1.3.2 
Author:         Luke Guppy
Created date:   03/10/2011
Modified by:    Luke Guppy
Modified date:  
Notes:          
-------------------------------------------------------------------*/
$(function() {
    setAccordion($('#nav ul ul li a'), 'closed');
    if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
        $('#nav li').bind('hover', function() {
            $(this).addClass('over');
        });
        $('#nav ul li').unbind();
    }
    // Stop navigation to products hub page
    $('a.products').bind('click', function() {
        return false;
    });
});

function setAccordion(item, start) {
    switch (start) {
        case "closed":
            $(item).next().hide();
            break;
        case "open":
            $(item).addClass('open');
    }
    $(item).bind('click', function() {
        if ($(this).hasClass('open')) {
            $(this).removeClass('open').next().slideUp('slow');
        }
        else {
            // find the open drawer, remove the class, move to the next element following it and hide it
            $(this).parent().parent().parent().parent().find('li a.open').removeClass('open').next().slideUp('slow');
            // add the open class to this A, move to the next element (i.e UL) and show it
            $(this).addClass('open').next().slideDown('slow');
        }
        return false;
    });
    $('#nav ul ul ul li a').unbind();
};

