function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

var r={
  'notnumbers':/[^\d]/g
}

function valid(o,w){
  o.value = o.value.replace(r[w],'');
}

window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('sderoulant'+i)) {document.getElementById('sderoulant'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function affichetype(ch){
var type = document.getElementById(ch);
type.value='';
for (i=1;i<8;i++){
	coch_type = document.getElementById('coch_type'+i);
	if (coch_type.checked) {
		if (type.value!=''){
			type.value += ', ';
		}
		type.value += ''+coch_type.title+'';
	}
}
}

function affichepieces(ch){
var pieces = document.getElementById(ch);
pieces.value='';
for (i=1;i<6;i++){
	coch_pieces = document.getElementById('coch_pieces'+i);
	if (coch_pieces.checked) {
		if (pieces.value!=''){
			pieces.value += ', ';
		}
		pieces.value += ''+coch_pieces.title+'';
	}
}
}

function verifSelect() {

				// on selectionne les checkbox all et allsecteurstras puis le champ text
				var checkboxSelectall = document.getElementById('coch_selectall');
				var checkboxSelectallsecteurstras = document.getElementById('coch_selectallsecteurstras');
				var secteur = document.getElementById('secteur');
				secteur.value='';
				
				// on selectionne les checkbox secteurstras et secteurgeo
				var boxSecteurgeo = document.getElementsByName('secteurgeo[]');
				var boxSecteurstras = document.getElementsByName('secteurgeo[] ');
				var boxSecteurgeoCount = 0, boxSecteurstrasCount = 0; // initialisations de compteurs			

				// Pour chaque checkbox secteurgeo on regarde s'il est coché ou non afin de rajouter sa valeur dans le champ text
				for ( var i=0; i < boxSecteurgeo.length; i++ ) {
					if ( boxSecteurgeo[i].checked ) {
						if (secteur.value!='') secteur.value += ', ';
						secteur.value += ' '+boxSecteurgeo[i].title+' ';
						boxSecteurgeoCount ++;
					}
				}

				// On verifie si toutes les checkbox secteurgeo sont coché ou non
				if ( boxSecteurgeoCount == boxSecteurgeo.length ) 	allSecteurgeoSelected = true;
				else 										allSecteurgeoSelected = false;

				// Pour chaque checkbox secteurstras on regarde s'il est coché ou non afin de rajouter sa valeur dans le champ text
				for ( var i=0; i < boxSecteurstras.length; i++ ) {
					if ( boxSecteurstras[i].checked ) {
						if (secteur.value!='') secteur.value += ', ';
						secteur.value += ' '+boxSecteurstras[i].title+' ';
						boxSecteurstrasCount ++;
					}
				}

				// On verifie si toutes les checkbox secteurstras sont coché ou non
				if ( boxSecteurstrasCount == boxSecteurstras.length ) allSecteurstrasSelected = true;
				else 								allSecteurstrasSelected = false;				

				// Si toutes les checkbox sont cochées les checkbox all et allsecteurstras doivent l'être aussi, 

				// si toutes les checkbox secteurstras sont cochées le checkbox allsecteurstras doit l'être aussi,

				// sinon aucune ne doit être cochées
				if ( allSecteurstrasSelected && allSecteurgeoSelected ) {
					checkboxSelectall.checked = true;
					checkboxSelectallsecteurstras.checked = true;
				}

				else if ( allSecteurstrasSelected ) {
					checkboxSelectall.checked = false;
					checkboxSelectallsecteurstras.checked = true;
				}

				else {
					checkboxSelectall.checked = false;
					checkboxSelectallsecteurstras.checked = false;
				}
			}

			function selectall() {
				var checkboxSelectall = document.getElementById('coch_selectall');
				var checkboxSelectallsecteurstras = document.getElementById('coch_selectallsecteurstras');
				var boxSecteurgeo = document.getElementsByName('secteurgeo[]');
				var boxSecteurstras = document.getElementsByName('secteurgeo[] ');

				// si le checkbox all est coché on coche tous les checkbox !! (secteurstras et secteurgeo)
				if (checkboxSelectall.checked) {
					for ( i=0; i < boxSecteurgeo.length; i++ ) boxSecteurgeo[i].checked = true;
					for ( i=0; i < boxSecteurstras.length; i++ ) boxSecteurstras[i].checked = true;
					checkboxSelectallsecteurstras.checked = true; // si tout est coché le checkbox allsecteurstras aussi ...

				} else {
					for ( i=0; i < boxSecteurgeo.length; i++ ) boxSecteurgeo[i].checked = false;
					for ( i=0; i < boxSecteurstras.length; i++ ) boxSecteurstras[i].checked = false;
					checkboxSelectallsecteurstras.checked = false;
				}

				// Lancement de la vérification pour affichage du texte et complément sur les all et allsecteurstras
				verifSelect();
			}
			
			function selectallsecteurstras() {
				var checkboxSelectall = document.getElementById('coch_selectall');
				var checkboxSelectallsecteurstras = document.getElementById('coch_selectallsecteurstras');
				var boxSecteurstras = document.getElementsByName('secteurgeo[] ');

				// si le checkbox allsecteurstras est coché on coche tous les checkbox secteurstras !!
				if (checkboxSelectallsecteurstras.checked) {
					for ( i=0; i < boxSecteurstras.length; i++ ) boxSecteurstras[i].checked = true;

				} else {	
					for ( i=0; i < boxSecteurstras.length; i++ ) boxSecteurstras[i].checked = false;
					checkboxSelectall.checked = false; // si le checkbox allsecteurstras est décoché le all n'est plus actif
				}

				// Lancement de la vérification pour affichage du texte et complément sur les all et allsecteurstras
				verifSelect();
			}

i9 = new Image();
i9.src = "styles/defaut/bt_imprimer_02.png";
i10 = new Image();
i10.src = "styles/defaut/bt_localiser_02.png";
i11 = new Image();
i11.src = "styles/defaut/bt_envoyez_02.png";
i12 = new Image();
i12.src = "styles/defaut/bt_selection_02.png";
i16 = new Image();
i16.src = "styles/defaut/barre_titre1_hover.png";
i20 = new Image();
i20.src = "_frame/small-photo-default.jpg";
