function toogle_div(nomdiv){
    var div = document.getElementById(nomdiv);
    if (div.style.display == "none")
        div.style.display = "block";
    else
        div.style.display = "none";
}

var oldrub;
function swap_field(num_rub){
    if (oldrub && num_rub != oldrub){
        document.getElementById("opt"+oldrub).style.display ="none";
    }
    if (oldrub != num_rub){
        document.getElementById("opt"+num_rub).style.display ="block";
        oldrub = num_rub;
    } 
}

function dolink(url,rem) {
	if (confirm(rem)) {
		document.location.href = url;
	} else {

	}
}

function open_url(url,titre,width,height){
  eval("window.open('"+url+"&titre="+titre+"&width="+width+"&height="+height+"','pop_img','width="+width+",height="+height+",scrollbars=no,resizable=no,toolbar=no,status=no,location=no,left=0,top=0');");
}

function form_validation(param) {
    var checkEmail = "@.";
    var EmailValid = false;
    var EmailAt = false;
    var EmailPeriod = false;
    var err = false;
    var checkStr = document.getElementById('email_ct').value;
    
    if (document.getElementById('nom_ct').value == ''){
        alert('Veuillez saisir Nom');
        document.getElementById('nom_ct').focus();
        err = true;
    }
    if (document.getElementById('email_ct').value == '' && !err){
        alert('Veuillez saisir E-mail');
        document.getElementById('email_ct').focus();
        err = true;
    }
    if (param && document.getElementById('adresse_cnt').value == '' && !err){
        alert('Veuillez saisir votre N° et Rue');
        document.getElementById('adresse_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_c').focus();
    err = true;
  }
  if (err == false)
      return true;
  else
      return false;

}