/* Plugin zur Steuerung des Aussehens des Headermenus. Copyright 2011 Inpsyde GmbH. */

jQuery(document).ready(function ($) {
    var d = 0;
    $('div.level-0').each(function () {
        d++;
        if (d == 1) {
            var a = 10
        }
        if (d == 2) {
            var a = 25
        }
        if (d == 3) {
            var a = 40
        }
        var b = $(this).parent().offset();
        var c = parseFloat(b.left + a);
        $(this).addClass('sublist-' + d);
        $(this).css({
            'left': c + 'px'
        })
    });
    $('.topnav').children('li').addClass('js_nav');
    $(".level-0.menucontainer").parent().append("<span></span>");
    $('li.js_nav').hover(function () {
        if ($.browser.msie && $.browser.version == "9.0") {
            $(this).children('div.level-0').css({
                'display': 'block'
            })
        } else {
            $(this).children('div.level-0').show()
        }
    }, function () {
        if ($.browser.msie && $.browser.version == "9.0") {
            $(this).children('div.level-0').css({
                'display': 'none'
            })
        } else {
            $(this).children('div').fadeOut()
        }
    });
    $('li.js_nav li').hover(function () {
        if ($.browser.msie && $.browser.version == "9.0") {
            $(this).children('div.level-1').css({
                'display': 'block'
            })
        } else {
            $(this).children('div.level-1').show()
        }
    }, function () {
        if ($.browser.msie && $.browser.version == "9.0") {
            $(this).children('div').css({
                'display': 'none'
            })
        } else {
            $(this).children('div').fadeOut()
        }
    })
});
jQuery(document).ready(function ($) {
    $('div.level-0').children('ul').each(function () {
        var a = $(this);
        var b = a.clone(true);
        $('body').append(b);
        $(b).css({
            'display': 'block',
            'position': 'absolute',
            'left': '-5550px',
            'top': '-55550px'
        });
        var c = parseFloat($(b).outerWidth());
		if ($.browser.msie && $.browser.version == "9.0") {
			var ie_width = parseFloat(width+15);
        	$(this).children('li').children('a').width(c)
		}
		else{
			var other_browsers_with = parseFloat(width+10);
			$(this).children('li').children('a').width(other_browsers_with)	
		}
    });
    $('div.level-1').children('ul').each(function () {
        var a = $(this);
        var b = a.clone(true);
        $('body').append(b);
        $(b).css({
            'display': 'block',
            'position': 'absolute',
            'left': '-2220px',
            'top': '-22220px'
        });
        var c = parseFloat($(b).outerWidth() + 10);
        $(this).css({
            'width': c + 'px'
        })
    })
});
