/*showMessageChamp
effacerTextChamp*/


var timer = "";

function montre(id) {
	 cachetout();

	 if (document.getElementById) {
		 document.getElementById(id).style.display="block";
	 } else if (document.all) {
		 document.all[id].style.display="block";
	 } else if (document.layers) {
		 document.layers[id].display="block";
	 }
	 
	 clearTimeout(timer);
}

function cache(id) {
	
	if (document.getElementById) {
		document.getElementById(id).style.display="none";
	} else if (document.all) {
		document.all[id].style.display="none";
	} else if (document.layers) {
		document.layers[id].display="none";
	}
	   
	timer=setTimeout("cache(id)",3000);
	
}

function cachetout() {
	cache('smenuprincipal1');
	cache('smenuprincipal2');
	cache('smenuprincipal3');
}

/* Demande d'affichage d'une fenêtre au niveau du front office */
function ouvrirFenetrePlan(url, nom) {
   window.open(url, nom, "width=520,height=500,scrollbars=yes, status=yes");
}


/*
	ED : extraite de menu_services.jsp le 19/10/05
	Auteur : JSS ?

*/
function activerService() {

	var index = window.document.FORM_SERVICE.selectservices.selectedIndex;
	if( index == 0)
		return;
	var url=window.document.FORM_SERVICE.selectservices.options[index].value;

	/* Analyse target */

	var indexTarget = url.indexOf(':');
	var target =  url.substring(0,indexTarget);
	url=  url.substring(indexTarget + 1);

	if( target == "" )
		window.document.FORM_SERVICE.submit( );
	else
		window.open(url, target);

}

function activerUrl( url ) {
	window.open(url);
}


function rafraichirResultat() {

	 lien = '/servlet/com.jsbsoft.jtf.core.SG?PROC=GESTION_SERVICES&ACTION=LISTE&OBJET=NEWSGW&SELECTION=null&FROM=0&ESPACE=houat&RH=PAGELIBRE'+'&THEME='+window.document.form.THEME.options[window.document.form.THEME.options.selectedIndex].value;
  
	if (window.document.form.INCREMENT){
			lien += '&INCREMENT='+window.document.form.INCREMENT.value;
	}
	 window.location.href= lien;
}



function supprimerCodePUBLIC_VISE_DSI_RESTRICTION(indice) {
   m = window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value ;
   i = 0;
   nb = 0;
   while (nb < indice )	{
     i =  m.indexOf(';', i + 1);
	 nb++;
   }
   window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value = m.substring( 0, i );
   
   i2 =  m.indexOf(';', i + 1);
   if( i2 != -1)	{
       if( window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value.length > 0)
	  window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value = window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value + ";";
     window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value = window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value + m.substring( i2 + 1, m.length);
   }
   }
function supprimerLibellePUBLIC_VISE_DSI_RESTRICTION(indice) {
   m = window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value ;
   i = 0;
   nb = 0;
   while (nb < indice )	{
     i =  m.indexOf(';', i + 1);
	 nb++;
   }
   window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value = m.substring( 0, i );
   
   i2 =  m.indexOf(';', i + 1);
   if( i2 != -1)	{
       if( window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value.length > 0)
	  window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value = window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value + ";";
     window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value = window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value + m.substring( i2 + 1, m.length);
   }
}

function supprimerPUBLIC_VISE_DSI_RESTRICTION () {

	var index = window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.selectedIndex;
	if( index != -1)	{
		   supprimerCodePUBLIC_VISE_DSI_RESTRICTION( index);
		   supprimerLibellePUBLIC_VISE_DSI_RESTRICTION( index);
		 window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.options[ index]=null;
	}
 if(window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.options.length == 0)
      window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.options[0] = new Option("");

}

function ajouterPUBLIC_VISE_DSI_RESTRICTION () {
	var l = window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.options.length ;
	if( (l > 0) && (window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.options[ l - 1].text.indexOf('-') == 0))
    l = l - 1;

 libelleItem=""
	/* champ de saisie */
 if(window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value == window.document.forms[0].TMP_PUBLIC_VISE_DSI_RESTRICTION.value) {
   alert("Cette valeur a dÃˆj? ÃˆtÃˆ insÃˆrÃˆe.");
   return false;}

libelleItem=   window.document.forms[0].LIBELLE_TMP_PUBLIC_VISE_DSI_RESTRICTION.value;
		if( window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value.length > 0)
			window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value = window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value + ";";
		window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value = window.document.forms[0].PUBLIC_VISE_DSI_RESTRICTION.value + window.document.forms[0].TMP_PUBLIC_VISE_DSI_RESTRICTION.value;
	  /* Fin champ de saisie*/
 if( libelleItem.length > 0) { 
		window.document.forms[0].SELECT_PUBLIC_VISE_DSI_RESTRICTION.options[ l]  = new Option(libelleItem);
 libelle=window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value;
 if (libelle.length > 0) 
      libelle += ';';
 libelle += libelleItem;
 window.document.forms[0].LIBELLE_PUBLIC_VISE_DSI_RESTRICTION.value=libelle;
	}

}


function setIdProperty( id, property, value ) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
			styleObject[ property ] = value;
		}
}


function toggleRestriction(control, target){
	var controlObject = document.getElementById(control);
	if(controlObject == null ){
		return;
	}
	else {
		if(controlObject.value > 0){
			setIdProperty( target, 'display', 'table-row' );
		}
		else {
			setIdProperty( target, 'display', 'none' );
		}
	}
}

function afficherLayer(nomLayer,contenu)
{
	if (document.layers && document.layers[nomLayer] && document.layers[nomLayer]!=null){ 
    document.layers[nomLayer].text = contenu;
    } 
  else if (document.all && document.all[nomLayer]!=null){
    document.all[nomLayer].innerHTML = contenu;
    }  
		else if ( document.getElementById && document.getElementById(nomLayer)!=null ){
		document.getElementById(nomLayer).innerHTML=contenu;
    }
}

function permuterUtilisateursTableau( format ){

	var url = document.location.href;

	//on enlève éventuellement le paramètre UTILISATEURS si existe
	var indexDeb = url.indexOf("&UTILISATEURS");

	if( indexDeb != -1 ){
		indexFin = url.indexOf("&", indexDeb+1);

		if( indexFin != -1)
			url = url.substring(0, indexDeb) + url.substring(indexFin);
		else
			url = url.substring(0, indexDeb);
	}

	//ajout du paramètre
	url = url + "&UTILISATEURS="+ format;

	document.location.href = url;
}

function validerTableau( mode ){
	window.document.forms['RECHERCHE_WEB'].CODE_REDACTEUR.value = mode;
	window.document.forms['RECHERCHE_WEB'].submit();
}
