window.onload = function(){
	
	var ie6Selects,
		hideSelects = function(){
			$$('.ie6 select').each(function(element){
				element.hide();
			});
		},
		showSelects = function() {
			$$('.ie6 select').each(function(element){
				element.show();
			});
		};
	
	(function(){
		var basket = $$('.topbar li.basket a')[0],
			cart = $$('div.cart-menu')[0],
			mousewithin = false,
			hideCart = function(){
				if (!mousewithin) {
					basket.removeClassName('active');
					cart.removeClassName('cart-menu-active');
					showSelects();
				}
			};
		
		basket.observe('mouseover',function(event){
			mousewithin = true;
			basket.addClassName('active');
			cart.addClassName('cart-menu-active');
			hideSelects();
		});
		cart.observe('mouseover',function(event){
			mousewithin = true;
		});
		basket.observe('mouseout',function(event){
			mousewithin = false;
			new PeriodicalExecuter(function(pe){
				pe.stop();
				hideCart();
			}.bind(this),.1);
		});
		cart.observe('mouseout',function(event){
			mousewithin = false;
			new PeriodicalExecuter(function(pe){
				pe.stop();
				hideCart();
			}.bind(this),.1);
		});
	})();
	
	if ($$('div.filters')) {
		(function(){
			$$('div.filters .lines h3').each(function(title){
				title.insert({bottom:'<span class="toggle"></span>'});
				title.down('.toggle').observe('click',function(event){
					this.up('div').toggleClassName('closed');
				});
			});
		})();
	}
	
	if(jQuery('body.home').length > 0) {
		var i = 1;
		var div = jQuery('<div class="product-overview" />');
		
		//if ( jQuery.browser.msie ) {
		if (false) {
			jQuery('div.main-content-right')[0].innerHTML = jQuery('div.main-content-right')[0].innerHTML + div.html();
		}
		else {
			jQuery('div.main-content-right').after(div);
		}
		div.attr('id', 'product-overview-2');
		div.html('<ul />');
		div.css('overflow', 'visible');
		
		div.find('ul').css('padding', '0px').css('margin', '0px');
		jQuery('body.home ul.product-overview li').each(function() {
			if(i > 6) {
				jQuery(this).appendTo(jQuery('#product-overview-2 ul'));
			}
			i++;
		});
	}
	
	jQuery('.ie7 .home .main-content-left form p').css('height', '20px').css('overflow', 'visible');
	jQuery('.ie7 .catalog-product-view .main-content-left form p').css('height', '9px').css('overflow', 'visible');
	
	if (jQuery('div.paging').length > 0) {
		var div = jQuery('<div class="toolbar-2" />');
		
		//product-overview
		jQuery('ul.product-overview').after(div);
		jQuery('div.paging').clone().appendTo('div.toolbar-2');
		
	}
	
}
