jQuery(document).ready(function () {
	/** menu **/
	var $menu = jQuery('#menu_principal > ul');
	jQuery('> li', $menu).eq(-2).addClass('last-item');
	jQuery('> li', $menu).not('.last-item').bind('mouseenter', function () {
		jQuery(this).addClass('hover-item');
	}).bind('mouseleave', function () {
		jQuery(this).removeClass('hover-item');
	});
	jQuery('> li', $menu).eq(1).width('107px');
	jQuery('> li', $menu).eq(2).width('157px');
	jQuery('> li', $menu).eq(3).width('147px');
	jQuery('> a', jQuery('> li', $menu).eq(1)).width('107px');
	jQuery('> a', jQuery('> li', $menu).eq(2)).width('157px');
	jQuery('> a', jQuery('> li', $menu).eq(3)).width('147px');
	/** breadcrumb **/
	jQuery('.navigation-pipe:eq(0), .navigation-pipe:eq(1), a:eq(0)', jQuery('#category_title h1')).remove();
	jQuery('.navigation-pipe:eq(0), .navigation-pipe:eq(1), a:eq(0)', jQuery('.breadcrumb')).remove();
	/** ookoodoo **/
	jQuery('#ookoodoo_action').bind('click', function () {
		popInSelector();
		return false;
	});
	
	var no_scroll = false;
	
	/** columns **/
	var lH = parseInt(jQuery('#left_column').height());
	var rH = parseInt(jQuery('#right_column').height());
	var $c = jQuery('#center_column');
	if (jQuery('#category_wrapper').length) {
		$c = jQuery('#category_wrapper');
	}
	var cH = parseInt($c.height());
	if (lH > cH) {
		$c.height(lH + 'px');
		no_scroll = true;
	}
	else jQuery('#left_column').height(cH + 'px');
	if (rH > cH) $c.height(rH + 'px');
	else jQuery('#right_column').height(cH + 'px');

	/** product_list **/
	jQuery('.ajax_block_product').live('mouseenter', function () {
		jQuery('.price', jQuery(this)).css('background-position', 'left bottom');
	}).live('mouseleave', function () {
		jQuery('.price', jQuery(this)).css('background-position', 'left top');
	});
	
	jQuery('#product_list li a, .home_bottom_block_li a, #liste_themes li a').bind('mouseenter', function(e) {
		var tip0 = jQuery(this).parent().find('strong');
		if( !tip0.length ) {
			tip0 = jQuery(jQuery(this).parents().get(1)).find('strong');
		}
		if( !tip0.length ) {
			tip0 = jQuery(jQuery(this).parents().get(2)).find('strong');
		}
		var tip = tip0.text();
		jQuery(this).attr('title','');
		if( tip!='' && tip!='null' && tip!=null ) {
			jQuery('body').append('<div id="tooltip">' + tip + '</div>');
			jQuery('#tooltip').css({
				'opacity': 0.1, 
				'line-height': '1.1em',
				'top' : e.pageY - 40,
				'left' : e.pageX + 15
			}).fadeTo(500,0.9);
		}
	}).bind('mousemove', function(e) {
		jQuery('#tooltip').css({
			'top' : e.pageY - 40,
			'left' : e.pageX + 15 
		});
	}).bind('mouseleave', function() {
		jQuery('#tooltip').remove();
	});
	
	/** product **/
	jQuery('.cloud-zoom').CloudZoom()
	
	/** scroll **/
	if (jQuery('#axome_filtres').length > 0) {
		var $catalogue_bloc = jQuery('#axome_filtres');
		var catalogue_top = $catalogue_bloc.offset().top;
		var catalogue_height = $catalogue_bloc.outerHeight();
		var flh = 0;
		if (jQuery('#freeblock_left').length == 1) flh = jQuery('#freeblock_left').outerHeight();
		var max_left = jQuery('#left_column').outerHeight() - flh - jQuery('#special_block_right').outerHeight() - catalogue_height - jQuery('#left_column').offset().top;
		if (!no_scroll) {
			jQuery(window).bind('scroll', function () {
				var newTop = jQuery(document).scrollTop();
				if (newTop > catalogue_top) {
					var ctop = newTop - catalogue_top + 10;
					if (ctop < max_left) {
						$catalogue_bloc.stop().animate({
							'margin-top' : ctop + 'px'
						}, 250);
					}
				} else {
					$catalogue_bloc.css({
						'margin-top': 0
					});
				}
			});
			jQuery('input[type=checkbox]', $catalogue_bloc).bind('change', function () {
				jQuery(document).scrollTop(0);
			});
		}
	}
});

