Can I call a panel from another panel

I have a structure like this:

Addon Directory
    index.js
Data Directory
   panel1.html
   panel1.js
   panel2.html
   panel2.js

I defined panel1 and panel2 in the index.js. I attached panel1 to the toolbar button. panel1.html contains a link that should fire panel2.html.

The problem is:
When I call panel2.show() inside panel1.js, I get this error: panel2.show is not a function
This is the code:

var geLink= document.getElementById("mylink");
getLink.addEventListener('click', function (event)
            {
               console.log("link clicked");
                panel2.show();
                },false);

How to fire panel2 from panel1? is this possible?

I get that the show method can not be invoked from outside the main addon script. So, what is the right logic to show panel2 when a link in panel1 is clicked? Is it by using using window.open() ?

How can I tell thepanel2 script to not get executed until the panel2.html window is opened? because when I tried it, the panel2 script get executed nefore I click the link in panel1 and before the panel2.html page opnes.

Another problem that makes window.open(panel2.html) is not a good solution is that I want to pass variable from index.js to panel2.js. Therefore, I need to define it as a panel in index.js. But the problem is I can not open it through panel1.js.

panel1 can message the background script and then the background script can open panel2. Wouldn’t that work in your case?