// Internet Mornay V2 01/09/2005 ManuCz

var Sp=20;
var Hauteur=37;
var Etat=new Array();
var Rub=0;
var Stop=0;
var Slide_ani=0;

var Start
var Count
var TotalHits
var Query1
var Query2
var Query3

Univers = (Univers) ? Univers : 'createur';


var DOM=((document.createRange&&(document.createRange().createContextualFragment))?1:0);

if (document.images) {
    imageon = new Image();
    imageon.src  = '/DSM/Qui.nsf/Alias/sel_files/$File/fleche_' + Univers + '_on.gif';
    imageoff = new Image();
    imageoff.src = '/imgweb/fleche_off.gif'; }


if (DOM == 1) {
	fle1 = new Image();
	fle2 = new Image();
	fle3 = new Image();
	fle4 = new Image();
	fle5 = new Image();
	fle6 = new Image();
	fle7 = new Image();
	fle8 = new Image();
	m1 = new Object();
	mm1 = new Object();
	m2 = new Object();
	mm2 = new Object();
	m3 = new Object();
	mm3 = new Object();
	m4 = new Object();
	mm4 = new Object();
	m5 = new Object();
	mm5 = new Object();
	m6 = new Object();
	mm6 = new Object();
	m7 = new Object();
	mm7 = new Object();
	m8 = new Object();
	mm8 = new Object(); }

// ********************** DEBUT GESTION MENUS DYNAMIQUES ********************
var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var w3 = (document.getElementById)? true:false
var head=1;

var yIdx=142;
tabht=new Array();
tabid=new Array();
var activeSubLayer=-1;

var itab=0;
function changeImage(num,ext) {
	if (DOM == 1) { image = eval('fle'+num);
		document.images['fle'+num].src = eval('image' + ext + '.src'); }
	else if (ns4 == 1) {
		document['m'+num].document['fle'+num].src = eval('image' + ext + '.src'); }
	else if (ie4 == 1) { image = eval('fle'+num);
		image.src = eval('image' + ext + '.src');
	} }
//id ='mxxx'
//yPrec 0 si non principal, hauteur courante sinon
//htCurrent hauteur du courant
function MoveTo(id,yPrec,htCurrent){
	if ((Num==1) && (Num!=id))
		Num=id.replace(/m+/,'');//récupère le numéro du layer	
	tabid[itab] =id;
	tabht[itab] = htCurrent;
	itab++;
	var Obj;
	  if (ns4) { Obj = document.layers[id] }
	  else if( w3) { Obj = document.getElementById(id).style }
	  else { Obj = document.all[id] }

	Obj.xpos = 0;
	Obj.left = Obj.xpos;
	Obj.ypos = yIdx;
	yIdx = yIdx + yPrec;
	Obj.top = Obj.ypos;
}
//aDyn (nb)
//Permet d'afficher l'ensemble des layers du menu dynamique 
//en étendant ou pas le layer 'nb'
function aDyn(nb){
	/*
	if ((activeSubLayer!=-1) && (activeSubLayer!=nb)){
		changeImage(activeSubLayer,'off');
		}
	*/

	yinit=142;	
	for (i=0 ; i <tabid.length ; i++){
			if (ns4) { Obj = document.layers[tabid[i]] }
		  		else if( w3) { Obj = document.getElementById(tabid[i]).style }
  					else { Obj = document.all[tabid[i]] }
			Obj.top = yinit;						
			//si SubLayer a afficher
			if ((tabid[i] == 'mm'+nb) || (tabid[i].lastIndexOf("m")==0)){
				//Gère l'ouverture et la fermeture d'un même niveau.
				if ((tabid[i] == 'mm'+nb) && (activeSubLayer==nb)){
					Obj.visibility = "hidden";//si on reclique sur le courant

				}else {				
					Obj.visibility = "visible";
					//changeImage(nb,'on');
					
					yinit = yinit+tabht[i];
				}
			}else{
				Obj.visibility = "hidden";
			}					

	}	

	if (typeof Num !='undefined'){//si un num est précisé on allume le bouton correspondant
		changeImage(Num,'on');
	}else{
		if (activeSubLayer!=-1) 
			changeImage(activeSubLayer,'off');		
		else
			changeImage(nb,'on');
	}	

	if (activeSubLayer == nb){
		activeSubLayer = -1;		
	}else{
		activeSubLayer = nb;
	}


}

// ********************** FIN GESTION MENUS DYNAMIQUES ********************

// Functions

//////// GoSearch()
function GoSearch() {
var Query = document.SearchForm.QueryField.value ;
if( (Query != '') && ((Query != '*')) ) { 
	Query = escape( Query );
	Query = '/DSM/DS.nsf/SearchResults?SearchDomain&Query=' + Query + '&SearchOrder=1&SearchWV=TRUE&SearchThesaurus=FALSE&SearchFuzzy=FALSE&Start=1&Count=10&SearchEntry=DetailedResultEntry&Scope=1'
	document.location.href = Query;
	}
}

//////// OW(Url)
function OW(Url) {
Win = window.open( Url, 'Win', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=640, height=430' )
Win.focus()
}

//////// OW2(Url)
function OW2(Url) {
Win = window.open( Url, 'Win', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=750, height=600' )
Win.focus()
}

//////// OW3(Url)
function OW3(Url) {
Win = window.open( Url, 'Win', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=750, height=750' )
Win.focus()
}

//////// PagePicker()
function PagePicker() {
//alert( TotalHits + Start + Count )
if( TotalHits == '' )  document.write( '<!-- Totall hits empty -->' )
else if( TotalHits < Count ) document.write( '<!-- TotalHits < Count -->' )
else {
    document.write('<center>')
    var j
    var i = Start - Count
    if( i < 1 ) i = 1
    if( Start > 1 ) document.write( '<a href="' + Query1 + '&Start=' + i + Query2 + '&Count=' + Count + Query3 + '">Pr&eacute;c&eacute;dent</a>' )
        else document.write('Pr&eacute;c&eacute;dent')
    if( TotalHits > Count )
        {
        var max = Math.ceil( TotalHits / Count )
        for( i=1; i <= max; i++ )
            {
            j = 0
            j = (i-1) * Count + 1
            if( j == Start ) document.write( ' <font color=red>' + i + '</font>' )
                else document.write( ' <a href="' + Query1 + '&Start=' + j + Query2 + '&Count=' + Count + Query3 + '">' + i + '</a>' )
            }
        }
    var i = Start + Count
    if( TotalHits >= Start + Count ) document.write( ' <a href="' + Query1 + '&Start=' + i + Query2 + '&Count=' + Count + Query3 + '">Suivant</a>' )
        else document.write(' Suivant')
    document.write('</center><br>')
} }

//////// initPagePicker(Query)
function initPagePicker(Query) {
Query = Query.substring( Query.indexOf('/') )
Start = Query.indexOf( '&Start=' )
Count = Query.indexOf( '&Count=' )
if( Start < Count )
  {
  Query1 = Query.substring( 0, Start )
  Query2 = Query.substring( Start +1, Count )
  if( Query2.indexOf( "&" ) <= 0 ) Query2 = ''
    else Query2 = Query2.substring( Query2.indexOf( "&" ) )
  Query3 = Query.substring( Count + 7 )
  if( Query3.indexOf( "&" ) <= 0 ) Query3 = ''
    else Query3 = Query3.substring( Query3.indexOf( "&" ) )
} else {
  Query1 = Query.substring( 0, Count )
  Query2 = Query.substring( Count +1, Start )
    if( Query2.indexOf( "&" ) <= 0 ) Query2 = ''
    else Query2 = Query2.substring( Query2.indexOf( "&" ) )
  Query3 = Query.substring( Start +7 )
    if( Query3.indexOf( "&" ) <= 0 ) Query3 = ''
    else Query3 = Query3.substring( Query3.indexOf( "&" ) )
}
//alert( "Start " + Start + " Count " + Count + "\nQuery1 : " + Query1 + "\nQuery2 : "+ Query2 + "\nQuery3 : " + Query3 )
Start = Number( GetParam( Query, 'Start' ) )
Count = Number( GetParam( Query, 'Count' ) )
}



// Utilitaires

// Suppression des espaces sur-numéraires
//////// trim(value)
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = /  /g;
   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}

//////// GetParam( query, paramname )
function GetParam( query, paramname ) {
var param='&'+paramname.toLowerCase()+'='
var pos=query.toLowerCase().indexOf(param)
if( pos > -1 ) {
var value=query.substring(pos+param.length)
pos = value.indexOf('&')
if(pos > 0) value=value.substring(0,pos)
return unescape(value)
} }


function ChangeRadio(posi) {

	document.SearchForm.search[posi].checked=true ;
   }
//DEBUT -------------------------- ANCIENNES FONCTIONS ET VARIABLES A ENLEVER A L'ISSUE DE LA MIGRATION -----------------
var NS=(document.layers) ? 1 : 0;
var IE=(document.all)  ? 1 : 0;
if (typeof nbMenu !='undefined'){
	for(i=1;i<nbMenu;i++){Etat[i]="off";}
}
function aNS(i){if(NS==1){Anim(i);}}
function aIE(i){if(IE==1){Anim(i);}if(DOM==1){Anim(i);}}

function Anim(i){
if( ht.length > 0 ) {
if(Slide_ani==0){
	if(Rub!=0){
		Stop=1;
		imgAnim=i;
		animOff(Rub,imgAnim);
		} else {
		imgAnim=i;
		animOn(imgAnim,0); } } } }
function animOn(c){
	Slide_ani=1;
    for(i=c+1;i<nbMenu+1;i++){
        if(IE && document.all['m'+c]){document.all['m'+i].style.top=parseInt(document.all['m'+i].style.top) + ht[c];}
        if(NS && document['m'+c]){document['m'+i].top=parseInt(document['m'+i].top) + ht[c];}
        if(DOM && document.getElementById('m'+c)){document.getElementById('m'+i).style.top=parseInt(document.getElementById('m'+i).style.top) + ht[c];}
    }
	if(IE && document.all['m'+c]){document.all['mm'+c].style.visibility="visible";}
	if(NS && document['m'+c]){document['mm'+c].visibility="visible";}
	if(DOM && document.getElementById('m'+c)){document.getElementById('mm'+c).style.visibility="visible";}

	Etat[c]="on";Rub=c;Slide_ani=0; }

function animOff(c,Slide_s){    
	Slide_ani=1;
	if(IE && document.all['m'+c]){document.all['mm'+c].style.visibility="hidden";}
	if(NS && document['m'+c]){document['mm'+c].visibility="hidden";}
	if(DOM && document.getElementById('m'+c)){document.getElementById('mm'+c).style.visibility="hidden";}
	
    for(i=c+1;i<nbMenu+1;i++){
        if(IE && document.all['m'+c]){document.all['m'+i].style.top=parseInt(document.all['m'+i].style.top) - ht[c];}
        if(NS && document['m'+c]){document['m'+i].top=parseInt(document['m'+i].top) - ht[c];}
        if(DOM && document.getElementById('m'+c)){document.getElementById('m'+i).style.top=parseInt(document.getElementById('m'+i).style.top) - ht[c];}
    }
    	Etat[c]="off";Slide_ani=0;Rub=0;Stop=0;
		if (c!=Slide_s) {
			imgAnim=Slide_s;
			animOn(imgAnim,0);
 } }

function change(num,ext) {
	if (DOM == 1) { image = eval('fle'+num);
		document.images['fle'+num].src = eval('image' + ext + '.src'); }
	else if (NS == 1) {
		document['m'+num].document['fle'+num].src = eval('image' + ext + '.src'); }
	else if (IE == 1) { image = eval('fle'+num);
		image.src = eval('image' + ext + '.src');
	} }

function Menu(num) {
	if( ht.length > 0 ) {
	for(j=1;j<=(nbMenu-1);j++){
		change(j,'off')
		}
	for(i=1;i<nbMenu;i++){
		if(Etat[i] == "on" && Stop==0) {Anim(i);}
		} }
		change(num,'on'); }

//FIN -------------------------- ANCIENNES FONCTIONS ET VARIABLES A ENLEVER A L'ISSUE DE LA MIGRATION -----------------


