var asciiBack       = 8;
var asciiTab        = 9;
var asciiSHIFT      = 16;
var asciiCTRL       = 17;
var asciiALT        = 18;
var asciiHome       = 36;
var asciiLeftArrow  = 37;
var asciiRightArrow = 39;
var asciiMS         = 92;
var asciiView       = 93;
var asciiF1         = 112;
var asciiF2         = 113;
var asciiF3         = 114;
var asciiF4         = 115;
var asciiF5         = 116;
var asciiF6         = 117;
var asciiF11        = 122;
var asciiF12        = 123;
var asciiF11        = 122;

function handleEnterKeyOnForm(oEvent, defaultButtonId) 
	{
    var returnValue = true;

    //We must not override the behaviour of the enter key when the element which has the focus is a textarea or an input of type 'submit'.
	//DOM and IE does not use the same property for the control that has the focus.
    if ((oEvent.target && (oEvent.target.type != 'textarea' && oEvent.target.type != 'submit')) ||
        (oEvent.srcElement && (oEvent.srcElement.tagName.toLowerCase() != 'textarea' && oEvent.srcElement.tagName.toLowerCase() != 'submit')))
        {
        var defaultButton = document.getElementById(defaultButtonId);

        //Do nothing when the default control does not exist
        if (defaultButton == null)
            return true;

		var sKeyCode =  oEvent.keyCode ? oEvent.keyCode :
					oEvent.which ? oEvent.which : 
					void 0;


		var bIsFunctionKey = false;

		if(oEvent.charCode == null || oEvent.charCode == 0)
			{ 
			bIsFunctionKey = (sKeyCode >= asciiF2 && sKeyCode <= asciiF12) 
                            || (sKeyCode == asciiALT 
							|| sKeyCode == asciiMS 
							|| sKeyCode == asciiView
							|| sKeyCode == asciiHome
							|| sKeyCode == asciiBack
	                     	)
			}
    	

		if (!bIsFunctionKey && sKeyCode == 13)
			{
            oEvent.returnValue=false;
			oEvent.cancel = true;
    		
            //In the case of HTML anchors, we must evaluate the content of the HREF atttribute.
            //ASP.NET is always using the HREF attribute to implement its PostBack feature.
            if (typeof(defaultButton.click) != 'undefined')
                {
	            defaultButton.click();
	            returnValue = false;
                }
            else
                {
                if (defaultButton.tagName.toUpperCase() == 'A')
                    {
	                eval(defaultButton.href);
                    returnValue = false;
                    }
                else
                    {
                    returnValue = true;
                    }
                }

            }

            //If the Enter is handled, we must prevent event from bubbling
            if (!returnValue)
            {
	        oEvent.cancelBubble = true;
	        if (oEvent.stopPropagation) oEvent.stopPropagation();

            oEvent.returnValue=false;
            oEvent.cancel = true;
            }
		}
    return returnValue;
	}
							
//----------------------------------------------------------
// Méchanisme utilisée pour attacher un ou plusieurs événements
// à un élément HTML
//----------------------------------------------------------
function addEvent(elm, evType, fn, useCapture)
{
    //Credit: Function written by Scott Andrews
    //(slightly modified)

    var ret = 0;

    if (elm.addEventListener) //DOM 2 method to attach multiple events to an object
    {
        ret = elm.addEventListener(evType, fn, useCapture);
    }

    else 
    {
        if (elm.attachEvent) //IE specific method
        {
            ret = elm.attachEvent('on' + evType, fn);
        }
        else
        {
            elm['on' + evType] = fn;
        }
    }
    return ret;
}


function replaceAll( str, from, to ) 
	{
	var idx = str.indexOf( from );
	while ( idx > -1 ) {
	        str = str.replace( from, to ); 
	        idx = str.indexOf( from );
	            }
	return str;
	}
	    

function popup(e)
	{
	var adrSource
	var popup = "true";
	
	//Le e.Target est utilisé lorsque le browser supporte le DOM2
	//Le e.srcElement existe uniquement du côté de IE
	var eventSource = (e.target ? e.target : e.srcElement);
		
	var returnValue = true;

	//Vérifie si le tag de l'évènement est bien un <A HREF=...>, un élément AREA ou une image incluse dans un Anchor
	if((eventSource.tagName == "A" || eventSource.tagName == "AREA" || (eventSource.tagName == "IMG" && eventSource.parentNode.tagName == "A")))
		{
		//Prends la source du HREF

		
		if (eventSource.tagName == "IMG" && eventSource.parentNode.tagName == "A")		
		{
			adrSource = eventSource.parentNode.href;
		}
		else
		{
			adrSource = eventSource.href;
		}

		//Si le lien pointe sur la recherche de MondoSearch, on n'intercepte pas le clique
		if (adrSource == '' || adrSource.indexOf('MsmGo.exe') != -1)
			return true;
			
			
		if (adrSource != '')
		{		
			var cpt=0;
			for (i = 0 ; i < adrVerif.length; i++)
			{		
				var t = adrVerif[i];
				var index = adrSource.indexOf(t);
				if (index >= 0)
				{				   				
				   cpt++;
				   break;
				}
				
			}			
			if (cpt == 0)
			{
				lePopup = window.open('','popup','');
				lePopup.document.write('<html><head></head><frameset rows="85,*"><frame SRC="' + location.protocol + '//'+ location.host + '/refonte_internet_ita/divers/hautQuit.aspx?urlBas=' + replaceAll(replaceAll(adrSource,'&','°'),"'","\'") + '&urlHaut=' + replaceAll(replaceAll(this.location.href,'&','°'),"'","\'") + '" NAME="header" scrolling="no" marginheight="0" marginwidth="0"><frame scrolling="AUTO"  name="main" SRC="' + adrSource + '"></frameset></html>');
				lePopup.document.close();

                returnValue = false;
			}
		}
	}

    //If the Enter is handled, we must prevent event from bubbling
    if (!returnValue)
    {
		e.cancelBubble = true;
		e.returnValue=false;
		e.cancel = true;

		if (e.stopPropagation) 
		{
			e.stopPropagation();
		}

  		if (e.preventDefault)
  		{
    		e.preventDefault(); // DOM style		
    	}

    }
}


function deselectionnerCaseACocher(idControles)
	{

	//Parcours tous les contrôles par leur ID
	for (i = 0; i < idControles.length; i ++)
		{
		//Obtient un pointeur sur le contrôle
		var ctl = document.getElementById(idControles[i]);
		
		//Vérifie son existence. Si inconnu, on quitte la présente fonction
		if (ctl == null)	
			{
			return;
			}
		
		ctl.checked = false;
		
		}
	}