var version = 0;
var Ie      = false;
var Ns      = true;


function setBrowserId()
  {

    var v_NavVersionA   = (navigator.appVersion).split(" ");
    var v_count = 0;

    for (v_count=0;v_count<v_NavVersionA.length;v_count++)
      if (v_NavVersionA[v_count] == "MSIE")
        {
          Ie = true;
          Ns = false;
        }

    version = Number(v_NavVersionA[0]);
  }


function openWinPopup( pURL, pWidth, pHeight, pGetHandle, pLeft, pTop, pDir, pLoctn, pMenuBar, pReszb, pScrlb, pStats, pToolb ) {

    if (version==0)
        setBrowserId();
    var attribs = "width=" + pWidth + ",height=" + pHeight +
                  ( ( Ie ) ? ",left=" + pLeft : ",screenX=" + pLeft ) +
                  ( ( Ie ) ? ",top=" + pTop : ",screenY=" + pLeft ) +
                  ",directories="+pDir+",location="+pLoctn+",menubar="+pMenuBar+",resizable="+pReszb+",scrollbars="+pScrlb+",status="+pStats+",toolbar="+pToolb;

    var handle = window.open( pURL, "", attribs );

    if ( pGetHandle ) {
        return handle;
    }
}


function openWinPopupTargt( pURL, pTarget, pWidth, pHeight, pGetHandle, pLeft, pTop, pDir, pLoctn, pMenuBar, pReszb, pScrlb, pStats, pToolb ) {

    if (version==0)
        setBrowserId();
    var attribs = "width=" + pWidth + ",height=" + pHeight +
                  ( ( Ie ) ? ",left=" + pLeft : ",screenX=" + pLeft ) +
                  ( ( Ie ) ? ",top=" + pTop : ",screenY=" + pLeft ) +
                  ",directories="+pDir+",location="+pLoctn+",menubar="+pMenuBar+",resizable="+pReszb+",scrollbars="+pScrlb+",status="+pStats+",toolbar="+pToolb;

    var handle = window.open( pURL, pTarget, attribs );
    handle.focus();

    if ( pGetHandle ) {
        return handle;
    }
}

function popup(mypage,myname,w,h,scroll,menubar){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes,menubar='+menubar+',toolbar=no,directories=no,statut=no,location=no,status=no'

	win = window.open(mypage,myname,settings)
	if( win.focus ) {
		win.focus();
	}
}

function openWindow( pURL, pAttribs, pGetHandle ) {

    var handle = window.open( pURL, "", pAttribs );

    if ( pGetHandle ) {
        return handle;
    }
}

/*
 *  This function opens a new variable form popup window for Web.
 *
 *  @param pURL A String object representing the URL to load in the popup window
 *  @param pWidth A integer representing the width of the popup window
 *  @param pHeight A integer representing the height of the popup window
 *  @param pGetHandle A boolean identifying whether or not the user wants the window handle
 *  @param pLeft A integer representing the left position of the popup window
 *  @param pTop A integer representing the top position of the popup window
 *  @param [pPopupName] A String object representing the popup's window name
 *  @param [pScrollBar] A boolean identifying wheter or not the user wants to show the menu bar
 *  @param [pStatus] A boolean identifying wheter or not the user wants to show the status bar
 *  @param [pResizable] A boolean identifying wheter or not the user wants to enabled resize
 *  @return The window handle is returned if pGetHandle is set to true
 */
function openFormPopup( pURL, pWidth, pHeight, pGetHandle, pLeft, pTop, pPopupName, pScrollBar, pStatus, pResizable ) {

    setBrowserId();
    var scrollBar = ( pScrollBar == null ) ? "yes" : ( pScrollBar ) ? "yes" : "no";
    var showStatus = ( pStatus == null ) ? "no" : ( pStatus ) ? "yes" : "no";
    var letResize = ( pResizable == null ) ? "no" : ( pResizable ) ? "yes" : "no";
    var attribs = "width=" + pWidth + ",height=" + pHeight +
                  ( Ie ? ",left=" + pLeft : ",screenX=" + pLeft ) +
                  ( Ie ? ",top=" + pTop : ",screenY=" + pLeft ) +
                  ",directories=no,location=no,menubar=no,resizable=" + letResize + ",scrollbars=" + scrollBar + ",status=" + showStatus + ",toolbar=no,titlebar=no";

    var handle = window.open( pURL, ( pPopupName != null ) ? pPopupName : "", attribs );

    if ( pGetHandle ) {
        return handle;
    }
}

/*
 *  This function opens a new standardized popup window.
 *
 *  @param pURL A String object representing the URL to load in the popup window
 *  @param pWidth A integer representing the width of the popup window
 *  @param pHeight A integer representing the height of the popup window
 *  @param pGetHandle A boolean identifying whether or not the user wants the window handle
 *  @param pLeft A integer representing the left position of the popup window
 *  @param pTop A integer representing the top position of the popup window
 *  @param [pPopupName] A String object representing the popup's window name
 *  @param [pScrollBar] A boolean identifying wheter or not the user wants to show the menu bar
 *  @param [pStatus] A boolean identifying wheter or not the user wants to show the status bar
 *  @param [pResize] A boolean identifying wheter or not the user wants to resize the popup window
 *  @return The window handle is returned if pGetHandle is set to true
 */
function openPopup( pURL, pWidth, pHeight, pGetHandle, pLeft, pTop, pPopupName, pScrollBar, pStatus, pResize ) {

   setBrowserId();
    var scrollBar = ( pScrollBar == null ) ? "yes" : ( pScrollBar ) ? "yes" : "no";
    var showStatus = ( pStatus == null ) ? "no" : ( pStatus ) ? "yes" : "no";
    var letResize = ( pResize == null ) ? "no" : ( pResize ) ? "yes" : "no";
    var attribs = "width=" + pWidth + ",height=" + pHeight +
                  ( ( Ie ) ? ",left=" + pLeft : ",screenX=" + pLeft ) +
                  ( ( Ie ) ? ",top=" + pTop : ",screenY=" + pLeft ) +
                  ",directories=no,location=no,menubar=no,resizable=" + letResize + ",scrollbars=" + scrollBar + ",status=" + showStatus + ",toolbar=no";

    var handle = window.open( pURL, ( pPopupName != null ) ? pPopupName : "", attribs );

    if ( pGetHandle ) {
        return handle;
    }
}

function pop()
{
    var myAs = document.getElementsByTagName('a');
    for (var a = 0; a < myAs.length; ++a) {
        // Si le lien a une classe de type pop
        if (myAs[a].className == 'pop') {
            // on extrait l'id de la popup à partir du href
            var pop = document.getElementById(myAs[a].href.substring(myAs[a].href.lastIndexOf('#') + 1));
            // si la popup existe on l'affiche (display block)
            if (pop) {       
                pop.style.display = 'none';
                myAs[a].onclick = function() {
                    thisPopup = document.getElementById(this.href.substring(this.href.lastIndexOf('#') + 1))
                    thisPopup.style.display = (thisPopup.style.display == 'none') ? 'inline' : 'none';
                    return false;
                };
                // on efface la popup en cliquant dessus
                pop.onclick = function()
                {
                    this.style.display = 'none';
                };
            }
        }
    }
}