$(document).ready(function(){ 

	jQuery.preLoadImages(add_surl + "/images/default/dd-bg.png");
	
	// Drop Down Navigation	
	$('.dd').hide();
	$('#navigation ul li').hover(function(){ 
		$(this).find('.dd:eq(0)').show();
		$(this).find('.dd:eq(0)').prev().addClass('hover');
	 },
	 function(){  
		$(this).find('.dd').hide();
		$(this).find('.dd:eq(0)').prev().removeClass('hover');
 	});
	
	// Fade Slider	
	var fader;
		
	$('.fader .item').simpleFade({
		init : function () {
			fader = this;			
		},
		onFade : function (index) {
			$('.fader-nav ul li a').removeClass('active').eq(index).addClass('active');
		}
	});
	
    $('.fader-nav a').click(function () {
        fader.fadeTo($('.fader-nav ul li a').index(this));
        return false;
    });


	// Input Fields
    $('.blink').
    focus(function() {
        if(this.title==this.value) {
            this.value = '';
        }
    }).
    blur(function(){
        if(this.value=='') {
            this.value = this.title;
        }
    });
    
	// Inputs transformation
    //$('.select form').jqTransform();	
    //$('.single-product .product-description .top .sum form').jqTransform();
	//$('form.profile-form, form.diagnostic1, form.nous-form').jqTransform();
	$('.select form').jqTransform();	
	$('.single-product .product-description .top .sum form').jqTransform();
	$('.location').jqTransform();
	$('.contact_objet').jqTransform();
	$('.date_naiss').jqTransform();
	$('.dates').jqTransform();
    
    
    
    // Scroll transformation
	$('.static-entry').jScrollPane({
		verticalDragMinHeight		: 29,
		verticalDragMaxHeight		: 29
	});
	
	$('.savoir .page-holder').jScrollPane({
		verticalDragMinHeight		: 29,
		verticalDragMaxHeight		: 29
	});
	
	
	//Hiding all tabs
	$(".tab").hide();
	$(".tabs a").removeClass("active");
	
	// Showing First Tab
	$(".tabs-content .tab").eq(0).show().addClass("active");
	$(".tabs a").eq(0).addClass("active");
	
	$(".tabs a").click(function(){
		$(".tabs a").removeClass("active");
		$(this).addClass("active");
		
		$(".tabs-content .active").removeClass("active").hide();
		$($(this).attr("href")).addClass("active").fadeIn();
		
	});

	 

	 	
 	//PNG FIX for IE6
	if($.browser.msie && $.browser.version.substr(0,1) == 6 ){
		DD_belatedPNG.fix('#navigation .dd-bg, #header p img, #header .dd li, .press .jcarousel-next, .order-page .order-steps ul li.past a')
	}
	

	// Checked box
	
	var flag = false; 
	$("p.valider input").click(function () {
		var container = $(this).parents('form');
		$('input[type="checkbox"]', container).each(function(){ 
			if ( $(this).hasClass('required') && $(this).attr('checked') !== true) {
				flag = true;
			}else{
					
			}
			
			if (flag) {
				$('p.valider input', container).hide();	
				$('.answer', container).fadeIn();	
			}
		 })
		 return false;
	});
	
	$('.philosophie .boxes .box').hover(function  () {
	    $(this).find('.box-info').fadeIn();
	},function  () {
	    $(this).find('.box-info').hide();
	});
	
	
	function mycarousel_initCallback(carousel) {
        $('.slider-navigation a').bind('click', function() {
            carousel.scroll($.jcarousel.intval($(this).text()));
            return false;
        });            
	};
	    
	function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	    $('.slider-navigation a').removeClass('active');
	    $('.slider-navigation a').eq(idx-1).addClass('active');
	};
	
    $(".press .slider-carousel2 ul").jcarousel({
        scroll:1,
        //auto:1,
        wrap:"both",
        start: 1
    });

	// Brevets
	
	$('.brevet-item').click(function() {
	    $('.brevet-info').fadeOut();
		$('.item1').animate({
            width : '76px'
        });
		$('.item2').animate({
            width : '76px'
        });
		$('.item3').animate({
            width : '76px'
        });
		$('.item4').animate({
            width : '76px'
        });
		$('.item5').animate({
            width : '76px'
        });
		$('.item6').animate({
            width : '76px'
        });
		$('.item7').animate({
            width : '76px'
        });
	    $(this).find('.brevet-info').stop(true,true).fadeIn();
	    $(this).stop(true,true).animate({
             width: '248px'
        });
       $(this).siblings().addClass('subling').animate({
            width : '76px'
        });
	});
	
	
   $('table.wishlist tr:even').css('backgroundColor', '#fff');
    
  
    $('.answer:eq(0);').show().addClass('active');
   
   $('.question').click(function  () {
       $('.answer').slideUp();
       $('.question').removeClass('active');
       $(this).find('.answer').slideDown();
       $(this).addClass('active');
   });
   
   
   $(".quantite a").click(function(){
		var inc = $(this).hasClass("minus") ? -1 : 1;
		$input = $(this).parent().find("input");
		var newVal = parseInt($input.val())+inc;
		newVal = newVal<0 ? 0 : newVal;
		$input.val(newVal);
		$input.change();
		return false;
	});
	/*
	$('.profile-form h3 input').click(function() {
       if($('input.no').is(':checked')) 
        { 
            $('.profile-form input, .profile-form select, .profile-form textarea ').removeAttr('disabled');
            $('.profile-form .field-row').addClass('dark');
        }
        else {
             $('.profile-form .field-row input, .profile-form  .field-row select, .profile-form  .field-row textarea ').attr('disabled','true'); 
             $('.profile-form .field-row').removeClass('dark');
         }
    });
   */
    $('form.diagnostic2-form p').hover(function  () {
        $(this).css('backgroundColor', '#bdd4d6');
        $(this).find('span.info').show();
    }, function  () {
         $(this).css('backgroundColor', '#fff');
          $(this).find('span.info').hide();
    });
    

    var flag = true;
    $('form.diagnostic2-form p.rad').click(function  () {
        if (flag) {
            $(this).find('input').attr('checked', 'checked');
            flag = false;
        }else{
            $(this).find('input').attr('checked', 'unchecked');
            flag = true;
        }
    });
	
	// Vertical Accordion
    $('.list-info li .holder').first().show();
    $('.list-info li').first().addClass('active');
    $('.list-info li').bind('click', function  () {
         if ($(this).find('.holder').is(":visible")) {   
         } else {
             $('.holder').slideUp();
             $(this).find('.holder').slideToggle();
             $('.list-info li').removeClass('active');
             $(this).toggleClass('active');
         };
    });

});


(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
