(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = window.innerHeight;//$(this).parent().height();
	if (document.documentElement){
		ph=document.documentElement.clientHeight;
	}
	//alert(ph+"=>"+ah);
	var mh = (ph - ah) / 2;
	if ( ph > 730 )
	  $(this).css('margin-top', mh);
	});
};
})(jQuery);

$(document).ready(function(){
	$('.main-content').vAlign();
	$(".menu .level1").hover(function(){
	    $(this).css("zIndex", 10000);
	    $(this).children("ul").slideDown();
	  },function(){
	    $(this).children("ul").hide();//slideToggle("fast");
	});
	$(".block-images .block").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	$(".elt-foundation").hover(function(){
		$(this).children(".infos").show();
		$(this).children(".mask").show();
	},function(){
		$(this).children(".infos").hide();
		$(this).children(".mask").hide();
	});
	$('.produit .colRight .desc').each(function(){
		$(this).jScrollPane({scrollbarWidth:1,showArrows:true});
	});
	$('.shoppingcart .content-scroll').each(function(){
	    $(this).jScrollPane({scrollbarWidth:1,showArrows:true});
	    $('.jScrollPaneTrack').css("top","0px");
	});
	$('.shoppingcart .content').each(function(){
	    $(this).jScrollPane({scrollbarWidth:1,showArrows:true});
	});
	$('.shoppingcart .content-shipping').each(function(){
		$(this).jScrollPane({scrollbarWidth:1,showArrows:true});
		$(this).next('.jScrollPaneTrack').css("top","0px");
	});
	$('.shoppingcart .contentpayement').each(function(){
		$(this).jScrollPane({scrollbarWidth:1,showArrows:true});
	});

	$(".productused h3").click(function(){
		if(!$(this).hasClass("actif")){
			$(".productused .actif").children().not("h3").slideUp();
			$(".productused").children().removeClass("actif");
			$(this).parent().addClass("actif");
			$(this).parent().children().not("h3").slideDown();
		}
	});

	$(".scroll").not(".foundation_txt .texte").jScrollPane({scrollbarWidth:1,showArrows:true});

	$(".oxy_txt .jScrollPaneTrack").css("top","0px");

	$('.shoppingcart .content-shipping').each(function(){
		$(this).next('.jScrollPaneTrack').css("top","0px");
	});


	$('.content .colLeft .texte').each(function(){
		$(this).jScrollPane({scrollbarWidth:1,showArrows:true});
	});

	if ( $('.button_desc') ) {
	  initProductButtons();
	}


	$('#dtsopen').click(function() {
	    //$('.payment-method').jScrollPane({scrollbarWidth:1,showArrows:true});
	    $('#dtstoggle').css('visibility', 'hidden');
	    $('#DataTrans').css('display', 'none');
	    $('.next-pev-payment').css('margin-top', '30px');
	    $('#dtstoggle').show(function() { 
		//$('.payment-method').jScrollPane({scrollbarWidth:1,showArrows:true});
		$('#dtstoggle').css('visibility', 'visible');
	    });
	    return false;
	  });

});

function displayMore(){
	$(".traitement .elt").hide();
	$(".traitement .more").fadeIn(250);
	if($(".jScrollPaneTrack").children().size()==0){
		$(".content-more").jScrollPane({scrollbarWidth:1,showArrows:true});
	}
}

function displayFoundation(){
	$(".foundation_txt").fadeIn(250);
	if($(".foundation_txt .jScrollPaneTrack").children().size()==0){
	  $(".foundation_txt .scroll").jScrollPane({scrollbarWidth:1,showArrows:true});
	  $(".foundation_txt .jScrollPaneTrack").css("top","0px");
	}
}
function closeFoundation(){
	$(".foundation_txt").fadeOut(250);
}
function closeMore(){
	$(".traitement .more").fadeOut(250);
	$(".traitement .elt").show();
}
function displayProduct(){
	$(".productused").fadeIn(250);
	$(".colRight .content-slide img.img-traitement").css("left","-135px").css("position","relative");
	//alert($('.productused').css("right"));
	/*if($('.productused').css("right")=="0px"){
		$('.productused').animate({
	    opacity:1,
	    right: '+=264',
	    height: 'none'
	  	},2000);
	}*/
}
function closeProduct(){
	$(".productused").fadeOut(250);
	$(".colRight .content-slide img.img-traitement").css("left","0px").css("position","static");
	/*$('.productused').animate({
    opacity:1,
    right: '-=264',
    height: 'none'
  	},1000,function(){
  		$('.productused').hide();
  	});*/
}

function initProductButtons() {
  $('.tab2').hide();
}

function showTab1() {
  $('.tab2').hide();      
  $('.tab1').fadeIn();
  $('.button_tab1').css('opacity', '1');
  $('.button_tab2').css('opacity', '0.5');  
}

function showTab2() {
  $('.tab1').hide();      
  $('.tab2').fadeIn(); 
  $('.button_tab1').css('opacity', '0.5');
  $('.button_tab2').css('opacity', '1');
}

function masquer(elt1)
{
var eltAcacher1 = document.getElementById(elt1);
eltAcacher1.style.visibility="hidden";
}

function afficher(elt1)
{
var eltAcacher1 = document.getElementById(elt1);

if (eltAcacher1.style.visibility=="hidden"){
	eltAcacher1.style.visibility="visible";
}else{
	eltAcacher1.style.visibility="hidden";
}
}

function initPrehome() {
  $('.colLeft').css('display', 'none');
  $('.logo').css('display', 'none');
  $('.menu').css('display', 'none');
  $('.footer').css('display', 'none');
}

function hidePrehome()  {
  $('.prehomeImage').css('display', 'none');
  $('.logo').fadeIn();
  $('.menu').fadeIn();
  $('.footer').fadeIn();
  $('.colLeft').fadeIn();
  $('.colRight').fadeIn();
}

function stateHandle(texte) 
	{ 
	if (texte==21) 
		$('#id_state').css('visibility','visible'); 
	else 
		$('#id_state').css('visibility','hidden'); 
	} 


