function prechargerNav()
{
	i1 = new Image;
	i1.src = "images/rub1_bis.gif";
	i2 = new Image;
	i2.src = "images/rub2_bis.gif";
	i3 = new Image;
	i3.src = "images/rub3_bis.gif";
	i4 = new Image;
	i4.src = "images/rub4_bis.gif";
	i5 = new Image;
	i5.src = "images/rub5_bis.gif";
}

function montre_calque(nom_calque)
{
	if(document.all){eval('document.all.'+nom_calque).style.visibility='visible';}                     //Internet Explorer
	else if (document.layers){eval('document.'+nom_calque).visibility='show';}                         //Netscape 4.5 et 4.7
	else if (document.getElementById){document.getElementById(nom_calque).style.visibility='visible';} //Netscape 6
}

function cache_calque(nom_calque)
{
	if(document.all){eval('document.all.'+nom_calque).style.visibility='hidden';}                     //Internet Explorer
	else if (document.layers){eval('document.'+nom_calque).visibility='hidden';}                      //Netscape 4.5 et 4.7
	else if (document.getElementById){document.getElementById(nom_calque).style.visibility='hidden';} //Netscape 6
}

//Ouverture d'une pop up
function ouvreFenetre(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

function confirmation(URL,MSG)
{
	if(confirm(MSG))
	{
		document.location.href=URL;
	}
}

function verifForm(LayerId)
{
	var msg = "";
	var isImg = "";
	if(document.forms['ajoutActu'].elements['AC_titre'].value == "") msg += "Veuillez fournir un titre S.V.P\n"; else msg += "";
	if(document.forms['ajoutActu'].elements['AC_description'].value == "") msg += "Veuillez fournir une description S.V.P\n"; else msg += "";
	if(document.forms['ajoutActu'].elements['AC_texte'].value == "") msg += "Veuillez fournir un texte S.V.P\n"; else msg += "";
	if(document.forms['ajoutActu'].elements['AC_pdf'].value == "") isImg += ""; else isImg += true;
	if(document.forms['ajoutActu'].elements['AC_img1'].value == "") isImg += ""; else isImg += true;
	if(document.forms['ajoutActu'].elements['AC_img2'].value == "") isImg += ""; else isImg += true;
	if(document.forms['ajoutActu'].elements['AC_img3'].value == "") isImg += ""; else isImg += true;
	if(document.forms['ajoutActu'].elements['AC_img4'].value == "") isImg += ""; else isImg += true;	
		

	if(msg=="") 
	{
		if(isImg!="") {
			montre_calque(LayerId);
		}
		document.forms['ajoutActu'].elements['btValide'].disabled = true;
		document.forms['ajoutActu'].submit();
	}
	else 
	{
		alert(msg);
		msg = "";
	}	
}

function insertion(FormName, InputName, repdeb, repfin) {
  var input = document.forms[FormName].elements[InputName];
  input.focus();
  /* pour l'Explorer Internet */
  if(typeof document.selection != 'undefined') {
    /* Insertion du code de formatage */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;
    /* Ajustement de la position du curseur */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -repfin.length);
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
  /* pour navigateurs plus récents basés sur Gecko*/
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* pour les autres navigateurs */
  else
  {
    /* requête de la position d'insertion */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Insertion du code de formatage */
    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}

function confirmate(MSG)
{
	if(confirm(MSG))
	{
		return true;
	}
}

function moveSelected(from, to) {
	from = document.getElementById(from);
	to = document.getElementById(to);
	len = from.options.length - 1;
	for (i = len; i >= 0; i--) {
		if (from.options[i].selected) {
			to.options[to.options.length] = new Option(from.options[i].text,from.options[i].value);
			from.options[i] = null;
		}
	}
	return true;
}

function SelectAll(to)
{
	to = document.getElementById(to);
	len = to.options.length - 1;
	for (i = len; i >= 0; i--) {
		to.options[i].selected = true;
	}
}

function MailBz(adresse,delimiteur)
{
	tabMail = adresse.split(delimiteur)
	adresse_modif = tabMail[0]+tabMail[1];
	document.location.href='mailto:'+adresse_modif;
}


function test_it(entry) {
 if (entry.value && entry.value.length!=0) {
  entry.value=""+ eval(entry.value);
  }
 computeForm(entry.form);
 }

function computeForm(form) {
 if ((!form.months.value || form.months.value.length==0) ||
    (!form.rate.value || form.rate.value.length==0) ||
    (!form.financed.value || form.financed.value.length==0)) {
   return;
   }
 if (!alrt_msg(form.months,1,480,"Nombre de versements") ||
    !alrt_msg(form.rate,.001,99,"Votre taux d'intérêt") ||
    !alrt_msg(form.financed,100,10000000,"Le capital à financer")) {
   form.payment.value="Valeur hors échelle - Cliquez sur Réinitialiser";
   return;
    }
 var i=form.rate.value;
 ffv=0;
 ffv+=form.financed.value;
 fmv=0;
 fmv+=form.months.value;
 if (i > 1.0) {
    // Apporter les corrections des erreurs de conversion binaire/point flottant
  i=(i/100.0)+.00001;
  var fmt="";
  fmt+=i;
  fmt=fmt.substring(0,6)
  form.rate.value=fmt;
  }
 i/=12;
 var isn=1;
 for (var j=0;j<form.months.value;j++)
  isn=isn*(1+i);
  form.payment.value=(form.financed.value*isn*i)/(isn-1);
  fpv=0;
  fpv+=form.payment.value;
  var fmt="";
  var add=9;
  fmt+=form.payment.value;
  for (var i=0;i<fmt.length;i++) {
   if (fmt.charAt(i)==".") {
    add=i+3;
    i=fmt.length;
    }
   }
  fmt=fmt.substring(0,add);
  fcalc=((fmv*fpv)-ffv);
  var fmtb="";
  var add=9;
  fmtb+=fcalc;
  for (var i=0;i<fmtb.length;i++) {
   if (fmtb.charAt(i)==".") {
    add=i+3;
    i=fmtb.length;
    }
   }
  fmtb=fmtb.substring(0,add);
  form.payment.value="   Frs "+fmt+"              Frs "+fmtb;
 }
 
function reset_it(form) {
 form.months.value="";
 form.rate.value="";
 form.financed.value="";
 form.payment.value="";
 }

function alrt_msg(entry,low,high,prompt) {
 prompt="You couldn't know. "+prompt 
 +" entry has unacceptable stuff: "+entry.value;
 var scratch=entry.value;
 for (var i=0;i<scratch.length;i++) {
  var letter=scratch.substring(i,i+1);
  if ((letter<"0" || "9"<letter) && letter!='.') {
   alert(prompt);
   return false;
   }
    }
 var errtst=parseFloat(scratch)
 if (errtst<low || high<errtst) {
  alert("I'm sorry. "+prompt+ " is not in the range"
  +" from "+low+" to "+high+"!");
  return false;
  }
 entry.value=scratch;
 return true;
 }
 
function CalculEcheances(taux,montantPret,nbMois)
{
	x = 1+taux / 1200;
	MntRbtPer = montantPret / (1-1/Math.exp(Math.log(x)*nbMois)) * (x-1);
	return Math.round (MntRbtPer*100)/100;
}

function isRIBvalid()
  {
  if (isRIBvalid.arguments.length>=3)
      {
      var bqe=isRIBvalid.arguments[0];
      var gui=isRIBvalid.arguments[1];
      var cpt=isRIBvalid.arguments[2].toUpperCase();
      var tab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
      var tab1="123456789123456789234567890123456789".split("");
      while (cpt.match(/\D/) != null)
          cpt=cpt.replace(/\D/, tab1[tab.indexOf(cpt.match(/\D/))]);
      var cp=parseInt    (cpt, 10);
      
      a=bqe%97;
      a=a*100000+parseInt(gui, 10);
      a=a%97;
      a=a*Math.pow(10, 11) + cp;
      a=a%97
      a=a*100;
      a=a%97
      a=97-a;
      if (isRIBvalid.arguments.length>3)
          return isRIBvalid.arguments[3]==a;
      else
          return a;
      }
  else
      {
      return false;
      }
  }
  
function clearRadio(objName) {
	for (var i = 0; i < objName.length; i++) {
	    objName[i].checked = false;
	}
}

function showBloc(objName) {		
	objName.style.position='relative';
	objName.style.visibility='visible';
}

function hideBloc(objName) {		
	objName.style.position='absolute';
	objName.style.visibility='hidden';
}

    

