var ProductLanding = new Class({
	init: function()
	{
        var productLinks = $ES('div#content ul.productLinks li');
        
        $$('div#content div.productImages span a img').each(function(item, index)
        {
               var altItems = $$('div#content div.productImages span a img');
               item.addEvents({
                    'mouseenter': function()
                    {
                        altItems.remove(item);
                        
                        altItems.each(function(otherItem) {
                            otherItem.setOpacity(0.55);
                        });
						var link = productLinks[index];
						if (link.hasClass('new'))
							link.addClass('selected_new');
						else
							link.addClass('selected');
                    },
                    
                    'mouseleave': function()
                    {
                        altItems.remove(item);
                        
                        altItems.each(function(otherItem) {
                            otherItem.setOpacity(1);
                        });
						var link = productLinks[index];
						if (link.hasClass('selected_new'))
							link.removeClass('selected_new');
						else
							link.removeClass('selected');
                    }
            });
        });
        
        var productImages = $$('div#content div.productImages span img');
    
        $ES("ul.productLinks li a", "info").each(function(item, index) {
            item.addEvents({
                'mouseenter': function(event) {
                    productImages[index].fireEvent("mouseenter");
                },
                
                'mouseleave': function(event) {
                    productImages[index].fireEvent("mouseleave");
                }
            });
        });
	}
});

var productLanding = new ProductLanding();

window.addEvent('load', function()
{
	productLanding.init();
});
