function toogle_div(nomdiv,imgname){
	var div = document.getElementById(nomdiv);
	var img = document.getElementById(imgname);
	if (div.style.display == "none"){
		div.style.display = "block";
		img.src = "commun/images/btn_moins.jpg";
	} else {
		div.style.display = "none";
		img.src = "commun/images/btn_plus.jpg";
	}
}

function get_pays(pays){
	var c = document.getElementById("cntpays");
	document.getElementById("tmp").innerHTML = "<img src='commun/images/indicator.gif'>";
	var xmlhttp = getHTTPObject(c,"html","innerHTML");
	xmlhttp.open("POST", "commun/ajax/pays.php",true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send("pays="+pays+"&cp="+document.getElementById("cp_cnt").value+"&ext=_cnt");
}

function get_cp(){ 
	var c = document.getElementById("cntville");
	document.getElementById("tmp").innerHTML = "<img src='commun/images/indicator.gif'>";
	var xmlhttp = getHTTPObject(c,"html","innerHTML");
	xmlhttp.open("POST", "commun/ajax/ville.php",true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send("cp="+document.getElementById("cp_cnt").value+"&ext=_cnt");
}
function resetchp(value,id,js,width,tindex){
	if (!value){
		document.getElementById("cnt"+id).innerHTML = "<input onfocus='"+js+"' class='champ2' tabindex='"+tindex+"' id='"+id+"_cnt' name='"+id+"_cnt' value=''>";
	} else {
		document.getElementById("cnt"+id).innerHTML = "<input onfocus='"+js+"' class='champ2' tabindex='"+tindex+"' id='"+id+"_cnt' name='"+id+"_cnt' value='"+value+"'>";
	}
}


function form_validation(param) {
    var checkEmail = "@.";
    var EmailValid = false;
    var EmailAt = false;
    var EmailPeriod = false;
    var err = false;
    var checkStr = document.getElementById('email_cnt').value;
    
    if (document.getElementById('societe_cnt').value == ''){
        alert('Veuillez saisir une société');
        document.getElementById('societe_cnt').focus();
        err = true;
    }
	 if (document.getElementById('pays_ct').value == ''){
        alert('Veuillez saisir un pays');
        document.getElementById('pays_ct').focus();
        err = true;
    }
    if (document.getElementById('cp_cnt').value == '' && !err){
        alert('Veuillez saisir un code postal');
        document.getElementById('cp_cnt').focus();
        err = true;
    }
    if (param && document.getElementById('email_cnt').value == '' && !err){
        alert('Veuillez saisir une adresse email');
        document.getElementById('email_cnt').focus();
        err = true;
    }
	
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkEmail.length;  j++)
    {
      if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
      if (ch == checkEmail.charAt(j) && ch == ".")
        EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid && !err)
  {
    alert("L'adresse électronique rentrée est invalide !");
    document.getElementById('email_cnt').focus();
    err = true;
  }
  if (err == false)
      return true;
  else
      return false;
}
