// fonction pour faire apparaitre ou disparaitre les tables avec les checkbox */

/*function voir1(categorie,tabl) {
	
	if (document.getElementById(''+categorie+'').checked == true)  {
		document.getElementById(''+tabl+'').style.display='inline';
	}
	
	if (document.getElementById(''+categorie+'').checked == false)  {
		document.getElementById(''+tabl+'').style.display='none';
	}

}*/

function voir1() {
	
	if (document.getElementById('categorie1').checked == true)  {
		document.getElementById('paye').style.display='inline';
	}
	
	if (document.getElementById('categorie1').checked == false)  {
		document.getElementById('paye').style.display='none';
	}

}

function voir2() {
	
	if (document.getElementById('categorie2').checked == true)  {
		document.getElementById('bilan').style.display='inline';
	}
	
	if (document.getElementById('categorie2').checked == false)  {
		document.getElementById('bilan').style.display='none';
	}

}

function voir3() {
	
	if (document.getElementById('categorie3').checked == true)  {
		document.getElementById('sur').style.display='inline';
	}
	
	if (document.getElementById('categorie3').checked == false)  {
		document.getElementById('sur').style.display='none';
	}

}

// fonction de verification des  bouton radio et input dans le formulaire de declaration de situation 

function reglement() {
	/*document.form.paye_autre.value = " ";*/
	document.getElementById('paye_autre').value = " ";
	document.getElementById('autre').style.display='none';
}

function reglement1() {
	document.getElementById('autre').style.display='inline';
}


// fonction defilement texte -------------------------------------------------------
var divstop = '';
var tbscroll=new Array();

function scroller(divname,largeur,hauteur,tbtext,sens,speed) {
 this.divname=divname;
 this.largeur=largeur;
 this.hauteur=hauteur;
 this.tbtext=tbtext;
 this.idx=1;
 this.sens = sens;
 this.speed = speed;
}

function addscroller(scroll) { tbscroll[tbscroll.length] = scroll }

function stop(div){ divstop = div }

function restart(){
 divstop = ''
}

function start(){
if (tbscroll.length > 0) {
 for(i=0; i < tbscroll.length; i++){
  if (tbscroll[i].tbtext.length > 0) {
   if(document.getElementById){
    ns6div = document.getElementById(tbscroll[i].divname)
    if (tbscroll[i].sens == 'left')
    	ns6div.style.left = tbscroll[i].largeur;
    else
    	ns6div.style.top = tbscroll[i].hauteur;
    ns6div.innerHTML=tbscroll[i].tbtext[0];
   }
  }
 }
 ns6scroll();
 }
}

function ns6scroll(){
 for(i=0; i < tbscroll.length; i++){
  if (divstop != tbscroll[i].divname) {
   if (tbscroll[i].tbtext.length > 0){
    ns6div=document.getElementById(tbscroll[i].divname);
    if (tbscroll[i].sens == 'left') {
     sizeup=ns6div.offsetWidth;
     if(parseInt(ns6div.style.left)>0&&parseInt(ns6div.style.left)<= tbscroll[i].speed)
      ns6div.style.left=0;
     if (parseInt(ns6div.style.left)>=sizeup*-1)
      ns6div.style.left=parseInt(ns6div.style.left)-tbscroll[i].speed;
     else{
      ns6div.style.left=tbscroll[i].largeur;
      if(tbscroll[i].idx >= tbscroll[i].tbtext.length-1)
       tbscroll[i].idx=0;
      else 
       tbscroll[i].idx++;
      ns6div.innerHTML=tbscroll[i].tbtext[tbscroll[i].idx]; 
     }
    }
  else {
     sizeup=ns6div.offsetHeight;
     if(parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=tbscroll[i].speed)
      ns6div.style.top=0;
     if (parseInt(ns6div.style.top)>=sizeup*-1)
      ns6div.style.top=parseInt(ns6div.style.top)-tbscroll[i].speed;
     else{
      ns6div.style.top=tbscroll[i].hauteur;
      if(tbscroll[i].idx >= tbscroll[i].tbtext.length-1)
       tbscroll[i].idx=0;
      else 
       tbscroll[i].idx++;
      ns6div.innerHTML=tbscroll[i].tbtext[tbscroll[i].idx]; 
     }
    }
   }
  }
 }
 setTimeout("ns6scroll()",100);
}
// fin fonction defilment texte ------------------------------------------------------

// fonction permettant ecrire flash
function flash_object(niveau,anim,width,height){
	
	if(niveau == "1") var url = "./";
	else if (niveau == "2") url = "../";
	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">')
	document.write('<param name="movie" value="'+url+'flash/'+anim+'.swf">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="wmode" value="transparent">')
	document.write('<embed src="'+url+'flash/'+anim+'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent">')
	document.write('</embed></object>')
}

// popup simple => 1 ou 0 pr le scroll
function popup(page, nom, largeur, hauteur, scrol) {
  window.open(page, ""+nom+"", "scrollbars="+ scrol +",menubar=no,toolbar=no,resizable=yes,width="+ largeur + ",height=" + hauteur);
}
// changement de couleur au survol des lignes
function change_color_ligne(id,defaut,txt){
	document.getElementById(id).style.backgroundColor=defaut;
	// si on mouseover col=#FF8000 sinon col=#000000
	var col = (txt) ? "#000000" : "#494949";	
	// on change la couleur de la police pr les 5 <td>
	document.getElementById(id+'1').style.color=col;
	document.getElementById(id+'2').style.color=col;
	document.getElementById(id+'3').style.color=col;
	document.getElementById(id+'4').style.color=col;
	document.getElementById(id+'5').style.color=col;
}
/*************** paires pour les formulaires ********************/

// remet la couleur dans l'input 
function couleur(obj) {
     obj.style.backgroundColor = "#FFFFFF";
}

// regarde si les champs sont vides
function check() {
	var msg = "";
	var color = "#FFFF99";
if (document.form_paiement.nature.value == "")   {
      msg += "Veuillez choisir la nature du paiement\n";
      document.form_paiement.nature.style.backgroundColor = color;
   }
if (document.form_paiement.montant.value == "")   {
      msg += "Veuillez saisir un montant\n";
      document.form_paiement.montant.style.backgroundColor = color;
   }
if (document.form_paiement.reference.value == "")   {
      msg += "Veuillez saisir une référence du dossier\n";
      document.form_paiement.reference.style.backgroundColor = color;
   }
if (document.form_paiement.nom.value == "")   {
      msg += "Veuillez saisir votre nom\n";
      document.form_paiement.nom.style.backgroundColor = color;
   }
if (document.form_paiement.ville.value == "")   {
      msg += "Veuillez saisir la ville du siège social\n";
      document.form_paiement.ville.style.backgroundColor = color;
   }
if (msg == "") return(true);
   else   {
      alert(msg);
      return(false);
   }
}
/* ouverture pop up conseiller a un  ami */
// popup centre
function popupcentre(page,largeur,hauteur,scrol) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",menubar=no,toolbar=no,resizable=yes,scrollbars="+ scrol);
}

// popup simple => 1 ou 0 pr le scroll
function popup(page, nom, largeur, hauteur, scrol) {
  window.open(page, ""+nom+"", "scrollbars="+ scrol +",menubar=no,toolbar=no,resizable=yes,width="+ largeur + ",height=" + hauteur);
}

// fonction ajout aux favoris et marque-page  
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
/**************************************************/
// changement de couleur au survol des lignes
function change_color_ligne(id,defaut,txt){
	document.getElementById(id).style.backgroundColor=defaut;
	// si on mouseover col=#FF8000 sinon col=#000000
	var col = (txt) ? "#000000" : "#494949";	
	// on change la couleur de la police pr les 5 <td>
	document.getElementById(id+'1').style.color=col;
	document.getElementById(id+'2').style.color=col;
	document.getElementById(id+'3').style.color=col;
	document.getElementById(id+'4').style.color=col;
	document.getElementById(id+'5').style.color=col;
}

//################## pour le paiment  #####################################################"

// vide les champs et desactive les boutons radio ou checkbox
function desactiver(btn) {
	switch(btn) {
		case 'modalite':
		document.form_paiement.montant1.value = "";
		document.form_paiement.montant2.value = "";
		document.form_paiement.montant3.value = "";
 		document.form_paiement.nb_echeance[0].checked = false;
		document.form_paiement.nb_echeance[1].checked = false;
		document.form_paiement.mt_egal.checked = false;
		break;
		case 'echeance':
		document.form_paiement.montant1.value = "";
		document.form_paiement.montant2.value = "";
		document.form_paiement.montant3.value = "";
		break;
	}
}

// divise le montant global en 2 ou 3 fois identiques et rempli les champs
function calcul() {
	var mtg = document.form_paiement.montant.value;
	var reg = new RegExp("^[0-9]+\\.[0-9]{2}$", "i"); // test du format xx.xx
	
	if(document.form_paiement.mt_egal.checked == false){ // si on décoche on vide les champs
		document.form_paiement.montant1.value = "";
		document.form_paiement.montant2.value = "";
		document.form_paiement.montant3.value = "";
	}else{ // si on coche on remplit
		if(mtg != "") { // si le montant n'est pas vide
		
			if (reg.test(mtg)) {
		
				if(document.form_paiement.nb_echeance[0].checked){ // si 2 echéances
				
				mt1 = Math.round((mtg/2)*100); // passge en centimes 15.30 => 1530
				mt2 = Math.round( (mtg*100)-mt1);
				mt1 = mt1.toString(); // passage en string
				mt2 = mt2.toString(); 
				var point1 = mt1.length - 2; // 2 decimales
				var point2 = mt2.length - 2;
				if (point1 >= 0) mt1 = mt1.substring(0, point1) + "." + mt1.substring(point1); // formatage montant => 15=15.00 ou 15.3=15.30
				if (point2 >= 0) mt2 = mt2.substring(0, point2) + "." + mt2.substring(point2); 
				document.form_paiement.montant1.value = mt1;
				document.form_paiement.montant2.value = mt2;
				
				}else if(document.form_paiement.nb_echeance[1].checked){ // si 3 échéances
				
				mt1 = Math.round(mtg/3*100);
				mt2 = Math.round((mtg*100)-(mt1*2));
				mt1 = mt1.toString(); // passage en string
				mt2 = mt2.toString(); 
				var point1 = mt1.length - 2; // 2 decimales
				var point2 = mt2.length - 2;
				if (point1 >= 0) mt1 = mt1.substring(0, point1) + "." + mt1.substring(point1); // formatage montant => 15=15.00 ou 15.3=15.30
				if (point2 >= 0) mt2 = mt2.substring(0, point2) + "." + mt2.substring(point2); 
				document.form_paiement.montant1.value = mt1;
				document.form_paiement.montant2.value = mt1;
				document.form_paiement.montant3.value = mt2;
				}
		
			}else{ 
				alert("Le format du montant global n\'est pas valide (cf.exemple)");
				document.form_paiement.montant.focus();
				document.form_paiement.mt_egal.checked = false;
			}
		}else if(mtg == "") { // si le montant est vide
			alert("Le champ montant global est vide (cf.exemple)");
			document.form_paiement.montant.focus();
			document.form_paiement.mt_egal.checked = false;		
		}
	}
}

// permet d'afficher/masquer le paiement en plusieurs fois
function affich(lst){	
 var div=document.getElementById("div_modalite");
 var div1=document.getElementById("div_condition");
 var div2=document.getElementById("div_echeance");
 var div3=document.getElementById("div_mt3"); 
 if (lst.selectedIndex == 1)
  div.style.display="inline";
 else
  div.style.display="none";
  div1.style.display="none";
  div2.style.display="none";
  div3.style.display="none";
	document.form_paiement.modalite[0].checked = false;
	document.form_paiement.modalite[1].checked = false;
}

// regarde si les champs sont vides ///////////

// remet la couleur dans l'input 
function couleur(obj) {
     obj.style.backgroundColor = "#FFFFFF";
}

function check() {
	var msg = "";
	var color = "#FFFF99";
if (document.form_paiement.nature.value == "")   {
      msg += "Veuillez choisir la nature du paiement\n";
      document.form_paiement.nature.style.backgroundColor = color;
   }
if (document.form_paiement.montant.value == "")   {
      msg += "Veuillez saisir un montant\n";
      document.form_paiement.montant.style.backgroundColor = color;
   }
if (document.form_paiement.reference.value == "")   {
      msg += "Veuillez saisir une référence du dossier\n";
      document.form_paiement.reference.style.backgroundColor = color;
   }
if (document.form_paiement.nom.value == "")   {
      msg += "Veuillez saisir votre nom\n";
      document.form_paiement.nom.style.backgroundColor = color;
   }
if (document.form_paiement.ville.value == "")   {
      msg += "Veuillez saisir la ville du siège social\n";
      document.form_paiement.ville.style.backgroundColor = color;
   }
if (msg == "") return(true);
   else   {
      alert(msg);
      return(false);
   }
}
//################## fin pour le paiment  #####################################################"

/*#############################################################################################################################"*/