Event.observe(window, "load", function() {
	Cufon.replace('.avt-gde');
	Cufon.replace('#nav li.level0', { hover: true });
	Cufon.replace('#nav li.active', { hover: true });
	
	jQuery('#nav').css('text-indent', '0');
	jQuery('.avt-gde').css('text-indent', '0');
	jQuery('.home-middle-box-mini .header h4').css('text-indent', '0');
	jQuery('.home-middle-box .header h4').css('text-indent', '0');
	
	DecorateProductList.init();
	DecorateEffectButton.init();
});

jQuery(document).ready(function(){
	
	jQuery('#category').sSelect();
	
	jQuery('a[@rel*=lightbox]').lightBox();
	
	/*if(!jQuery.browser.msie || (jQuery.browser.msie && (jQuery.browser.version.substr(0,1) > 6 )))
	{*/
		jQuery('.select-sort-by').sSelect();
		jQuery('.select-per-page').sSelect();
	/*}*/
	
	/*jQuery('li.active').prev('li.parent').hide();
	
	console.log(jQuery('li.active').prev('li.parent').children('a'));*/

});


var DecorateProductList = {
	init: function() {
		
		jQuery('.product-list').equalHeights();
		
		var currentTallest = 0;
		
		$$('.home-middle-box-mini li').each( function(elmt) {
			
			var height = $(elmt).getHeight();
			
			if (height > currentTallest) { currentTallest = height; }

		});
		
		$$('.home-middle-box-mini li').each( 
			function(elmt){
				$(elmt).setStyle({'height': currentTallest+'px'});
			}
		); 
		
		$$('.product-list li').each( function(elmt) {
			Event.observe(elmt, 'mouseover', DecorateProductList.colorIt);
			Event.observe(elmt, 'mouseout', DecorateProductList.uncolorIt);
		});
		
	},
	
	colorIt: function(event) {
		$(this).addClassName('over');
	},
	
	uncolorIt: function(event) {
		$(this).removeClassName('over');
	}
}

var DecorateEffectButton = {
		init: function() {
			
			$$('.btn-effect').each( function(elmt) {
				Event.observe(elmt, 'mouseover', DecorateEffectButton.activeIt);
				Event.observe(elmt, 'mouseout', DecorateEffectButton.disableIt);
			});
			
		},
		
		activeIt: function(event) {
			
			
			if( jQuery(this).hasClass("btn-grey") )
			{
				$(this).addClassName('btn-grey-over');
			}
			else if( jQuery(this).hasClass("tab-grey") )
			{
				$(this).addClassName('tab-grey-over');
			}
			else
			{
				var btnHeight = jQuery(this).height();
				
				jQuery(this).css("background-position", "0 "+ (-btnHeight)+"px");
				$(this).addClassName('effect-over');
			}
		},
		
		disableIt: function(event) {
			
			if( jQuery(this).hasClass("btn-grey") )
			{
				$(this).removeClassName('btn-grey-over');
			}
			else if( jQuery(this).hasClass("tab-grey") )
			{
				$(this).removeClassName('tab-grey-over');
			}
			else
			{			
				jQuery(this).css("background-position", "0 0");
				$(this).removeClassName('effect-over');
			}
		}
	}



CategSearch = Class.create();
CategSearch.prototype = {
	initialize: function() {	
		/*Event.observe('categ', 'focus', this.showCategList);*/
	},
	
	showCategList: function() {
		$('categ_search_list').show();
	}
}

CartShippingPrice = Class.create();
CartShippingPrice.prototype = {
	initialize: function() {
		Event.observe('country', 'change', this.shippingCountryChange);
		
		if($('country').getValue() == "")
		{
			$('country').setValue("FR");
			$('shipping-zip-form').submit();
		}
	},
	shippingCountryChange: function() {
		if($('country').getValue() != "")
			$('shipping-zip-form').submit()
	}
}

function overMenu(el, over)
{
    if (over) {
        Element.addClassName(el, 'over');
    }
    else {
        Element.removeClassName(el, 'over');
    }
}
