﻿$(document).ready(function() {
    $('.headerdropdown').find('tt').click(function() {
        if (typeof document.addEventListener != 'function') { // if  ie6
            var ddwidth = $(this).parent().width();
            $(this).parent().find('div').width(ddwidth);
            $(this).parent().find('ul').width(ddwidth - 2);
        }
        $(this).parent().toggleClass('headerdropdown_active');
    });
    $('.headerdropdown').hover(function() {
        //in
        $(this).find('tt').addClass("hover");
    }, function() {
        //ut
        $(this).find('tt').removeClass("hover");
    });

    $(document.body).click(function(e) {
        $('.headerdropdown tt').blur();
        if ($('.headerdropdown tt').index(e.target) < 0) {
            $('.headerdropdown').removeClass('headerdropdown_active');
        }
    });
});
