window.addEvent('domready', function(){
	var el = $$('#nav li'),
        color = el.getStyle('backgroundColor');

    $$('#nav li').addEvents({
        mouseenter: function(){
            // We set the cursor to pointer so users know they can click this region
            this.setStyle('cursor','pointer');

            // Change background color on mouseover
            this.morph({
    	        'background-color': '#434343',
                'background-image': 'url(images/navslider.gif)', //Background image
                'background-repeat': 'no-repeat',
                'background-position': [0, 270], //image will move from left to right - Values are in pixels.
            });
		},
        mouseleave: function(){
            // Morphes back to the original style
            this.morph({
                'background-image': 'none',
                backgroundColor: color
            });
        }
    });


    //We retrieve the link location (href) and assign it to LI to make the whole region clickable
    var link = $$('#nav li a');
    link.each(function(element) {
        element.getParent().addEvent('click', function(){
            window.location = element.get('href');
            // on click, background color and border will turn to a different color
            this.morph({
                'background-image': 'none',
                'background-color': '#fff'
            });
        });
    });
});

