﻿
//  don't delete this -  it is a VS script reference to the jQuery file, and allows intellisense to almost work
/// <reference path="~/scripts/jquery-1.3.2.js" />

// define variables
var maxListItemWidth = new Object();

function lclDropDownToggle() {
    // default width
    defaultWidth = 178;
    // maxListItemWidth contains max item length for all lists passed (via id)
    if (maxListItemWidth == undefined) maxListItemWidth = 0;
    // get the max width of a list item	
    if (maxListItemWidth == 0) {
        $(".dropdownText ul li span").each(function() {
            if (maxListItemWidth < ($(this).width() * 1.40))
                maxListItemWidth = ($(this).width() * 1.40);
        });
    }
    // if maxListItemWidth < defaultWidth : maxListItemWidth = defaultWidth
    if (maxListItemWidth > defaultWidth) {
        // and set them all to the same 'wider' width
        $(".dropdownText ul li span").each(function() {
            $(this).width(maxListItemWidth);
            $(".dropdownText ul li span").width(maxListItemWidth);
        });
    } else {
        // set container to default
        $(".dropdown").width(defaultWidth);
    }


    // change the close icon state
    $(".langDropdown > ul > li > a").toggleClass("close");
    //toggle the dropdown
    $(".langDropdown ul li .dropdown").slideToggle("fast");
};
