 ////
 ////
 ////  [yak]: adding a simple wrapper function
 ////
 ////


 
 function addEvent2(el, evname, func)
 {
     if (el.attachEvent)
     { // IE
         el.attachEvent("on" + evname, func);
     }
     else if (el.addEventListener)
     { // Gecko / W3C
         el.addEventListener(evname, func, true);
     }
     else
     {
         el["on" + evname] = func;
     }
 };



 var gAutoPrint = true; // Flag for whether or not to automatically call the print function

 function print_layer_iframe()
 {
    if (document.getElementById != null)
    {
        var html = '<HTML>\n<HEAD>\n';

        var headTags = layerWindow2_content.document.getElementsByTagName("head");
	
        if (headTags.length > 0)
           html += headTags[0].innerHTML;

        html += '\n</HE' + 'AD>\n<BODY>\n';
	
        var printReadyElem = layerWindow2_content.document.getElementById("printReady");

        if (printReadyElem != null)
        {
            var myregexp = new RegExp("<script[^>]*?>.*?<\\/script>", "ig");

            result = printReadyElem.innerHTML.replace(myregexp, '');
            html  += result;
        }
        else
        {
            alert("Could not find the printReady section in the HTML");
            return;
        }

        html += '\n</BO' + 'DY>\n</HT' + 'ML>';


        var printWin = window.open("","printSpecial");
        printWin.document.open();
        printWin.document.write(html);
        printWin.document.close();

        if (gAutoPrint)
            printWin.print();
    }
    else
    {
        alert("Sorry, the print ready feature is only available in modern browsers.");
    }
 }
 
 
 




 var layerWindow;
 function openLayer(title, status, url, content, sizex, sizey)
 {
     if (layerWindow)
     {
         layerWindow.destroy();
     }
     
     //// use 'url' or 'content'
     //
     layerWindow = new Window
     (
         'layerWindow',
         {
             className: 'dialog',
             width: sizex,
             height: sizey,
             zIndex: 100,
             resizable: true,
             title: title,
             showEffect:Effect.BlindDown,
             hideEffect:Element.hide,
             draggable: true,
             wiredDrag: true,
             minimizable: false,
             maximizable: false
         }
     );


     if (url != '')
     {
         layerWindow.setURL(url);
     }
     else if (content != '')
     {
         layerWindow.setHTMLContent(content);
     }

     layerWindow.setStatusBar(status);
     layerWindow.showCenter();
     layerWindow.setDestroyOnClose();
 };



 var win2 = false;
function openLayer2(title, status, url, content, sizex, sizey)
{
    if(win2 == false)
    {
        // Windows with an URL as content
        win2 = new Window(
    			'layerWindow2',
    			{
    			    className: 'layer2',
    			    zIndex: 101,
    			    resizable: true,
    			    draggable: true,
    			    wiredDrag: true,
    			    minimizable: true,
    			    maximizable: false,
    			    
    			    showEffect:Effect.BlindDown,
    			    hideEffect:Element.hide,
    			    
    			    //  yak, hack to get the "print" button working
    	    		    disable_minimize_onClick: true
    			}
			    );
    }
    
    win2.setSize(sizex, sizey);
    win2.setTitle(title);
    win2.setStatusBar(status);
    
    
		    
    if (url != '')
    {
        win2.setURL(url);
    }
    else if (content != '')
    {
        win2.setHTMLContent(content);
    }
     
     
     ////  Fix some of the issues with the pring button
     //
     var minimize_div = $('layerWindow2_minimize');

     minimize_div.innerHTML = 'PRINT';
     addEvent2(minimize_div, 'click', print_layer_iframe);     
     
     
    win2.setStatusBar(status);
    win2.showCenter();
//    win2.setDestroyOnClose();
 };