﻿var windowHandle = null;

function openWindow(url) {
    windowHandle = window.open(url,'windowName');
}

function MyPopup(url)
{
    if (windowHandle != null) {
        if (!windowHandle.closed) {
            windowHandle.location.href=url;
        }
        else {
            openWindow(url);
        }
    }
    else{
        openWindow(url);
    }
    //Forcer le focus sur ce popup.  (si ce popup supporte le focus).
    if(windowHandle.window.focus){windowHandle.window.focus();}
}

function NewPopup(url){
    window.open(url);
}

function SetURLOpenerAndClose(url){
    //S'il y a un opener, mettre l'url dedans et fermer la page courante
    //sinon mettre l'url dans la page courante.
    if (window.opener){
        if (window.opener.closed){
            document.location.href=url;
        }
        else {
            window.opener.location.href=url;
            window.close();
        }
    }
    else {
        document.location.href=url;
    }
}

function MontrerCacher(ClientElementID){
    var obj = document.getElementById(ClientElementID);
    //changer le display du style de cet objet
    if (obj.style.display=='none'){
        obj.style.display='';
    }
    else {
        obj.style.display='none';
    }
}

function Montrer(ClientElementID){
    var obj = document.getElementById(ClientElementID);
    obj.style.display='';
}

function Cacher(ClientElementID){
    var obj = document.getElementById(ClientElementID);
    obj.style.display='none';
}

function openPopup(url, width, height) {
    //window.open(url, 'MyPopup', 'width='+width+',height='+ height+',scrollbars=yes');
      if (windowHandle != null) {
        if (!windowHandle.closed) {
            windowHandle.location.href=url;
        }
        else {
            openWindowParam(url, width, height);
        }
    }
    else{
        openWindowParam(url, width, height);
    }
    //Forcer le focus sur ce popup.  (si ce popup supporte le focus).
    if(windowHandle.window.focus){windowHandle.window.focus();}
}

function openWindowParam(url, width, height) {
    windowHandle = window.open(url,'windowName', 'width='+width+',height='+ height+',scrollbars=yes');
}


  




