jQuery(document).ready(function(){

	jQuery('.onglet ul li').click(function(e,keepScroll){
			if(!keepScroll) jQuery('.onglet ul li.actif img').hide();
			if(keepScroll) jQuery('.onglet ul li.actif img').fadeOut();
			jQuery('.onglet ul li.actif').removeClass('actif');
			jQuery(this).find('img').fadeIn();
			jQuery(this).addClass('actif');
			
			// Stopping the auto-advance if an icon has been clicked:
			if(!keepScroll) clearInterval(itvl);
	});
	
	/* auto-advance */
	var current=1;
	function autoAdvance()
	{
		if(current==-1) return false;
		jQuery('.onglet ul li a').eq(current%jQuery('.onglet ul li a').length).trigger('click',[true]);
		current++;
	}

	var itvl = setInterval(function(){autoAdvance()},4000);
  
  

	jQuery('.boiteonglets>ul>li').click(function(e){
      var pos = jQuery(this).prevAll('li').length + 1;
      var div = jQuery(this).parent().parent();
			div.find('div>div').hide();
			div.find('ul>li.active').removeClass('active');
			div.find('div>div:nth-child('+pos+')').fadeIn();
			jQuery(this).addClass('active');
			
	});
  
	jQuery('.showmore input').change(function(e){
    if (jQuery(this).attr('checked') == 'checked') {
			jQuery(this).parent().parent().find('.showmore_zone').css('display','block');
    } else {
			jQuery(this).parent().parent().find('.showmore_zone').css('display','none');
    }
	});
  
  jQuery('.showmore').trigger('change');

  
  var adv_search_show = false;
  jQuery('#recherche-avance').click(function(e){
    if (adv_search_show) {
      jQuery(this).text('Recherche avancée');
      jQuery(this).css('top','-21px');
      jQuery('#champ').slideDown();
      jQuery('#champ2').slideUp();
      adv_search_show = false;
    } else {
      jQuery(this).text('Recherche simple');
      jQuery(this).css('top','-20px');
      jQuery('#champ').slideUp();
      jQuery('#champ2').slideDown();
      adv_search_show = true;
    }
	});
  
  jQuery('.search_result .showmore').click(function(e){
    if(jQuery(this).parent().parent().next().css('display') == 'table-row') {
      jQuery(this).parent().parent().next().hide();
    } else {
      jQuery('.contact_list').hide();
      jQuery(this).parent().parent().next().show();
    }
  });
  
  jQuery('.contact_list .groupitem').change(function(e){
    jQuery(this).parent().parent().parent().parent().find('input.groupall').removeAttr('checked') ;
  });  
  jQuery('.search_result .groupall').change(function(e){
    if(jQuery(this).attr('checked') == 'checked') {
      jQuery(this).parent().parent().parent().parent().find('input.groupitem').attr('checked','checked') ;
    } else {
      jQuery(this).parent().parent().parent().parent().find('input.groupitem').removeAttr('checked') ;
    }
  });  

  jQuery('.search_filter .filter_title').click(function(e){
    jQuery(this).parent().find('form').slideToggle();
  });
  
  jQuery('.action_modify_contact').click(function(e){
    jQuery('#popup_contact').parent().show();
  });

  jQuery('.action_add_contact').click(function(e){
    jQuery('#popup_contact').parent().show();
  });

  jQuery('.action_delete_contact').click(function(e){
    jQuery('#popup_contact').parent().show();
  });

  jQuery('.popup .close').click(function(e){
    jQuery(this).parent().parent().hide();
  });
  
  jQuery('.popup_background').click(function(e){
    jQuery(this).parent().hide();
  });
  
  jQuery('.action_acheter').click(function(e){
    //jQuery('#popup_credits').parent().show();
	openSelectionnerCredits();
  });
  
  jQuery('.action_save').click(function(e){
    jQuery('#popup_exemple').parent().show();
  });
  
  jQuery('.action_deselect_contact').click(function(e){ 
	//alert("toto");
    jQuery(this).parent().parent().remove();
	if (jQuery('#nb_caddie').html()=="1") {
		jQuery("#ListeLigneVide").show();
	}
  });


  jQuery('.all').click(function(e){
    e.preventDefault();
    jQuery(this).find('ul').slideToggle('fast'); return true;
  }).mouseleave(function(e) {
		jQuery(this).find('ul').slideUp('fast');
	});
  
/*  jQuery('.exportAll').click(function(e){
    var fullurl = getUrl();
	window.open( fullurl + );
  });

  jQuery('.exportSelect').click(function(e){
	var fullurl = getUrl();
	//window.open('http://www.google.be');
  });*/
  
  jQuery('#tab li').click(function(e){
	var fullurl = getUrl();
    var pos = jQuery(this).prevAll('li').length + 1; //alert (fullurl+"public/images/1ternet/fil.jpg");
	jQuery(this).parent().find('li').css( 'background', 'url("public/images/1ternet/fil.jpg") no-repeat top left');
    jQuery(this).parent().find('li').removeClass('active');
    var div = jQuery('#block_account');
    jQuery('#block_account>div').hide();
    //jQuery('#block_account>div:nth-of-type('+pos+')').show(); //ne fonctionne pas sous IE8-
	if (pos == 1) jQuery("#tab1").show();
	if (pos == 2) jQuery("#tab2").show();
	if (pos == 3) jQuery("#tab3").show();
    jQuery(this).addClass('active');
	//jQuery(this).css( 'background', 'none');
	jQuery(this).css( 'background', 'url("public/images/1ternet/fil2.jpg") no-repeat top center');
  });
  
  jQuery('#liste-contact a').click(function(e){
		jQuery(this).parent().fadeOut();
  });
  
jQuery("#pageflip").hover(function() { //On hover...
	jQuery("#pageflip img , .msg_block").stop()
		.animate({ //Animate and expand the image and the msg_block (Width + height)
			width: '220px',
			height: '220px'
		}, 500);
	} , function() {
	jQuery("#pageflip img").stop() //On hover out, go back to original size 50x52
		.animate({
			width: '63px',
			height: '63px'
		}, 220);
	jQuery(".msg_block").stop() //On hover out, go back to original size 50x50
		.animate({
			width: '60px',
			height: '60px'
		}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
});

  
	jQuery(".compte").lettering();
	//jQuery(".compteSel").lettering();

	//jQuery(".ttips").tinyTips('title');

  
});

function AfficherEmailEnvoye() { 
    //jQuery('#popup_envoi_mail').parent().show();
};
  


