							 
							 
$.fn.fadeIn = function(speed, callback) { 
    return this.css({opacity: 1, visibility: "visible", display: "block"}).animate({opacity: '1'}, speed, function() { 
        if (jQuery.browser.msie)   this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback))  callback();  
    }); 
}; 
 
$.fn.fadeOut = function(speed, callback) { 
    return this.css({opacity: 1, visibility: "visible"}).animate({opacity: '0'}, speed, function() { 
        if (jQuery.browser.msie)  this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback))  callback();  
    }); 
}; 
 
$.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 

$(function() {

	$('#connect').click(function(){
				$('#conct').fadeIn(800);
				$('#overlay').slideDown(800);
				$('#conct').animate({top:'65px', width:'600px', height:'340px', marginLeft:'-100px'},{queue:false,duration:500});
				return false;
	});
	
	$('#close-connect').live('click',function(){
				$('#conct').animate({top:'-10px', width:'1px', height:'1px', marginLeft:'420px'},{queue:false,duration:500});
				$('#conct').fadeOut(800);
				$('#overlay').slideUp(800);
	});
	
	$('a.scrollink').click(function(){
				$('#scroll').stopTime('scrolling');
				$('.scrollink').removeClass('ok'); $(this).addClass('ok');
				$('#scroll .scrollall').animate({left:'-'+$(this).attr('rel')+'px'},{queue:false,duration:800}); 
				setTimeout(function() { scrolling(); },200); 
				return false;
	});

	$('#viewgalerie li a').lightBox({fixedNavigation:true});
	// $('#maincontent img').lightBox({});

    $(".help").live("mouseover", function() {
    	  var monId=$(this).attr("id");
    		var filename = '/fichiers/help/'+ monId + '.txt';
				$(this).find('span').load(filename);
				$(this).find('span').css({'display':'block'});
		});
    $(".help").live("mouseout", function() { $(this).find('span').css({'display':'none'}); });
			

});



			
/*  */   
			function sendmailmsg(nom,prenom,tel,email,mail,txt,id) { 
				  $('#overlay').slideDown('200');
					$('#loadingMessage').html('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Envoie de votre mail en cours...</b><p>');
					if(mail == '') {
						if (nom == '' || prenom == '' || tel == '' || email == '' || txt == '') {
							printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Veuillez remplir tous les champs du formulaire.</b></p>');
						} else {
							$.ajax({
							   type: "POST",
							   url: "./load.php?action=sendmailmsg",
							   data:({ 'nom' : nom, 'prenom' : prenom, 'email' : email, 'tel' : tel, 'txt' : txt, 'idsendmail' : id }),
							   success: function(msg){ printLoadingMessage(msg); }
							});
						} 
					} else printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Veuillez désactiver le remplissage automatique de votre navigateur,</b> vous êtes considéré comme un spammeur.</p>');
			}
			
			function sendcontactwb(mail,nom,prenom,email,tel,raison,sujet,txt) { 
					if(mail == '') {
						if (nom == '' || prenom == '' || email == '' || tel == '' || raison == '' || sujet == '' || txt == '') {
							printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Veuillez remplir tous les champs du formulaire.</b></p>');
						} else {
							$.ajax({
							   type: "POST",
							   url: "./load.php?action=sendcontactwb",
							   data:({ 'nom' : nom, 'prenom' : prenom, 'email' : email, 'tel' : tel, 'raison' : raison, 'sujet' : sujet, 'txt' : txt }),
							   success: function(msg){ printLoadingMessage(msg); }
							});
						} 
					} else printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Veuillez désactiver le remplissage automatique de votre navigateur,</b> vous êtes considéré comme un spammeur.</p>');
			}


/* MDP / Login ************************************************************************************************************************** */

			function changemdp() { 
					$('#loadingMessage').html('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Connexion en cours...</b><p>');
					if(document.changmdp.mdp1.value != document.changmdp.mdp2.value || document.changmdp.mdp1.value == '' || document.changmdp.mdp2.value == '') {
						printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Vos deux mots de passe ne correspondent pas.</b></p>');
					} else  {
						$.ajax({
						   type: "POST",
						   url: "./load.php?action=changemd",
						   data:({ mdp : document.changmdp.mdp.value, mdpnew : document.changmdp.mdp1.value }),
						   success: function(msg){ printLoadingMessage(msg); $('#overlay').slideDown(500); }
						});
				} 
			}
			
			function sendlogin() { 
				  $('#resultlogin').fadeOut('200');
				  $('#resultlogin').html('<img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Connexion en cours...</b>');
				  $('#resultlogin').fadeIn('200');
					$.ajax({
					   	type: "POST",
					   	url: "./load.php?action=login",
	 					data:({ login : document.formlogin.login.value, mdp : document.formlogin.mdp.value }),
					   	success: function(msg){ $('#resultlogin').html(msg); }
					});
			}

			function sendlogins() { 
				  printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Connexion en cours...</b></p>');
				  $.ajax({
					   	type: "POST",
					   	url: "./load.php?action=login",
	 					data:({ login : document.formlogins.login.value, back : document.formlogins.back.value, mdp : document.formlogins.mdp.value }),
					   success: function(msg){ printLoadingMessage('<p>'+msg+'<p>'); }
				  });
			}
						
			function sendmdp(admail) { 
				  $('#resultlogin').fadeOut('200');
				  $('#resultlogin').html('<img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Vérification en cours...</b>');
				  $('#resultlogin').fadeIn('200');
					if(document.getElementById('lostpasswd').value == '') {
						$('#resultlogin').html('<img src="fichiers/img/error.png"> <b>Merci de renseigner votre adresse email.</b>');
					} else  {
						$.ajax({
						   type: "POST",
						   url: "./load.php?action=sendmdp",
		 					 data:({ admail : document.getElementById('lostpasswd').value }),
						   success: function(msg){ $('#resultlogin').html(msg); }
						});
					}
			}

/* INSCRIPTION ************************************************************************************************************************** */

			function sendinscr() { 
				if (document.sendincr.email.value == '') {
				  printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Création de votre compte en cours...</b><p>');
					if(document.sendincr.nom.value == '') { document.sendincr.nom.className='novalid'; } else { document.sendincr.nom.className=''; }
					if(document.sendincr.prenom.value == '') { document.sendincr.prenom.className='novalid'; } else { document.sendincr.prenom.className=''; }
					if(document.sendincr.mail.value == '') { document.sendincr.mail.className='novalid'; } else { document.sendincr.mail.className=''; }
					$.ajax({
					   type: "POST",
					   url: "./load.php?action=sendinscr",
					 	 data:({ nom : document.sendincr.nom.value, prenom : document.sendincr.prenom.value, mail : document.sendincr.mail.value }),
					   success: function(msg){ printLoadingMessage(msg); $('#overlay').slideUp(500); }
					});
				}
			}
			
			function sendinsc() { 
				if (document.sendinc.email.value == '') {
				  $('#resultlogin').fadeOut('200');
				  $('#resultlogin').html('<img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Création de votre compte en cours...</b>');
				  $('#resultlogin').fadeIn('200');
					if(document.sendinc.nom.value == '') { document.sendinc.nom.className='novalid'; } else { document.sendinc.nom.className=''; }
					if(document.sendinc.prenom.value == '') { document.sendinc.prenom.className='novalid'; } else { document.sendinc.prenom.className=''; }
					if(document.sendinc.mail.value == '') { document.sendinc.mail.className='novalid'; } else { document.sendinc.mail.className=''; }
					$.ajax({
					   type: "POST",
					   url: "./load.php?action=sendinscr",
					 	 data:({ nom : document.sendinc.nom.value, prenom : document.sendinc.prenom.value, mail : document.sendinc.mail.value}),
					   success: function(msg){ $('#resultlogin').html(msg); }
					});
				}
			}

/* Etapes inscription ****************************************************************************************************************** */

			function savelive() {
				$.ajax({
				   type: "POST",
				   url: "./load.php?action=savelive",
					 data:({ nom : document.saveliv.nom.value, prenom : document.saveliv.prenom.value, email : document.saveliv.email.value,
					 				 telephone : document.saveliv.telephone.value, entreprise : document.saveliv.entreprise.value, adresse : document.saveliv.adresse.value  }),
				   success: function(msg){ printLoadingMessage(msg); }
				});
			}
			function slive(nom,champs) {
				if (nom != '') {
					$.ajax({
					   type: "POST",
					   url: "./load.php?action=savlive",
						 data:({ value : nom, donne : champs }),
					   success: function(msg){ printLoadingMessage(msg); }
					});
				}
			}
			function slivegall(h2,txt,galerie) {
					$.ajax({
					   type: "POST",
					   url: "./load.php?action=slivegall",
						 data:({ 'h2' : h2, 'txt' : txt, 'galerie' : galerie }),
					   success: function(msg){ printLoadingMessage(msg); }
					});
			}
			function savee(nom,champs,id) {
				$.ajax({
				   type: "POST",
				   url: "./?action=savee&id="+id,
					 data:({ 'nom' : nom, 'champs' : champs }),
				   success: function(msg){ printLoadingMessage(msg); }
				});
			}
			function svlsupp(value,donne,id) {
				$.ajax({
				   type: "POST",
				   url: "./?action=svlsupp&vid="+id,
					 data:({ 'value' : value, 'donne' : donne }),
				   success: function(msg){ printLoadingMessage(msg); }
				});
			}
			function save_one() { 
				printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Chargement en cours...</b></p>');
				$.ajax({
					type: "POST",
					url: "./load.php?action=saveone",
					data:({ nom : document.saveone.nom.value, prenom : document.saveone.prenom.value, email : document.saveone.email.value,
							telephone : document.saveone.telephone.value, adresse : document.saveone.adresse.value,
							domaine : document.saveone.domaine.value, metier : document.saveone.metier.value, details : document.saveone.details.value, parrain : document.saveone.parrain.value   }),
					success: function(msg){ printLoadingMessage(msg); }
				});
			}
			function addpage(value,type,style) {  if (value != '') {
				printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Ajout en cours...</b></p>');
				$.ajax({
					type: "POST",
					url: "./load.php?action=addp",
					data:({ name : value, 'type' : type, 'style' : style }),
					success: function(msg){ printLoadingMessage(msg); reload('listallp','liste_page'); }
				});
			} }
			function delpage(value) {  if (value != '') {
				printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Suppression en cours...</b></p>');
				$.ajax({
					type: "GET",
					url: "./load.php?action=delp&id="+value,
					success: function(msg){ printLoadingMessage(msg); reload('listallp','liste_page'); }
				});
			} }
			function delgal(page,value) {  
				  printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Suppression en cours...</b></p>');
						$.ajax({
						   type: "GET",
						   url: "./load.php?action=delgal&id="+value+"&page="+page,
						   success: function(msg){ printLoadingMessage(msg); $('#viewgall'+value).css({'display':'none'}); }
						});
			}
			function pagliv(nom,id) {
				$.ajax({
				   type: "POST",
				   url: "./?action=pagliv&id="+id,
					 data:({ 'nom' : nom }),
				   success: function(msg){ printLoadingMessage(msg); }
				});
			}
			function updownpage(nb,id) {
				$.ajax({
				   type: "POST",
				   url: "./?action=updownpage",
					 data:({ 'nb' : nb, 'id' : id }),
				   success: function(msg){ printLoadingMessage(msg); reload('listallp','liste_page'); }
				});
			}
			function visibpage(check,id) {
				$.ajax({
				   type: "POST",
				   url: "./?action=visibpage",
					 data:({ 'check' : check, 'id' : id }),
				   success: function(msg){ printLoadingMessage(msg); }
				});
			}
			function reload(id,action) {  
				$.ajax({
					type: "GET",
					url: "./load.php?action="+action,
					success: function(msg){ $('#'+id).fadeOut('200');
							 setTimeout(function() { $('#'+id).html(msg); },330); 
							 setTimeout(function() { $('#'+id).fadeIn('1500'); },700); 												  
					}		
				}); return false;
			} 

			function iframe(id,action) {  			
				$('#loadajax').slideDown(500);                                   
				$('#overlay').slideDown(500);	
				$('#loadajax').html('<iframe src="/users/'+id+'/'+action+'.php"></iframe>'); 
			}	
			
			function activelink(obj) {  
				$('a.linkmenu').each(function(){ $(this).removeClass('active'); }); 
				$(obj).addClass('active'); 
			} 
			
			function senrepsupport(value,id) { if (value == '') { printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Veuillez remplir votre message avant d\'envoyer votre réponse.</b></p>'); }
				else { $.ajax({
				    type: "POST",
				    url: "./?action=senrepsupport",
					data:({ 'txt' : value, 'id' : id }),
				    success: function(msg){ 
						printLoadingMessage(msg); 
						setTimeout(function() { reload('allsuppor','viewsupport'); },300); 
					}
				}); }
			}
			function sendmail(email,sujet,txt) { 
				if (txt == '' || sujet == '') { printLoadingMessage('<p><img src=".fichiers/img/error.png"> <b>Veuillez remplir votre message avant de l\'envoyer.</b></p>'); }
				else { $.ajax({
				   type: "POST",
				   url: "./?action=sendmail",
					 data:({ 'email' : email, 'sujet' : sujet, 'txt' : txt }),
				   success: function(msg){  printLoadingMessage(msg);  }
				}); }
			}
			function sendsupport() { 
					printLoadingMessage('<p><img src="fichiers/img/loading.gif"> &nbsp; &nbsp; <b>Envoie en cours...</b><p>');
					if(document.suppor.etat.value == '' || document.suppor.sujet.value == '' || document.suppor.text.value == '' || document.suppor.titre.value == '') {
						printLoadingMessage('<p><img src="fichiers/img/error.png"> <b>Veuillez compléter tous les champs du formulaire.</b></p>');
					} else  {
						$.ajax({
						   type: "POST",
						   url: "./load.php?action=sendsupport",
						   data:({ etat : document.suppor.etat.value, titre : document.suppor.titre.value, sujet : document.suppor.sujet.value, text : document.suppor.text.value }),
						   success: function(msg){ 
							 					printLoadingMessage(msg); 
												setTimeout(function() { reload('allsuppor','viewsupport'); },300); 
												document.suppor.titre.value = '';
												document.suppor.etat.value = '';
												document.suppor.sujet.value = '';
												document.suppor.text.value = '';
					 		 }
						});
				} 
			}
/* Affichage réponses ****************************************************************************************************************** */

			function printLoadingMessage(loadingMessageText) { 
				$('#loadingMessage').stopTime('loamstop');
				$('#loadingMessage').html(loadingMessageText); 
				$('#loadingMessage').slideDown();
  				$('#overlay').slideDown();	
  				$('#overlay').bind('click', function() { hideLoadingMessage(); }); 
  				$('#loadingMessage').oneTime(5000, 'loamstop', function() { hideLoadingMessage(); }); 
  			}
			function hideLoadingMessage() { 		
				$('#loadingMessage').slideUp();
  				$('#overlay').slideUp();	
  			}

			function closeajax(id) {
				$('#overlay').slideUp(500);
				$('#'+id).slideUp(500);
				setTimeout(function() {  $('#'+id).html('');    },700); 
			}

			function loadajax(url,id,bg) {
				if (bg != 'no') $('#overlay').slideDown(500);
				 $.ajax({
					type: "GET", url: "./load.php?action="+url,
					success: function(msg){
						$('#'+id).html(msg);
						setTimeout(function() {  
							$('#'+id).css({'display':'block' }); 
							document.getElementById(id).style.removeAttribute("filter");
						},200); 
					}
				 });
			}
			
			function load(page,id) {
				 $.ajax({
					type: "GET", url: "./load.php?load="+page,
					success: function(msg){
						setTimeout(function() { 
							document.getElementById(id).innerHTML = '<div id="'+page+'">'+msg+'</div>';  
						},200); 
					}
				 });
			}
			
			
			
/* Autres... *************************************************************************************************************************** */

			function scrolling() { 
						$('#scroll').everyTime(5000, 'scrolling', function() {
									if (parseInt($('#scroll').offset().left)-parseInt($('#scroll .scrollall').offset().left) >= '1620') $('#scroll .scrollall').animate({left:'0px'},{queue:false,duration:800}); 
									else $('#scroll .scrollall').animate({left:'-=600px'},{queue:false,duration:800}); 
									$('#cl1').removeClass('ok'); $('#cl2').removeClass('ok'); $('#cl3').removeClass('ok'); $('#cl4').removeClass('ok'); 
									
									if(parseInt($('#scroll').offset().left)-parseInt($('#scroll .scrollall').offset().left) <= '590') $('#cl2').addClass('ok');
									else if(parseInt($('#scroll').offset().left)-parseInt($('#scroll .scrollall').offset().left) <= '1150') $('#cl3').addClass('ok');
									else if(parseInt($('#scroll').offset().left)-parseInt($('#scroll .scrollall').offset().left) <= '1700') $('#cl4').addClass('ok');
									else $('#cl1').addClass('ok');
									
						}); 
			}

			function toggleDiv(name, id) {
				for (x=0; x<=99; x++) { 
					if (x == id) { 
						document.getElementById(name+x).style.display = 'block'; 
						document.getElementById(name + '_' + x).className = 'btnok'; 
					} else { 
						document.getElementById(name+x).style.display = 'none'; 
						document.getElementById(name + '_' + x).className = 'btn'; 
					}
				}
			}


