activateMenu = function(nav) {

    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}

function sDebrouilleUrlAPos(sUrl)
{
	return conciergerie.decode(sUrl);
}

function gotoUrlBrouillee(sUrl)
{
	document.location.href=sDebrouilleUrl(sUrl)
}
function sDebrouilleUrl(sUrl)

{
                sUrl = sUrl.replace(/##SLASH##/g,'/');
                sUrl = sUrl.replace(/##WWW##/g,'www.')
                sUrl = sUrl.replace(/##COM##/g,'.com')
                sUrl = sUrl.replace(/##FR##/g,'.fr')
                sUrl = sUrl.replace(/##ASP##/g,'.asp')
                sUrl = sUrl.replace(/##HTML##/g,'.html')
                sUrl = sUrl.replace(/##HTM##/g,'.htm')
                sUrl = sUrl.replace(/secureHttpProtocol/g,'https://')
                sUrl = sUrl.replace(/httpProtocol/g,'http://')
                return   sUrl 
}




	function montreDiv(identifiant)
		{
			if (testIsValidObject(document.getElementById(identifiant)))
			{
				document.getElementById(identifiant).style.display = "block"; 
			}
		}
		function masqueDiv(identifiant)
		{
			if (testIsValidObject(document.getElementById(identifiant)))
				document.getElementById(identifiant).style.display = "none"; 
		}
		
		function testIsValidObject(objToTest) {
			if (null == objToTest) {
				return false;
			}
			if ("undefined" == typeof(objToTest) ) {
				return false;
			}
			return true;
		}
		
		function masqueMontreDiv(identifiant)
		{
			if (testIsValidObject(document.getElementById(identifiant)))
			{
				if (document.getElementById(identifiant).style.display == "none" )
					montreDiv(identifiant);
				else
					masqueDiv(identifiant);
			}
		}
		
	function file(fichier)
	{
	
	if(window.XMLHttpRequest) // firefox
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	xhr_object.open("GET", fichier, false);
	
	xhr_object.setRequestHeader('Content-Type','text/html; charset=iso-8859-1');
	
	xhr_object.send(null);
	
	if(xhr_object.readyState == 4) 
		return(xhr_object.responseText);
	else 
		return(false);
		
	}
	
	function insertion(input,repdeb, repfin, addurl) {
	
  //var input = document.forms['REPLIER'].elements['texte'];
  input.focus();
/* ======================================================================== INTERNET EXPLORER */
  if(typeof document.selection != 'undefined') {  /* seul internet explorer reconnait document.selection */
    var range = document.selection.createRange();
	var insText=""; 
	insText = range.text;
	if (typeof addurl == 'undefined') addurl="";
/* 	if ((insText=="") && (addurl!="IMG__url") ) insText = addurl;*/
	
    range.text = repdeb + insText + repfin;
/*	textform = '\n'+'repfin_length : ' + repfin.length + ' et insText_length : ' + insText.length; range.text = textform;	*/

/* ==============================  Ajustement de la position du curseur */

    range = document.selection.createRange();
    if (insText.length == 0) {
		range.move('character', -repfin.length); 
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
/* ======================================================================== FIN INTERNET EXPLORER */


/* ======================================================================== NAVIGATEURS GECKO */
  else if(input.selectionStart || input.selectionStart == "0")
  {
    /* ========================================= Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = "";
	insText = input.value.substring(start, end);
	if (typeof addurl == 'undefined') addurl="";
	if ((insText=="") && (addurl!="IMG__url") ) insText = addurl;

    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* ==================================== Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
/* ======================================================================== FIN NAVIGATEURS GECKO */
input.blur();
input.focus();
return;
}

/* ======================================================================== FIN FONCTION INSERTION */

function isDate(dtStr){
	
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
function executer(scriptdata)
{
	
	eval(unescape(scriptdata))
}

function splash(sUrl)
{
	showPopWin(sUrl, 640, 480, executer);
}

//Get current time from date timestamp
function GetCurrentTime() {
	var my_current_timestamp;
	my_current_timestamp = new Date();		//stamp current date & time
	return my_current_timestamp.getTime();
	}

function initWindow()
{
	var sTemp=file('/infocontenu/checkNavigation.asp?url=' + escape(this.location.href)  + '&dumy=' + GetCurrentTime());
	if ((sTemp!='') && (sTemp!=null) && (sTemp!=false))
		this.location.href = sTemp;
}

var conciergerie = {
	
	_base16: "0A12B34C56D78E9F",
	_baseClassName:"LibCatho",

	encode: function (str)
	{
		var retour="";
		for(var i=0;i<str.length;i++)
		{
			var cc=str.charCodeAt(i);
			var ch=cc>>4;
			var cl=cc-(ch*16);
			retour+=this._base16[ch]+this._base16[cl];
		}
		return _baseClassName+retour;
	},

	decode: function (str)
	{
		var retour="";
		for(var i=0;i<str.length;i+=2)
		{
			var ch=this._base16.indexOf(str.charAt(i));
			var cl=this._base16.indexOf(str.charAt(i+1));
			retour+=String.fromCharCode((ch*16)+cl);
		}
		return retour;
	},
	
	init: function ()
	{
		var tagsA=document.getElementsByTagName("span");
		for(var i=0;i<tagsA.length;i++)
		{
			if (tagsA[i].className.substring(0,this._baseClassName.length)==this._baseClassName)
			{
				var url=this.decode(tagsA[i].className.substring(this._baseClassName.length));
				var nlink=document.createElement("a");
				nlink.href=url;
				var nbl=tagsA[i].childNodes.length;
				for(var j=0;j<nbl;j++)
				{
					nlink.appendChild(tagsA[i].childNodes[0]);
				}
				tagsA[i].appendChild(nlink);
			}
		}
	}	
}
conciergerie.init();


