//IE6 Background Color
var ie6BGColor = '#cccccc';

var MenuSlides = {
    navmenu: function () {
        $$('.Menu').each(function (button, i) {
            if ($defined($('Sub' + button.id))) {
                $('Sub' + button.id).parentNode.style.top = '40px'; // Controls how far the DHTML menu appears from the bottom of the top nav bar			
                $('Sub' + button.id).parentNode.style.position = 'fixed';
                if (window.ie6) {
                    $(button.id + 'a').style.background = ie6BGColor;
                    $('Sub' + button.id).parentNode.style.width = '175px';
                    if (button.id == 10) {
                        $('Sub' + button.id).parentNode.style.left = $(button.id).getPosition().x - $('test').getPosition().x - 667 + 'px';
                    } else {
                        $('Sub' + button.id).parentNode.style.left = $(button.id).getPosition().x - $('test').getPosition().x - 560 + 'px';
                    }
                } else {
                    if (button.id == 10) {
                        $('Sub' + button.id).parentNode.style.left = $(button.id).getPosition().x - 92 + 'px';
                        $('Sub' + button.id).parentNode.style.width = '175px';
                    } else {
                        $('Sub' + button.id).parentNode.style.left = $(button.id).getPosition().x + 'px';

                    }
                }

                var menuSlide = new Fx.Slide($('Sub' + button.id), {
                    duration: 400,
                    mode: 'vertical',
                    transition: Fx.Transitions.Quad.easeOut
                });

                $('Sub' + button.id).onmouseover = function () {
                    menuSlide.stop();
                    menuSlide.slideIn();
                }

                $('Sub' + button.id).onmouseout = function () {
                    menuSlide.stop();
                    menuSlide.slideOut();
                }

                button.onmouseover = function () {
                    menuSlide.stop();
                    menuSlide.slideIn();
                }

                button.onmouseout = function () {
                    menuSlide.stop();
                    menuSlide.slideOut();
                }

                menuSlide.hide();
            }
        });
    }
}
window.addEvent('domready',function() {
	MenuSlides.navmenu();
});

window.addEvent('resize', function () {
    $clear(timer);
    timer = (function () {
        //your logic goes here

        $$('.Menu').each(function (button, i) {
            if ($defined($('Sub' + button.id))) {
                $('Sub' + button.id).parentNode.style.position = 'fixed';
                if (button.id == 10) {
                    $('Sub' + button.id).parentNode.style.left = $(button.id).getPosition().x - 92 + 'px';
                } else {
                    $('Sub' + button.id).parentNode.style.left = $(button.id).getPosition().x + 'px';

                }
            }
        });


    }).delay(500);
});
