var menu_rubriques ;

XML_HTTP_SEPARATEUR_CHAMPS = "xxxSCxxx"
XML_HTTP_SEPARATEUR_LIGNES = "XXRCXX"

//***************************
function generer_adresse_mail(p1, p2, p3, nom_lien, objet)
{
var link;

link=p1 + '@'+ p2 + "." + p3;
objetmail = '?SUBJECT=';
objetmail+= objet ;
document.write("<a href='mailto:" + link + objetmail + "'><b>" + nom_lien + "</b></a>");
}

//***************************
function aleatoire()
{
return Math.floor(Math.random()* 100000000)+1;
}

//***************************
function remplacer_espaces(url_param)
{
url_param = url_param.replace(/ /g,"%20") ;
return(url_param) ;
}


//------------------------
function fenetre_ouvrir(src,name,w,h, parametres)
{
	var new_window, param, separ;

	param =""
	separ=""

	if (typeof(h)!='undefined' && h!="")
	{	
		param += separ + "height=" + h;
		separ=","
	}	


	if (typeof(w)!='undefined' && w!="")
	{	
		param += separ + "width=" + w;
		separ=","
	}	

	if (typeof(parametres)!='undefined' && parametres!="")
	{	
		param += separ + parametres;
		separ=","
	}	
	else
	{
		param += separ + "resizable=yes,scrollbars,locationbar=yes,status=yes";
		separ=","
	}

	new_window=window.open(src, name, param);

	return new_window ;
}


//***************************
function fenetre_fermer()
{
if(window.opener)
	try 
	{
		window.opener.focus();
	}
	catch (e) 
	{
	}

self.close();
}

//***************************
function ouvrir_edition(url)
{
var fenetre;
fenetre = fenetre_ouvrir(url, "EDITION", 400, 300) ;
return ;
}

//***************************
function fermer_edition(provenance)
{
//var fenetre_origine = opener ;
opener.document.forms[provenance].x_redirection.value = provenance ;
opener.document.forms[provenance].submit() ;
window.close();
return ;
}

//***************************
function frame_contenu_ouvrir(url)
{
parent.contenu.location.href=url;
}

//***************************
function frame_ouvrir(nom_frame,url)
{
if (!url || url=="")
	{parent.frames[nom_frame].location.reload();}
else
	{parent.frames[nom_frame].location.href=url;}

}

//***************************
function afficher_titre(partie, titre)
{
while (!parent.titre && !parent.titre.afficher_bandeau_titre );
	parent.titre.afficher_bandeau_titre(partie, titre)
}



//***********************
function effacer_titres()
{
layer_cacher("titre_page");
}


//***************************
function admin_afficher_titre(titre)
{
var html='';
//html+='<p align="center" class="pagetitre">' + titre +'</p>';

html+='<table border="0" cellPadding="0" cellSpacing="0" align="center" width="574">';
html+='<tr><td class="titregestionfilet" colspan="2"><img src="../images/img_commun/img_transp.gif" width="100%" height="1"></td></tr>';
html+='<tr><td width="25" bgcolor="#FFCB00"><img src="../images/img_commun/fleche_titre_gestion.gif" width="25" height="24"></td><td class="titregestion" width="549">' + titre +'</td></tr>';
html+='<tr><td class="titregestionfilet" colspan="2"><img src="../images/img_commun/img_transp.gif" width="100%" height="1"></td></tr></table><br>';

document.write(html);
}

//***************************
function afficher_titre_recherche(id_document_type)
{
var html='';
html+='<table border="0" cellPadding="0" cellSpacing="0" width="642"><tr><td width="23">&nbsp;</td><td>';
html+='<img src="../images/'+id_document_type+'/'+id_document_type+'_titre_recherche.gif" width="619" height="26">';
html+='</td></tr></table><br>';

document.write(html);
}

//***************************
function afficher_icone_transparente(w, h)
{
var html = '' ;
var html_w = 'width="16"' ;
var html_h = 'height="21"' ;
if (w)
	html_w = ' width = "' + w + '"'
if (w)
	html_h = ' height = "' + h + '"'
	
html+='<img src="../images/img_commun/img_transp.gif" border="0" align="absmiddle" ' + html_w + html_h + '>'
document.write(html);
}

//***************************
function admin_afficher_modifier(url)
{
var html;

html='<a href="' + url 
html+='&code='+ aleatoire() +'&operation=modifier">'
html+='<img src="../images/admin/admin_modifier.gif" border="0" alt="Modifier"  align="absmiddle"></a>'
document.write(html);
}


//***************************
function admin_afficher_supprimer(url)
{
var html;

if (url.search("#") > 0)
	{
	url=url.replace("#", "\\\'");
	alert(url);
	}
html='<a href="' + url + '">';
html+='<img src="../images/admin/admin_supprimer.gif" border="0" alt="Supprimer" align="absmiddle"></a>';
document.write(html);
}

//***************************
function admin_afficher_supprimer_param(nom_fonction, id, titre, id2, libelle)
{
var html, url, fonction;


if (nom_fonction!="")
	fonction=nom_fonction;
else 
	fonction="confirmer_suppression";


//on met un caractère d'échappement devant les paostrophes et les guillemets	
if (titre.search('"') > 0)
	{
	titre = titre.replace(/"/g, '\\\""**');	
	//alert (titre);
	}
if (titre.search("'") > 0)
	{
	// ->  /g est indispensable pour remplacer TOUTES les occurences
	titre = titre.replace(/'/g, "\\\'");	
	//alert (titre);
	}



url="javascript:" + fonction + "('" + id + "', '"  + titre + "'"; 

if (id2)
  url+=", '" + id2 + "'";

url+=");"
//alert(url);
html='<a href="' + url + '">';
//if (titre.search('"') > 0)
//	alert (html);
if(libelle && libelle.length > 0) html+=libelle;
html+='<img src="../images/admin/admin_supprimer.gif" border="0" alt="Supprimer"  align="absmiddle"></a>';
document.write(html);
}

//***************************
function ouvrir_fiche_metrologie(id_fichemetro, consultation_maj)
{
var fenetre;
var url;

url ="../fichemetros/fichemetro_fiche.asp?id_fichemetro=" + id_fichemetro;
url+='&code='+ aleatoire();
if (consultation_maj)
	url+='&consultation_maj='+consultation_maj;
fenetre = fenetre_ouvrir(url, "Fiche_Metrologique", 820, 550) ;
return ;
}


//***************************
function ouvrir_fiche_fds(id_fds, consultation_maj)
{
var fenetre;
var url;

url ="../fds/fds_fiche.asp?id_fds=" + id_fds;
url+='&code='+ aleatoire();
if (consultation_maj)
	url+='&consultation_maj='+consultation_maj;
fenetre = fenetre_ouvrir(url, "Fiche_FDS", 720, 550) ;
return ;
}

//***************************
function ouvrir_fiche_metrologie_mesures(id_fichemetro)
{
var fenetre;
var url;

url ="../fichemetro_mesures_admin/fichemetro_mesures_gerer.asp?id_fichemetro=" + id_fichemetro;
url+='&code='+ aleatoire();
fenetre = fenetre_ouvrir(url, "Fiche_Metrologique_Mesures", 820, 550) ;
return ;
}


//***************************
function ouvrir_fiche_new(id_new)
{
var fenetre, url;
url = "../news_admin/new_fiche.asp?mode=fiche&id_new=" + id_new + "&code=" + aleatoire() ;
fenetre = fenetre_ouvrir(url, "NEW", 600, 400) ;
return ;
}


//***************************
function ouvrir_lexique()
{
var fenetre;
var url;

url ="../lexique/lexique.htm";
fenetre = fenetre_ouvrir(url, "lexique", 366, 400) ;
return ;
}

//***************************
function ouvrir_aide()
{
var fenetre;
var url;

url ="../aide/aide.htm";
fenetre = fenetre_ouvrir(url, "aide", 520, 600) ;
return ;
}

//***************************
function ouvrir_impression_fast(id_fast)
{
var fenetre;
var url;

url ="../fast/fast_impression.asp?id_fast="+id_fast;
fenetre = fenetre_ouvrir(url, "fast_impression", 600, 400) ;
return ;
}

//***************************
function ouvrir_impression_fan(id_fan)
{
var fenetre;
var url;

url ="../fan/fan_impression.asp?id_fan="+id_fan;
fenetre = fenetre_ouvrir(url, "fan_impression", 600, 400) ;
return ;
}

//***************************
function ouvrir_fiche_fast(id_fast,consultation_maj)
{
var fenetre;
var url;

url ='../fast/fast_fiche_imp.asp?id_fast=' + id_fast;
url+='&code='+ aleatoire();
if (consultation_maj)
	url+='&consultation_maj='+consultation_maj;

var h = 600  ;
var w = 600 ;
var name = "FICHE_fast" ;
var src = url ;
var param = "height=" + h + ",width=" + w + ",resizable=no,scrollbars,menubar=no,toolbar=no";
// pour debug
param +=",locationbar=yes,status=yes";
fenetre=window.open(src, name, param);
//fenetre = fenetre_ouvrir(url, "FICHE_fast", 600, 600) ;
return ;
}

//***************************
function ouvrir_fiche_fan(id_fan,consultation_maj)
{
var fenetre;
var url;

url ="../fan/fan_fiche_imp.asp?id_fan=" + id_fan;
url+='&code='+ aleatoire();
if (consultation_maj)
	url+='&consultation_maj='+consultation_maj;
	
var h = 600  ;
var w = 600 ;
var name = "FICHE_FAN" ;
var src = url ;
var param = "height=" + h + ",width=" + w + ",resizable=no,scrollbars,menubar=no,toolbar=no";
// pour debug
param +=",locationbar=yes,status=yes";
fenetre=window.open(src, name, param);
	
//fenetre = fenetre_ouvrir(url, "FICHE_FAN", 600, 500) ;
return ;
}

//***************************
function ouvrir_fiche_epi(id_epi,consultation_maj)
{
var fenetre;
var url;

url ="../epi/epi_fiche_imp.asp?id_epi=" + id_epi;
url+='&code='+ aleatoire();
if (consultation_maj)
	url+='&consultation_maj='+consultation_maj;
fenetre = fenetre_ouvrir(url, "FICHE_EPI", 600, 500) ;
return ;
}

//***************************
function ouvrir_fiche_documentation(id_fichedoc,consultation_maj)
{
var fenetre;
var url;

url ="../fichedocs/fichedoc_fiche.asp?id_fichedoc=" + id_fichedoc;
url+='&code='+ aleatoire();
if (consultation_maj)
	url+='&consultation_maj='+consultation_maj;
fenetre = fenetre_ouvrir(url, "FICHE_DOC", 600, 500) ;
return ;
}

//***************************
function ouvrir_fiche_epi_type(id_epi)
{
var fenetre;
var url;

url ="../epi/epi_fiche_imp.asp?id_epi=" + id_epi;
url+='&code='+ aleatoire();
fenetre = fenetre_ouvrir(url, "FICHE_EPI_TYPE", 600, 500) ;
return ;
}

//***************************
function imprimer()
{
if (window.print)
	window.print();
else 
	{
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
//    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    
    WebBrowser1.ExecWB(6, 1);
	WebBrowser1.outerHTML = "";  
	return;
  }
return;
}

//***********************
function afficher_menu_rubriques(menu_rubriques)
{
var html="";

if (layer_adresse("menu_rubriques")==null)
	layer_creer("menu_rubriques", 120, 1, 750, 80, "visible", null);

html+=menu_rubriques ;
	
layer_ecrire_contenu("menu_rubriques", html);
layer_montrer("menu_rubriques");
}


//***************************
function ouvrir_fenetre_document_motcles(id_source, type_document, recharger_zone_xml)
{
var fenetre;
var url;
// recharger_zone_xml est <> undefined si lorsqu'on fermera la fenetre d'édition, 
// on rechargera seulement une zone donnée au lieu de recharger la page entière
// recharger_zone_xml contient le nom de cette zone

url ="../documents_motcles/document_motcles_gerer.asp?id_source=" + id_source + "&recharger_zone_xml=" + recharger_zone_xml ;
url+="&type_document="+type_document;
fenetre = fenetre_ouvrir(url, "DOCUMENT_MOTCLES", 700, 600) ;
return ;
}



//***************************
function recharger_page_dans_frame()
{
if (parent.frames.length ==0) 
	location.replace("../accueil/accueil-sante-travail-prevention.htm");
}

//-----------------------------
function nouvelle_inscription(){
	parent.frames["contenu"].location.replace("../accueil/accueil_abonnement.asp") ;
} 