 ////
 ////
 ////  [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 = layerWindow_content.document.getElementsByTagName("head");
	
        if (headTags.length > 0)
           html += headTags[0].innerHTML;

        html += '\n</HE' + 'AD>\n<BODY>\n';
	
        var printReadyElem = layerWindow_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 win = false;
function openLayer(title, status, url, content, sizex, sizey)
{
    if(win == false)
    {
        // Windows with an URL as content
        win = new Window(
    			'layerWindow',
    			{
    			    className: 'layer',
    			    zIndex: 7000,
    			    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
    			}
			    );
    }
    
    win.setSize(sizex, sizey);
    win.setTitle(title);
    win.setStatusBar(status);
    
    
		    
    if (url != '')
    {
        win.setURL(url);
    }
    else if (content != '')
    {
        win.setHTMLContent(content);
    }
     
     
     ////  Fix some of the issues with the pring button
     //
     var minimize_div = $('layerWindow_minimize');

     minimize_div.innerHTML = 'DRUCKEN';
     addEvent2(minimize_div, 'click', print_layer_iframe);     
     
     
    win.setStatusBar(status);
    win.showCenter();
 };