function validCodePostal(val) {
	var reg = /^[a-zA-Z][0-9][a-zA-Z](\s)?[0-9][a-zA-Z][0-9]$/;
	return reg.test(val);
}

function addToPDV(membre_id) { 

	var myRandom = parseInt(Math.random()*99999999); // cache buster 

    jQuery.post("/pdv/manpdv.php", {id: membre_id, op:'ajout', rand:myRandom } , function(data) {
																														     // alert(data);
	  //window.location.href='http://www.tourismemauricie.com/monitineraire';
	});
	
}

function delToPDV(membre_id) { 

	var myRandom = parseInt(Math.random()*99999999); // cache buster 

    jQuery.post("/pdv/manpdv.php", {id: membre_id, op:'supprimer', rand:myRandom } , function(data) {
																														
	 affichePDV();
	});
	
}

function videPDV() { 

	var myRandom = parseInt(Math.random()*99999999); // cache buster 

    jQuery.post("/pdv/manpdv.php", { op:'vider', rand:myRandom } , function(data) {
																														
	 affichePDV();
	});
	
}

function moveUp(index) { 

	var myRandom = parseInt(Math.random()*99999999); // cache buster 

    jQuery.post("/pdv/manpdv.php", {index: index, op:'monter', rand:myRandom } , function(data) {
	 affichePDV();
	});
	
}

function moveDown(index) { 

	var myRandom = parseInt(Math.random()*99999999); // cache buster 

    jQuery.post("/pdv/manpdv.php", {index: index, op:'descendre', rand:myRandom } , function(data) {																													
	 affichePDV();
	});
	
}

function affichePDV() {

  	var myRandom = parseInt(Math.random()*99999999); // cache buster 

    jQuery.post("/pdv/manpdv.php", { op:'affiche', rand:myRandom } , function(data) {
	 document.getElementById('panierdesvoyageurs').innerHTML=data;
	});
	
}



function setPointDeDepart() {
	
	var myRandom = parseInt(Math.random()*99999999); // cache buster 
    var pdd;
	pdd = document.getElementById('point_de_depart').value;
	
	if (pdd.length<5) {
	  alert('Le code postal que vous avez saisi est invalide.  Veuillez le saisir de nouveau.');
	  return false;
	} 
	
	
    jQuery.post("/pdv/manpdv.php", {pdd: pdd, op:'pointdedepart', rand:myRandom } , function(data) {																													
	 affichePDV();
	});	
	
}

function setPointDeRetour() {
	
	var myRandom = parseInt(Math.random()*99999999); // cache buster 
    var pdd;
	pdd = document.getElementById('point_de_retour').value;
	
/*	if (pdd.length<5) {
	  alert('Le code postal que vous avez saisi est invalide.  Veuillez le saisir de nouveau.');
	  return false;
	} 
	*/
	
    jQuery.post("/pdv/manpdv.php", {pdd: pdd, op:'pointderetour', rand:myRandom } , function(data) {																													
	 affichePDV();
	});	
	
}
function printIFrame(id) {
var iframe = document.frames ? document.frames[id] : document.getElementById(id);
var ifWin = iframe.contentWindow || iframe;
ifWin.printPage();
return false;
}


function afterPDV(obj) {
 
  if (obj.className.indexOf('en')!=-1) {
	obj.className  = 'voir-en';  
	 obj.onclick     =  function() {redirectpdven()};
  } else {
    obj.className  = 'voir';
    obj.onclick     =  function() {redirectpdv()};
  }
  return false;
}

function redirectpdv() { window.location.href='/monitineraire'; }
function redirectpdven() { window.location.href='/my-itinerary'; }
