﻿// JScript File
     var windownumber = 0;
    // stores the opened window object 
    var winMap = new Object(); 
    //winMap["TestedKey"] = "TestedValue"; 
    window.onunload = function() { 
        // try to close all child windows. 
        for(var propName in winMap) { 
            try {                 
                winMap[propName].close();  
            }catch(e) { 
                //alert(e.message); 
            }            
        } 
    }
    
 function openWin(newurl) { 
        //debugger; 
     
      var url =newurl; 
        var winName =windownumber; 
        var win; 
        win = winMap[winName]; 
        try { 
            win.focus();             
        }catch(e) { 
            // alert(e.message); 
            // we need to open a new window when the child window has not  
            // been opened or the child window has been close. 
            // as to the later, you also can implements some method that notices the parent window 
            // to remove the child window from our winMap object when it is closing. 
            // but it's a piece of hard work, i think so, because you must  
            // add the notice codes to all the child windows 
            //              
            win = window.open("https://www.e-firmen.com/E-Mail/Apply.aspx?Lang=de&KEY="+url, winName, "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=auto, resizable=yes, width=650, height=700");  
            winMap[winName] = win;  
               if (windownumber>0)
            {
            winMap[(windownumber-1)].close();
            }
            windownumber++;          
            // 
            if(!win) {  
                alert("Sorry, fail to open the window.Some unexpected error occurs.");  
            } 
            else { 
                    // i try to bind a callback function to the child window's unload event 
                    // unfortunately, it seems not to work. 
//                win.onunload = function() {  
//                    try { 
//                        alert(opener.winMap[winName]); 
//                        opener.winMap[winName] = null;  
//                        alert(opener.winMap[winName]); 
//                    } catch(e) { 
//                        // alert(e.message); 
//                    } 
//                }; 
                win.focus(); 
            } 
        }         
    }
    
    function ApplyShop(newurl) { 
        //debugger; 
     
      var url =newurl; 
        var winName =windownumber; 
        var win; 
        win = winMap[winName]; 
        try { 
            win.focus();             
        }catch(e) { 
            // alert(e.message); 
            // we need to open a new window when the child window has not  
            // been opened or the child window has been close. 
            // as to the later, you also can implements some method that notices the parent window 
            // to remove the child window from our winMap object when it is closing. 
            // but it's a piece of hard work, i think so, because you must  
            // add the notice codes to all the child windows 
            //              
            win = window.open("https://www.e-firmen.com/Shop/Apply.aspx?Lang=de&KEY="+url, winName, "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=auto, resizable=yes, width=650, height=700");  
            winMap[winName] = win;  
               if (windownumber>0)
            {
            winMap[(windownumber-1)].close();
            }
            windownumber++;          
            // 
            if(!win) {  
                alert("Sorry, fail to open the window.Some unexpected error occurs.");  
            } 
            else { 
                    // i try to bind a callback function to the child window's unload event 
                    // unfortunately, it seems not to work. 
//                win.onunload = function() {  
//                    try { 
//                        alert(opener.winMap[winName]); 
//                        opener.winMap[winName] = null;  
//                        alert(opener.winMap[winName]); 
//                    } catch(e) { 
//                        // alert(e.message); 
//                    } 
//                }; 
                win.focus(); 
            } 
        }         
    } 
    
 
    
