﻿(function ($) {

    var resize = function () {
        $('.second-level').each(function () {
            var bufferWidth = 11;
            var sBrowser = navigator.userAgent;
            if (sBrowser.toLowerCase().indexOf('msie 7.0') > 0) {
                bufferWidth = 11;
            }
            var calculatedWidth = $('.header').width() - ($('.header').width() - 960) / 2 - bufferWidth;
            $(this).width(calculatedWidth);
        });
    };
    $(window).resize(function () { resize() });
    resize();
    if ($('.second-level').length > 0) {
        $('.first-level li.selected').addClass("selectedArrow");
    }
    // Toogle watermark on input fields
    $(':input[type=text][title]').each(function () {

        var $this = $(this);
        if ($this.val() !== '')
            return;

        $this.val($this.attr('title'));
        $this.focus(function () {
            if ($this.val() === $this.attr('title')) {
                $this.val('');
            }
        });
        $this.blur(function () {
            if ($this.val() === '') {
                $this.val($this.attr('title'));
            }
        });
    });
})(jQuery);
