function getIndex(what,which) {
    for (var i=0;i < what.elements.length;i++)
        if (what.elements[i].name == which)
            return i;
    return -1;
}

function getFullName(el) {
	   idx=getIndex(el.form,el.name);
	   return el.form.name+'.elements['+idx+']';
}

function cherche_cp(ville,dest) {
	   retour=getFullName(dest);
	   if (ville.length < 2) {
	   	alert ("La ville doit avoir 2 caractères au minimum");
	   	return false;
	   }
	   msgWindow=window.open('','',   'toolbar=no,scrollbars=yes,width=450,height=250')	  ;
	   msgWindow.document.location="cherche_ville_cp.php?action=ville&param="+escape(ville)+"&dest="+retour;
	   msgWindow.document.close();
}
function cherche_ville(cp,dest) {
	   retour=getFullName(dest);
	   if (cp.length < 2) {
	   	alert ("Le code postal doit avoir 2 caractères au minimum");
	   	return false;
	   }
	   msgWindow=window.open('','',   'toolbar=no,scrollbars=yes,width=450,height=250')	  ;
	   msgWindow.document.location="cherche_ville_cp.php?action=cp&param="+escape(cp)+"&dest="+retour;
	   msgWindow.document.close();
}
function cherche_annu(nom, cp, ville) {
	   msgWindow=window.open('','',   'toolbar=no,scrollbars=yes,resizable=yes,width=600,height=400')	  ;
	   msgWindow.document.location="http://www.pagesjaunes.fr/pb.cgi?DEFAULT_ACTION=bf_inscriptions_req&faire=decode_input_image&frm_nom="+nom+"&frm_departement="+cp+"&frm_localite="+ville;
	   msgWindow.document.close();
}

