$(document).ready(function() {
/*
 if ($("#slid_9782072025327")) $("#slid_9782072025327").attr({ src:"http://www.epagine.fr/images/9782072025327.png" });
 if ($("#slid_9782715230248")) $("#slid_9782715230248").attr({ src:"http://www.epagine.fr/images/9782715230248.png" });
 if ($("#slid_9782072309373")) $("#slid_9782072309373").attr({ src:"http://www.epagine.fr/images/9782072309373.png" });
 
$("#sliderIndex").easySlider({
	auto: true,
	controlsShow: true,
	continuous: false,
	numeric: true,
	numericId: 'controls',
	speed: 500,
	pause: 10000
});	
*/
$("#ContactForm").validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			message: "required"
		},
		messages: {
			email: {
				required: "Veuillez entrer un courriel valide.",
				email: "Veuillez entrer un courriel valide."
			},
			message: "Veuillez saisir votre message pour nous contacter."
		}
});

$("#popupepagineForm").validate({
		rules: {
			nom: "required",
			prenom: "required",
			ville: "required",
			email: {
				required: true,
				email: true
			},
			telphone: {
				required: true,
				maxlength: 10
			},
			age: {
				required: true,
				number: true,
				maxlength: 2
			}
		},
		messages: {
			prenom: "Entrez votre pr&eacute;nom",
			nom: "Entrez votre nom",
			ville: "Entrez votre ville",
			email: {
				required: "Veuillez entrer un courriel valide",
				email: "Veuillez entrer un courriel valide"
			},
			telphone: {
				required: "Veuillez rentrer un num&eacute;ro de t&eacute;l&eacute;phone valide",
				maxlength: "Veuillez rentrer un num&eacute;ro de t&eacute;l&eacute;phone valide"
			},
			age: {
				required: "Veuillez rentrez votre &acirc;ge",
				maxlength: "Veuillez rentrer votre &acirc;ge"
			}
		}
});

}); //fin document ready

function AffiFenetre(urlv,divid) {
  $("div.taillesite").addClass("opac");
  $("div.dessus").addClass("opac");
  $("div.buy1clic").addClass("opac");
  $("div.lstacht").addClass("opac");  
  $("div#conteneur").addClass("opac");
  $("img.visulivre").addClass("opac");
  $("table.taillesite").addClass("opac");
  $("#"+divid).html($.ajax({
    url: urlv,
    async: false
  }).responseText).draggable().show("slow");
  $("#"+divid+" #Fermer").click(
    function() {
      $("#"+divid).hide("slow").html("&nbsp;");
      $("div.taillesite").removeClass("opac");
      $("div.dessus").removeClass("opac");
      $("div.buy1clic").removeClass("opac");
      $("div.lstacht").removeClass("opac");	  
      $("div#conteneur").removeClass("opac");
      $("img.visulivre").removeClass("opac");  
	  $("table.taillesite").removeClass("opac");	  
    }
  );
}

function PosiFenetre(divid) {
  var hauteur=$(window).scrollTop()+($(window).height()/4);
  var largeur=($(window).width()/2)-($("#"+divid+" div").width()/2);
  $("#"+divid).css({ 'top':hauteur,'left':largeur });
}

function AffiDomaine(CSR) {
  var kids=$("#menucsr").children();
  for(i=0;i<$(kids).length;i++) {
    if ($(kids[i]).attr("id")!="") {
      $(kids[i]).show();
      if ("d"+CSR==$(kids[i]).attr("id")) break;
      kids2=$(kids[i]).children();
      for(j=0;j<$(kids2).length;j++) {
        if ($(kids2[j]).attr("id")!="") $(kids2[j]).show();
      }
    }
  }
}

function ChangeDLRD(argument) {
  if ($("#DL").attr("src")=='/images/pictodlon.jpg') {
	  $("#DL").attr({ src:'/images/pictodloff.jpg' });
	  $("#RD").attr({ src:'/images/pictofeuilleteron.jpg' });
    $("#conttext").html('<a href="'+argument+'" target="_blank" style="color:#FFEC00;font-size:10px;">FEUILLETER UN EXTRAIT</a>');
  } else {
    $("#DL").attr({ src:'/images/pictodlon.jpg' });
    $("#RD").attr({ src:'/images/pictofeuilleteroff.jpg' });
    $("#conttext").html('<a href="javascript:AffiFenetre(\'/telextrait.php?idl='+argument+'\',\'Affiche\');PosiFenetre(\'Affiche\');" style="color:#FFEC00;font-size:10px;">T&Eacute;L&Eacute;CHARGER UN EXTRAIT</a>');
  }
}

function clicktoplay(EAN) {
  $("#conttext").html('<object type="application/x-shockwave-flash" data="dewplayer-mini.swf?mp3=http://images.epagine.fr/'+EAN.substring(10,13)+'/'+EAN+'_s_1001.mp3&autostart=true" width="155" height="20"><param name="wmode" value="transparent" /><param name="movie" value="dewplayer-mini.swf?mp3=http://images.epagine.fr/'+EAN.substring(10,13)+'/'+EAN+'_s_1001.mp3&autostart=true" /></object>');
}

function SrcText() {
  $("#fen_stc").toggle("slow");
}

function ChSupport(support) {
  if ($("#Supports")) $("#Supports").html($("#support"+support).html());
}

function ScrollDetail() {
  $(function(){
    var maxScroll = $("#scroller").attr("scrollHeight") - $("#scroller").height();
    if (maxScroll<=0) {
      $("#slider").hide();
    } else {
      $("#slider").slider({
        orientation: 'vertical',
        range:'max',
    		animate: true,
        value: 100,
        handle: '.slider',
        change: handleSliderChange,
    		slide: handleSliderSlide
      });
    }
  });
  function handleSliderChange(e, ui) {
    var maxScroll = $("#scroller").attr("scrollHeight") - $("#scroller").height();
    $("#scroller").animate({scrollTop: (maxScroll-(ui.value * (maxScroll/100))) }, 1000);
  }
  function handleSliderSlide(e, ui) {
    var maxScroll = $("#scroller").attr("scrollHeight") - $("#scroller").height();
    $("#scroller").attr({scrollTop: (maxScroll-(ui.value * (maxScroll/100))) });
  }
}

function DevLib() {
  if ($("#ListeLibs").html()=="") $("#ListeLibs").html($("#Libs").html());
  else $("#ListeLibs").html("");
}

function AffiCentre(p) {
  $("#centre").html($("#c"+p).html());
}

function epapop() {
if ($('#iemail').val()!="") {
	$.post("upepapop.php",{
		nom: $('#inom').val(),
		prenom: $('#iprenom').val(),
		age: $('#iage').val(),
		ville: $('#iville').val(),
		telphone: $('#itelphone').val(),
		email: $('#iemail').val(),
		sectactivite: $('#isectactivite').val()
		},
		function(data){
		if (data=="ko") {
			$("div.msg_ko").slideDown('fast');
			$("div.msg_ok").hide();
		} else { 
			$("div.msg_ok").slideDown('fast');
			$("div.msg_ko").hide();
			$("div.container").addClass('opac');
		}
		}
	);
	$.post("upclient.php",{email: $('#iemail').val()});	
}
return false;
}