jQuery.noConflict();

/*
 * General DOM ready statemenets
 */
jQuery(function($) {
	
	$('li').mouseover(function(){
		$(this).addClass('over');
	}).mouseout(function(){
		$(this).removeClass('over');
	})
		
	
	//左右移动图片
	$(".scrollable").scrollable({circular:true});
	$('.col-main-style').cycle({ 
		fx:     'scrollLeft', 
		timeout: 5000
	 });



	//左导航	
	$('.left-navgation #left-nav a').each(function(){
		if($(this).attr('href')==document.location){
			$(this).parent().addClass('active');
			$(this).parent().parent().parent().addClass('active');
			$(this).parent().parent().parent().children('.expander').addClass('active');
			$(this).parent().parent().parent().children('.expander').children('a').addClass('active');
			//$('#left-nav .level1 .level2 .expander.active .expander-ico').css('background-position','0 -13px')
		}
	});
	
	$('#left-nav li.active').each(function(){
		if($(this).children('ul').length>0){
				$(this).children('ul').show();
		}
	})
	
	
	$('.expander-ico').each(function(){
		if($(this).parent().children('ul').length>0){
			if($(this).parent().children('ul').css('display')=='none'){
					$(this).attr('title','plus');
					$(this).css('background-position','0 0');
				}else{
					$(this).attr('title','mois');
					$(this).css('background-position','-32px 0');
				}
		}else{
			if($(this).parent().next('ul').css('display')=='none'){
					$(this).attr('title','plus');
					$(this).css('background-position','0 0');
				}else{
					$(this).attr('title','mois');
					$(this).css('background-position','-32px 0');
				}
		}
	});
	
    $('.expander-ico').mouseover(function(){
		if($(this).attr('title')== 'plus'){
			$(this).css('background-position','0 -34px');
		}else{
			$(this).css('background-position','-32px -33px');
		}
	 }).mouseout(function(){
		if($(this).attr('title')== 'plus'){
			$(this).css('background-position','0 0');
		}else{
			$(this).css('background-position','-32px 0');
		}
	 });	
	
	$('.expander-ico').click(function(){
		if($(this).parent().children('ul').length>0){
			$(this).parent().children('ul').slideToggle();
		}else{
			$(this).parent().next('ul').slideToggle();
		}
		if($(this).attr('title')== 'plus'){
			$(this).css('background-position','0 -34px');
			$(this).attr('title','mois');
		}else{
			$(this).css('background-position','-32px -33px');
			$(this).attr('title','plus');
		}
	});
	
	
		
		
	//tabs
	$('#tab1').click(function(){
		$('.IM_tabs .tab').removeClass('actived');
		$(this).parent().parent().addClass('actived');	
		$('.product-view .product-collateral .box-collateral').css({"display":"none"});
		$('.product-view .product-collateral .box-description').css({"display":"block"});		
	});
	
	$('#tab2').click(function(){
		$('.IM_tabs .tab').removeClass('actived');
		$(this).parent().parent().addClass('actived');
		$('.product-view .product-collateral .box-collateral').css({"display":"none"});
		$('.product-view .product-collateral .box-meill').css({"display":"block"});
	});
	
	
	
	//下拉菜单
	$("#select-language").selectbox();
	
	$(".toolbar-select").selectbox();

	$(".super-attribute-select").selectbox();

	$("#IM_currency-select").selectbox();
	
	
	//top-nav缩放
	if($('.IM_topnav-con').height>0){
		$('.IM_topnav-con').attr('alt','show');
	}else{
		$('.IM_topnav-con').attr('alt','hide');
	};
    $('.IM_topnav-con').ready(function(){		
		if($('.IM_topnav-con').attr('alt')=='hide'){
			$(".IM_topnav-con").animate({top:'65px'},2000);
			$(".IM_topnav-con").parent().animate({height:'91px'},2000);
			$('.IM_topnav-con').attr('alt','show');
		}
    });
	$(".IM_topnav-content-bottom-aword").click(function () {		
		if($('.IM_topnav-con').attr('alt')=='show'){
			$(".IM_topnav-con").animate({top:'-34px'},800);
			$(".IM_topnav-con").parent().animate({height:'0px'},800);
			$('.IM_topnav-con').attr('alt','hide');
			$(".cms-b2c-homepage .IM_topnav-content-bottom-aword").css("background","url('http://prod.venumfight.com/skin/frontend/imboutique/venumb2c/images/french/header/aword.png')")
		}else{
			$(".IM_topnav-con").animate({top:'65px'},800);
			$(".IM_topnav-con").parent().animate({height:'91px'},800);
			$('.IM_topnav-con').attr('alt','show');
			$(".cms-b2c-homepage .IM_topnav-content-bottom-aword").css("background","url('http://prod.venumfight.com/skin/frontend/imboutique/venumb2c/images/french/header/aword2.png')")
		}
    });
	
	if(!$(".block-viewed").length>0){
		$(".block-twitter").css('margin-top','0');
	}
	
	if(!$(".catalog-category-view .IM_meilleures-list").length>0){
		$(".catalog-category-view .category-products").css('margin-top','-20px');
	}

	
	$("#right-newsletter-validate-detail .block-content #newsletter").focus(function(){
		if ($(this).attr("value") == "Votre adresse e-mail") {
			$(this).attr({"value" : ""});
		}
	}).blur(function(){
		if ($(this).attr("value") == "") {
			$(this).attr({"value" : "Votre adresse e-mail"});
		}
	});
	
	
	$('.IM_bg-change .js_item').each(function(){
		$(this).css({'background':$(this).attr("title")+' url('+$(this).children('img').attr('src')+') no-repeat scroll 50% 0','width':'100%','height':'100%'});
		$(this).children('img').remove();
	})
	
	$('.IM_bg-change').cycle({
		fx: 'fade',
		speed: 'fast',
		timeout: 6000,
		pager: '#control_panel',
		next: '#next2',     
		prev: '#prev2'
	}); 
	
	
	
	
	
	$('.IM_add-number').click(function(){
		var ori = parseInt($('input.qty').val());
		$('input.qty').val(ori+1);
	});

	$('.IM_minus-number').click(function(){
		var ori = parseInt($('input.qty').val());
		if(ori > 0){
			$('input.qty').val(ori-1);
		};
	}); 
	
	
	
	
	
	
	if($('.IM_actus-buttom').length>0){
		$('.IM_actus-buttom').attr('alt','hide');
		$('.IM_actus-buttom').css('display','block');
	}else{
		$('.IM_actus-buttom').attr('alt','show');
		$('.IM_actus-buttom').css('display','none');
	};
	$(".IM_actus-top .IM_cate-name").click(function () {		
		if($('.IM_actus-buttom').attr('alt')=='show'){
			$(".IM_actus").animate({top:'89px'},900);
			$('.IM_actus-buttom').attr('alt','hide');
		}else{
			$(".IM_actus").animate({top:'0px'},830);
			$('.IM_actus-buttom').attr('alt','show');
		}
    });
	

	
	
	if($('.IM_promotions-buttom').length>0){
		$('.IM_promotions-buttom').attr('alt','hide');
		$('.IM_promotions-buttom').css('display','block');
	}else{
		$('.IM_promotions-buttom').attr('alt','show');
		$('.IM_promotions-buttom').css('display','none');
	};
	$(".IM_promotions-top .IM_cate-name").click(function () {		
		if($('.IM_promotions-buttom').attr('alt')=='show'){
			$(".IM_promotions").animate({top:'89px'},900);
			$('.IM_promotions-buttom').attr('alt','hide');
		}else{
			$(".IM_promotions").animate({top:'0px'},830);
			$('.IM_promotions-buttom').attr('alt','show');
		}
    });

	
	
	if($('.IM_nouveautes-buttom').length>0){
		$('.IM_nouveautes-buttom').attr('alt','hide');
		$('.IM_nouveautes-buttom').css('display','block');
	}else{
		$('.IM_nouveautes-buttom').attr('alt','show');
		$('.IM_nouveautes-buttom').css('display','none');
	};
	$(".IM_nouveautes-top .IM_cate-name").click(function () {		
		if($('.IM_nouveautes-buttom').attr('alt')=='show'){
			$(".IM_nouveautes").animate({top:'89px'},900);
			$('.IM_nouveautes-buttom').attr('alt','hide');
		}else{
			$(".IM_nouveautes").animate({top:'0px'},830);
			$('.IM_nouveautes-buttom').attr('alt','show');
		}
    });


	if($('.category-fighters').length>0){
		$('.IM_top-navgation .IM_topnav-title .IM_title-name').removeClass('actived');
		$('.IM_top-navgation .IM_topnav-title .IM_comb').addClass('actived');
	}else if($('.category-news').length>0){
		$('.IM_top-navgation .IM_topnav-title .IM_title-name').removeClass('actived');
		$('.IM_top-navgation .IM_topnav-title .IM_actu').addClass('actived');
	}else if($('.cms-revendeur-html').length>0){
		$('.IM_top-navgation .IM_topnav-title .IM_title-name').removeClass('actived');
		$('.IM_top-navgation .IM_topnav-title .IM_reve').addClass('actived');
	}else if($('.contacts-index-index').length>0){
		$('.IM_top-navgation .IM_topnav-title .IM_title-name').removeClass('actived');
		$('.IM_top-navgation .IM_topnav-title .IM_cont').addClass('actived');
	}else if($('.checkout-cart-index').length>0){
		$('.IM_top-navgation .IM_topnav-title .IM_title-name').removeClass('actived');
		$('.IM_top-navgation .IM_topnav-title .IM_pan').addClass('actived');
	}else{
		$('.IM_top-navgation .IM_topnav-title .IM_title-name').removeClass('actived');
		$('.IM_top-navgation .IM_topnav-title .IM_cata').addClass('actived');
	};
	
	$('#search').focusout(function(){
		if($(this).val()!='Rechercher'){
			$(this).css('font-style','normal');
		}else{
			$(this).css('font-style','italic');
		}
	})
	
	
	if($('.catalogsearch-advanced-result .category-products').length>0){
		$('.IM_advanced-product-list-bottom').css('display','none');
		$('.IM_advanced-product-list-content').css('margin-bottom','-10px');
	};
	
	$('.wco-lang-list').hover(function(){$(this).children('.wco-lang-content').show()},function(){$(this).children('.wco-lang-content').hide()});
	
	$('.IM_product_button_addtocart').children('.button').click(function(){
		if($('#attribute978').val() != ''){
			productAddToCartForm.submit();
		}else{
			alert('Please specify a size.');
		}
	});
	
	$('.sizeguide a').fancybox({
		'padding' : 0,
		onComplete : function() {
			$('#fancybox-content .sizeguidecontent').css('display','block');
		},
		onClosed : function() {
			$('.sizeguidecontent').css('display','none');
		}
	}); 
	
	//Added 13/02/12 ->
	$('.actus_bottom').cycle({
		fx: 'fade',
		speed: 'fast',
		timeout: 6000,
		next: '#actus_prev',
		prev: '#actus_next'
	});
	//<- Added 13/02/12
});


