// fonction permettant ecrire flash
function flash_object(url,anim,width,height,button,couleur1,couleur2,couleur3,h1){
	
	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?url='+url+'&link='+button+'&couleur1='+couleur1+'&couleur2='+couleur2+'&couleur3='+couleur3+'&h1='+h1+'">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="wmode" value="transparent">')
	document.write('<embed src="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'&couleur1='+couleur1+'&couleur2='+couleur2+'&couleur3='+couleur3+'&h1='+h1+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent">')
	document.write('</embed></object>')
}

// fonction permettant ecrire flash en %
function flash_object1(url,anim,width,height,button){

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="wmode" value="transparent">')
	document.write('<param name="movie" value="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'" /><param name="quality" value="high" />')
	document.write('<param name="salign" value="t" />')
	document.write('<embed src="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'" quality="high" salign="t" width="100%" height="100%" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
	document.write('</embed></object>')
}

 // fonction permettant ecrire flash qui reste centré tout en utilisant les 100% de la largeur de l'ecran
function flash_object2(url,anim,width,height,button){

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="wmode" value="transparent">')
	document.write('<param name="movie" value="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'" /><param name="quality" value="high" />')
	document.write('<param name="salign" value="b" />')
	document.write('<embed src="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'" quality="high" salign="b" width="100%" height="100%" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
	document.write('</embed></object>')
}

// fonction permettant ecrire flash qui reste centré tout en utilisant les 100% de la largeur de l'ecran
/*function flash_object3(url,anim,width,height,couleur1,couleur2,couleur3){
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="'+height+'" align="left">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="wmode" value="transparent">')
	document.write('<param name="movie" value="'+url+'flash/'+anim+'.swf?url='+url+'&couleur1='+couleur1+'&couleur2='+couleur2+'&couleur3='+couleur3+'" /><param name="quality" value="high" /><param name="scale" value="noscale" /><embed src="'+url+'flash/'+anim+'.swf?url='+url+'&couleur1='+couleur1+'&couleur2='+couleur2+'&couleur3='+couleur3+'" quality="high" wmode="transparent" scale="noscale" width="100%" height="'+height+'" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
	document.write('</object>')
}*/

// fonction permettant ecrire flash qui reste centré tout en utilisant les 100% de la largeur de l'ecran
function flash_object3(url,anim,width,height,couleur1,couleur2,couleur3){
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="'+height+'" id="huissier-alpes-maritimes" align="left">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="wmode" value="transparent">')
	document.write('<param name="movie" value="'+url+'flash/'+anim+'.swf?url='+url+'&couleur1='+couleur1+'&couleur2='+couleur2+'&couleur3='+couleur3+'" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="salign" value="l" /><embed src="'+url+'flash/'+anim+'.swf?url='+url+'&couleur1='+couleur1+'&couleur2='+couleur2+'&couleur3='+couleur3+'" wmode="transparent" quality="high" scale="noscale" salign="l" width="100%" align="left" height="'+height+'" name="huissier-alpes-maritimes" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
	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;
}

// 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, "")
}


//################## 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;
}

// 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);
}

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


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() {
	function reglement() {
	document.getElementById('paye_autre').value = " ";
	document.getElementById('autre').style.display='none';
}

	document.getElementById('autre').style.display='none';
}

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


