/**
 * jQuery shadow plugin
 * Author: Benjamin Michotte
 */
 jQuery('#sscateglist').show()
 jQuery('#sscateglist').hide()
if(jQuery) 
(function(jQuery) 
{
	jQuery.extend(jQuery.fn, 
	{
		shadowify: function(options) 
		{
			options = jQuery.extend(
			{
				color: "#aaaaaa",
				vertical: 8,
				horizontal: 8,
				fade: 12,
				text: false,
				border: "10px solid white",
				autoborder: false
			}, options || {});
			
			return this.each(function()
			{
				var value = options.horizontal + 'px ' + options.vertical + 'px ' + options.fade + 'px ' + options.color;
				var opt = options.text ? 'text-shadow' : 'box-shadow';
				if (jQuery.browser.msie)
				{
					opt = options.text ? '' : 'progid:DXImageTransform.Microsoft.';
					var direction = 180 - ((options.vertical / Math.abs(options.vertical)) * Math.sin(options.vertical) * (180 / Math.PI));
					jQuery(this).css({
						filter: opt + "Shadow(color='" + options.color + "', Direction=" + direction + ", Strength=" + options.fade + ")",
						zoom: 1
					}); 
				}
				else if (jQuery.browser.safari)
				{
					jQuery(this).css('-webkit-' + opt, value);
				}
				else if (jQuery.browser.mozilla)
				{
					jQuery(this).css('-moz-' + opt, value);
				}
				
				// ajout du box-shadow sans extension pour le futur
				jQuery(this).css(opt, value);
				
				if (options.autoborder)
				{
					jQuery(this).css('border', options.border);
				}
			});
		}
	});
})(jQuery);



jQuery(document).ready(function(){
	function share()
	{
		window.open(jQuery(this).attr('href'), 'sharer', 'toolbar=0,status=0,width=626,height=436');
		return false;
	};
	
	jQuery('.facebookLink').click(share);
	
	if(window.location.href.indexOf('home') != -1){
		jQuery('.pubbox').hide();
	// select the overlay element - and "make it an overlay"
	jQuery('.pubbox').overlay({
		// custom top position
		top: 200,
		// some mask tweaks suitable for facebox-looking dialogs
		mask: {
			// you might also consider a "transparent" color for the mask
			color: '#000000',
			// load mask a little faster
			loadSpeed: 200,
			// very transparent
			opacity: 0.9
		},
		// disable this for modal dialog-type of overlays
		closeOnClick: true,
		// load it immediately after the construction
		load: true
	});
	}
	jQuery('ul.select_elem li a').click(function(){
		if(jQuery(this).parent().parent().hasClass('select_open')){
			jQuery(this).parent().parent().removeClass('select_open');
			jQuery(this).parent().parent().children('.selected').each(function(){
				jQuery(this).removeClass('selected');
			});	
			jQuery(this).parent().addClass('selected');
			/*jQuery(this).parent().parent().css('background','url("/skin/frontend/nutrico/bicycle/images/nutrico/bg_select.gif") top left no-repeat;');*/
			
		}else{
			jQuery(this).parent().parent().children('.selected').each(function(){
				jQuery(this).removeClass('selected');
			});
			jQuery(this).parent().parent().addClass('select_open');
		}
	});	
	
	jQuery('.col-main').shadowify({ vertical: 1, horizontal: 1, color: '#777777', fade: 2 });
	jQuery('.block-top10,.block-upsell').shadowify({ vertical: 1, horizontal: 1, color: '#777777', fade: 2 });
	jQuery('.block').shadowify({ vertical: 1, horizontal: 1, color: '#777777', fade: 2 });
	jQuery('.title-catbox a').shadowify({ text: true, vertical: 1, horizontal: 1, fade: 2 });
	jQuery('button.button span').shadowify({ vertical: 1, horizontal: 1, color: '#777777', fade: 2 });

	
});

jQuery(document).click(function(e){
	var className = e.target.parentNode.parentNode.className;	
	if(-1 == className.indexOf('select_elem')){
		jQuery('ul.select_open').each(function(){
			
			jQuery(this).removeClass('select_open');
			jQuery(this).children('.selected').each(function(){
				jQuery(this).removeClass('selected');
			});	
			jQuery(this).children().first().addClass('selected');
			
		});
	}
});

function showChildren(){
	jQuery('#sscateglist').show();	
}
