jQuery.noConflict();

jQuery(document).ready(function() {

  jQuery('#site').change(function() {
    window.location = this.value;
  });


  jQuery('#search a:first').click(function(evt) {
    evt.preventDefault();
    var $a = jQuery(this);
    var $input = $a.prev();

    if ($input.val()) {
      window.location = $a.attr('href') + '/' + $input.val();
    }
  });


  jQuery('#search input[type=text]').keyup(function(evt) {
    if (evt.keyCode == 13) {
      jQuery(this).next().click();
    }
  });


  jQuery('#nb_result #item_count').change(function() {
    var form = jQuery('<form method="post" action="' + window.location.href + '"><input name="item_count" value="' + jQuery(this).val() + '" type="hidden" /></form>');
    form.hide().appendTo('body');
    form.submit();
  });


  jQuery('#crea_content_connexion form').live('submit', function(evt) {
    evt.preventDefault();

    var $this = jQuery(this);

    jQuery('#crea_devis_connexion').load($this.attr('action'), $this.serializeObject());
  });


  jQuery('#password_forget form').live('submit', function(evt) {
    evt.preventDefault();

    var $this = jQuery(this);

    jQuery('#password_forget').load($this.attr('action'), $this.serializeObject());
  });


});




jQuery(document).ready(function() {

  var id_list;
  var id_item;

  jQuery('#nav_catalog .menu_item').mouseover( function(event) {

    id_item = jQuery(this).attr("id");
    jQuery('#'+id_item).attr("id", id_item+"_hover");

    id_list = id_item.replace('item', 'list');
    jQuery('#'+id_list).show();

  });

  jQuery('#nav_catalog .menu_item').mouseout( function(event) {
    var new_item = id_item.replace('_hover', '');
    //alert(new_item +" "+ id_item);
    jQuery('#'+id_item+"_hover").attr("id",new_item);
    jQuery('#'+id_list).hide();

  });

  jQuery('#roll_nav .menu_list').mouseover( function(event) {

    jQuery('#'+id_item).attr("id", id_item+"_hover");
    jQuery('#'+id_list).show();

  });
  jQuery('#roll_nav .menu_list').mouseout( function(event) {
    var new_item = id_item.replace('_hover', '');
    jQuery('#'+id_item+"_hover").attr("id", new_item);
    jQuery('#'+id_list).hide();
  });

});

jQuery(document).ready(function() {

  jQuery('.question').click( function(event) {

    var id_question = jQuery(this).attr("id");
    var nb_question = jQuery('#nb_faq').val();
	
    var id_answer = id_question.replace('question', 'answer');
	
	if(jQuery('.'+id_answer).css('display') != 'none'){
		
    	jQuery('.'+id_answer).slideUp('slow');
		
	}
	else {
	
		for (i=1; i<=nb_question; i++){
			jQuery('.answer_'+i).slideUp('slow');
		}
	   setTimeout(function(){ jQuery('.'+id_answer).slideDown('slow');},500);
	}

  });

});

jQuery(document).ready(function() {

	jQuery('.close').mouseover( function(event) {
  
  		jQuery('.close span').css('background', '#FF6600');
  
  	});
	jQuery('.close').mouseout( function(event) {
  
  		jQuery('.close span').css('background', '#C1CBCE');
  
  	});

  jQuery('.close').click( function(event) {

    var id_answer = jQuery(this).attr("id");
    var id_question = id_answer.replace('close', 'answer');
    jQuery('.'+id_question).slideUp('slow');

  });

});

jQuery(document).ready(function() {
								
	// Roll over barre actu déroulante			
		jQuery('.open_close').mouseover( function(event) {
	  
		  	var id_actu = jQuery(this).attr("id");
	  		id_actu = id_actu.split('_')[1];
	  
			jQuery('#open_'+id_actu +' span').css('background', '#FF6600');
			jQuery('#close_'+id_actu +' span').css('background', '#FF6600');
	  
		});
		jQuery('.open_close').mouseout( function(event) {
			var id_actu = jQuery(this).attr("id");
	  		id_actu = id_actu.split('_')[1];
	  
			jQuery('#open_'+ id_actu +' span').css('background', '#C1CBCE');
			jQuery('#close_'+ id_actu +' span').css('background', '#C1CBCE');
	  
		});
		
var nb_actu = jQuery('#nb_actu').val();		

  for(var i=1; i<=nb_actu; i++){
	  
	if(jQuery('#container_actu_'+i+' #img_actu_'+i).height() != null){
		
		//jQuery('#container_actu_'+i).height(jQuery('#img_actu_'+i).height()+30);
		
	jQuery('#container_actu_'+i).height(215);
	
	 if (jQuery('#actu_'+i).height()<180){
        jQuery('#open_'+i+' span').hide();
      }
		
	}
	else{
	jQuery('#chapo_actu_'+i).width(600);
	jQuery('#actu_'+i+' p').width(600);
	jQuery('#container_actu_'+i).height(145);
	//alert(jQuery('#container_actu_'+i).height());
	
	 if (jQuery('#actu_'+i).height()<130){
        jQuery('#open_'+i+' span').hide();
      }
	  
	}
	  
    //jQuery('#container_actu_'+i).height(jQuery('#img_actu_'+i).height()+30);

   
  }

  jQuery('.open_close').click( function(event) {

    var id_question = jQuery(this).attr("id");
	var id_actu = id_question.split('_')[1];
	
	var h_img = 215;
	var h = 145;
	var h_base = 0; 
	 
	if(jQuery('#container_actu_'+id_actu+' #img_actu_'+id_actu).height() != null){
		h_base = 200;
	}
	else{
		h_base = 130;
	}
	 
	 //alert(jQuery('#actu_'+id_actu).height());
	 
    if(id_question.indexOf("open")==0 && jQuery('#actu_'+id_actu).height()>h_base){
			
	for(var i=1; i<=nb_actu; i++){ 
	var id_all_close = 'close_'+i;
	 	if(jQuery('#container_actu_'+i+' #img_actu_'+i).height() != null){
			jQuery("#container_actu_"+i).animate({height: h_img+"px"}, 1000 );
		}
		else{
     		jQuery("#container_actu_"+i).animate({height: h+"px"}, 1000 );
		}
		
		
      	var id_close = id_all_close.replace('close', 'open');
      	jQuery("#"+id_all_close).attr("id", id_close);		
	}
		
		
      var id_answer = id_question.replace('open', 'actu');
      var h = jQuery('#'+id_answer).height() +jQuery('#chapo_'+id_answer).height()+20;

     setTimeout( function() { jQuery('#container_'+id_answer).animate({height: h+"px"}, 1000 );}, 500);

      var id_close = id_question.replace('open', 'close');
      jQuery(this).attr("id", id_close);

    }
    else if(id_question.indexOf("close")==0){
		

     var id_answer = id_question.replace('close', 'actu');

	  
	if(jQuery('#container_actu_'+id_actu+' #img_actu_'+id_actu).height() != null){
		
		jQuery("#container_"+id_answer).animate({height: h_img+"px"}, 1000 );
	}
	else{
     	jQuery("#container_"+id_answer).animate({height: h+"px"}, 1000 );
	}

      var id_close = id_question.replace('close', 'open');
      jQuery(this).attr("id", id_close);

    }

  });

});

jQuery(document).ready(function() {

  if (jQuery('#list_ref_site').length) {
    jQuery('#list_ref_site').carousel({
      dispItems: 3,
      direction: 'vertical',
      nextBtn: '<span id="nav_site_bottom"></span>',
      prevBtn: '<span id="nav_site_top"></span>',
      btnsPosition: 'outside'
    });
  }

});



