function cp_ville(cp)
{
	if(document.getElementById('cp').value.length == 5)
	{
		$('ville').update("<img src=\"./images/load.gif\" alt=\"\" />");
		new Ajax.Request('ajax.php',
		{method: 'post', parameters: 'cp='+cp, onSuccess: function(ajax)
			{
				$('ville').update(ajax.responseText);
			}
		});
	}
}

// Annuaires des dermato : afficher les coordonnees
function coordonees_der(id_der)
{
		var id_div = 'coordonees_dermato'+id_der;

		$(id_div).update("<img src=\"./images/load.gif\" alt=\"\" />");
		new Ajax.Request('ajax.php',
		{method: 'post', parameters: 'id_der='+id_der, onSuccess: function(ajax)
			{
				$(id_div).update(ajax.responseText);
			}
		});
}

function change_reg(id_reg)
{
		new Ajax.Request('ajax.php',
		{method: 'post', parameters: 'id_reg='+id_reg, onSuccess: function(ajax)
			{
				$('depart_dermat').update(ajax.responseText);
			}
		});
}

function show_list(id_typ)
{
		$('listview').update("<img src=\"./images/load.gif\" alt=\"\" />");
		new Ajax.Request('ajax.php',
		{method: 'post', parameters: 'id_typ='+id_typ, onSuccess: function(ajax)
			{
				$('listview').update(ajax.responseText);
			}
		});
}

function openurl(htmlurl,nom) {
	width = 501;
	leftf =(screen.width-width)/2;
	height = 501;
	topf  = (screen.height-height)/2;

	nom = nom.replace(/\s/g,"");
	var riwindow = window.open(htmlurl,nom,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width= '+width+',height='+height+',left='+leftf+',top='+topf);
	if (riwindow){
		riwindow.focus();
	}
}

function verifMail(a){
	testm = false ;
	for (var j=1 ; j<(a.length) ; j++)
	{
		if (a.charAt(j)=='@')
		{
			if (j<(a.length-4))
			{
				for (var k=j ; k<(a.length-2) ; k++)
				{
					if (a.charAt(k)=='.') testm = true;
				}
			}
		}
	}
	
	if (testm==false)
	{
		document.getElementById("err_email").innerHTML = '<span class="error_log"> L\'adresse e-mail saisie n\'est pas valide</span>';
		document.getElementById("email").style.border = '1px solid red';
		document.getElementById("email").style.color = 'red';
		//alert('adresse e-mail non valide.');
	}
	else
	{
		document.getElementById("err_email").innerHTML = '<span style="color : #507CBC;"> L\'adresse e-mail est valide</span>';
		document.getElementById("email").style.border = '1px solid #507CBC';
		document.getElementById("email").style.color = '#507CBC';
	}
	return testm ;
}

function showdiv(div) {
	document.getElementById(div).style.display = 'block';
}
function hidediv(div) {
	document.getElementById(div).style.display = 'none';
}
