﻿Event.observe(window, 'load', function() {

    Event.observe(document, 'mouseover', function(event) {
         
         var el = event.element();

         if ($$('div.filters div.selected').length > 0 && !el.descendantOf($('filters')) && !el.descendantOf($('filters-content')))
         //if ($$('div.filters div.selected').length > 0 && !el.hasClassName('filter') && !el.descendantOf($('filters-content')))
         
         
         //if ($$('div.filters div.selected').length > 0 && el.id == 'filter-name' && !el.descendantOf($('filters-content')))
         {
             $('filters-content').childElements().invoke('hide'); // first level elements
             $('filters').childElements().invoke('removeClassName', 'selected');
         }
    });

    $$('div.filter').each(function(item) { item.observe('mouseover', function(event) {

            var el = event.element();
            
            if ($(el.id + '-content').innerHTML.length > 0)
            {
                $('filters').childElements().invoke('removeClassName', 'selected');
                el.addClassName('selected');
                
                $('filters-content').childElements().invoke('hide'); // first level elements
                $(el.id + '-content').show();   
            }  
        });
    });
});

function filter()
{
    var categoryId = document.getElementById("CategoryFilter").value;
    var colourId = document.getElementById("ColourFilter").value;
    var sizeId = document.getElementById("SizeFilter").value;
    var priceId = document.getElementById("PriceFilter").value;
       
    if (categoryId == 0 && colourId == 0 && sizeId == 0 && priceId == "0|1000")
    {
        window.location = _url;
    }
    else
    {
        window.location = _url + "?categoryId=" + categoryId + "&colourId=" + colourId + "&sizeId=" + sizeId + "&priceId=" + priceId;
    }
}
