   function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);
  
   return x;
  
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { 
	if (v=='show'){
	$("#titre_carte").html(obj.id);
	}
	obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
	
}
$(document).ready(function(){
						   
						
	$("#login").focus(function(){
							   var textlogin = $(this).val();
							   var defaultlogin = "Nom utilisateur";
							   defaultlogin = jQuery.trim(defaultlogin);
							   textlogin = jQuery.trim(textlogin);
							 

if(textlogin == defaultlogin){
$(this).val('');
$(this).removeClass('input-text').addClass('input-text-active');
}
});
$("#mot_pass").focus(function(){
if (jQuery.trim($(this).val()) == "Mot de passe"){
$(this).val('');
$(this).removeClass('input-text').addClass('input-text-active');
}
});
$("#login").blur(function(){
if (jQuery.trim($(this).val()) == ""){
$(this).val('Nom utilisateur').removeClass('input-text-active').addClass('input-text');
}
});
$("#mot_pass").blur(function(){
if (jQuery.trim($(this).val()) == ""){
	$(this).val('Mot de passe').removeClass('input-text-active').addClass('input-text');
}
});			   
  $(".pagination a").mouseover(function(){
  $(".pagination a").filter(".current").removeClass("current");
  $(this).addClass("current");
});
						   var validator = $("#registrationform").validate({
		rules: {
			Nom: "required",
			Prenom: "required",
			adresse: "required",
			cp: "required",
			ville_register: "required",
			identifiant: {
				required: true,
				minlength: 2,
				remote: "modules/membre/user.php"
			},
			password: {
				required: true,
				minlength: 5
			},
			password_confirm: {
				required: true,
				minlength: 5,
				equalTo: "#password"
			},
			pays_register:{
				required: true
			},
			email: {
				required: true,
				email: true
			},
			url:{
				url: true,
				remote: "modules/membre/url.php"
			}
		},
		messages: {
			Nom: "Entrez votre nom",
			Prenom: "Entrez votre prenom",
			adresse: "Entrez votre Adresse",
			cp: "Entrez votre Code Postal",
			ville_register: "Entrez votre Ville",
			identifiant: {
				required: "Entrez votre identifiant",
				minlength: jQuery.format("Entrez au moin {0} characters"),
				remote: jQuery.format("{0} est D&eacute;ja utilser")
			},
			password: {
				required: "Entrez le Mot de passe",
				minlength: jQuery.format("Entrez au moin {0} characters"),
				remote: jQuery.format("{0} est d&eacute;ja utilser")
			},
			password_confirm: {
				required: "R&eacute;petez le Mot de passe",
				minlength: jQuery.format("Entrez au moin {0} characters"),
				equalTo: "Entez le m&ecirc;me mot de passe"
				},
			email: {
				required: "Svp Entrez une adresse email valide",
				email: "Svp Entrez une adresse email valide"
			},	
		    url: {
				url: "Svp Entrez une adresse url valide",
				remote: jQuery.format("{0} est d&eacute;ja utilser")
			},
			pays_register: {
				required: "S&eacute;lectionnez le pays de votre h&eacute;bergement"
			}
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			$("#registrationwrap").css({ opacity: "0.50", background: "#FFFFFF"});
		$("#onload_transaction_registration").addClass("onload_transaction_registration");
			$.ajax({ 
  type: "POST", 
  url: "modules/membre/membre_register.php", 
  data: {
   Nom:$("#Nom").val(),
   Prenom:$("#Prenom").val(),
   adresse:$("#adresse").val(),
   cp:$("#cp").val(),
   ville_register:$("#ville_register").val(),
   identifiant:$("#identifiant").val(),
   password:$("#password").val(),
   email:$("#email").val(),
   url:$("#url").val(),
   pays_register:$("#pays_register").val()
  },
  success: function(msg){ 
  $("#registrationwrap").css({ opacity: "1", background: "#FFFFFF"});
   $("#onload_transaction_registration").removeClass("onload_transaction_registration");
  $("#registrationwrap").html(msg);	
  }
  });
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});


function delete_image_membre(nom_image){
nom_photo = 'div_'+nom_image+'_membre';
nom = document.getElementById(nom_photo);
$.ajax({ 			    
  type: "POST", 
  url: "modules/Admin_membre/delete.php", 
  data: {
   photo:nom_image
  },
  success: function(msg){ 
  nom.innerHTML = msg;	
   }
  });
}
						   //$('.map').maphilight({fade: true});
						  $("#menu span").click(function(){
						  $(this).parent().parent().find(".active").removeClass("active").addClass("non-active");
						  $(this).parent().removeClass("non-active").addClass("active");
                         });
var validator = $("#contactform").validate({
		rules: {
			Nom: "required",
			Prenom: "required",
			adresse: "required",
			Sujet: {
				required: true,
				minlength: 3
			},
			Message: {
				required: true,
				minlength: 20
			},
			email: {
				required: true,
				email: true
			},
			url:{
				url: true
			},
			copie_mail: "required"
		},
		messages: {
			Nom: "Entrez votre nom",
			Prenom: "Entrez votre prenom",
			adresse: "Entrez votre Adresse",
			Sujet: {
				required: "Entrez le sujet",
				minlength: jQuery.format("Entrez au moin {0} characters"),
				remote: jQuery.format("{0} is already in use")
			},
			Message: {
				required: "Entrez le Message",
				minlength: jQuery.format("Entrez au moin {0} characters")
			},
			email: {
				required: "Svp Entrez un email valide",
				email: "Svp Entrez un email valide"
			},
			url: {
				url: "Svp Entrez une url valide"
			},
			copie_mail: "Svp selectionnez oui ou non"
			
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			$("#contactwrap").css({ opacity: "0.50", background: "#FFFFFF"});
		$("#onload_transaction").addClass("onload_transaction");
			$.ajax({ 			    
  type: "POST", 
  url: "modules/Contact/contact.php", 
  data: {
   Nom:$("#Nom").val(),
   Prenom:$("#Prenom").val(),
   adresse:$("#adresse").val(),
   email:$("#email").val(),
   url:$("#url").val(),
   Sujet:$("#Sujet").val(),
   Message:$("#Message").val(),
   copie_mail:$("#copie_mail_yes").val()
  },
  success: function(msg){ 
  $("#contactwrap").css({ opacity: "1", background: "#FFFFFF"});
   $("#onload_transaction").removeClass("onload_transaction");
  $("#contactwrap").html(msg);	
  }
  });
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});

  //fin Controle
  
  //contôle de formuliare d'administration membre
     
var validator = $("#Administrationform").validate({
		rules: {
			titre: {
				required: true,
				minlength: 3,
				maxlength: 18
			},
			Categorie_site: "required",
			text_description: {
				required: true,
				maxlength: 400
			},
			detail: {
				required: true,
				minlength: 300
			},
			tarifs: {
				required: true,
				minlength: 300
			},
			adresse: {
				required: true,
				maxlength: 150
			}
		},
		messages: {
			titre: {
				  required: "Entrez votre titre",
				  minlength: jQuery.format("Min {0} caracteres"),
				  maxlength: jQuery.format("Max {0} caracteres")
			},
			Categorie_site: {
				  required: "choisir une categorie",
				  minlength: jQuery.format("Min {0} caracteres"),
				  maxlength: jQuery.format("Max {0} caracteres")
				    },
			detail: {
				  required: "Entrez votre detail",
				  minlength: jQuery.format("Min{0} caracteres")
				    },
			tarifs: {
				  required: "Entrez vos tarifs",
				  minlength: jQuery.format("Min {0} caracteres")
			},
			adresse: {
				  required: "Entrez votre Adresse",
				  maxlength: jQuery.format("Max {0} caracteres")
			},
			text_description: {
				  required: "Entrez votre texte",
				  maxlength: jQuery.format("Max {0} caracteres")
			}
			
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {

			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			$("#adminmembrewrap").css({ opacity: "0.50", background: "#FFFFFF"});
		$("#onload_transaction").addClass("onload_transaction");
		if ($("#promotion").is(':checked') == true){
		var promotion = 1;
		}else{
		var promotion = 0;
		}
		if ($("#googleMap").val() == 1){
		var longitude = $("#longitude").val();
		var latitude = $("#latitude").val();
		}else{
		var longitude = '';
		var latitude = '';
		}
			$.ajax({ 			    
  type: "POST", 
  url: "modules/Admin_membre/update.php", 
  data: {
   titre:$("#titre").val(),
   Categorie_site:$("#Categorie_site").val(),
   detail:$("#detail").val(),
   tarifs:$("#tarifs").val(),
   adresse:$("#adresse").val(),
   promotion:promotion,
   longitude:longitude,
   latitude:latitude,
   text_description:$("#text_description").val()
  },
  success: function(msg){
   $("#adminmembrewrap").css({ opacity: "1", background: "#FFFFFF", border : "1"});
   $("#onload_transaction").removeClass("onload_transaction");
  $("#adminmembrewrap").html(msg);	
  }
  });
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});

  //fin Controle de formuliare d'administration membre
	$.preload('.photo_annonce', {
		onRequest:request,
		onComplete:complete,
		onFinish:finish,
		placeholder:'template/images/load_photo_annonce.gif',//this is the really important option
		notFound:'template/images/pas_de_photo.gif'//optional image if an image wasn't found
	});
   $('#Annonce_top').cycle({
    fx:    'scrollRight',
    delay: -3000
	});
$.ajax({ 
  type: "POST", 
  url: "modules/recherche/recherche.php", 
  data: {continent:'Europe'},
  success: function(msg){ 
  
  $("#default_pays").html(msg);
  } 
  });

							});// ready close
$.preload('img', {
		onRequest:request,
		onComplete:complete,
		onFinish:finish,
		placeholder:'template/images/load_map.gif',//this is the really important option
		notFound:'template/images/load_map.gif'//optional image if an image wasn't found
	});
function deconnect_process(){
  $.ajax({ 
  type: "POST", 
  url: "modules/membre/deconnect.php", 
  success: function(msg){ 
  setTimeout(function(){window.location='index.php?page=Actualites';},0);
  
  }
});
}

	
