var gAutoPrint = true; // Flag for whether or not to automatically call the print function
var gPrintAll = true; // Flag if not printReady section, print all

function printSpecial(frmName)
{
        if (document.getElementById != null)
        {
                var html = '<HTML>\n<HEAD>\n';

                if (document.getElementsByTagName != null)         {
                        top.frames[frmName].focus();
                        var headTags = top.frames[frmName].document.getElementsByTagName("head");
                        if (headTags.length > 0) {
                           html += headTags[0].innerHTML; }
                }

                html += '\n</HE' + 'AD>\n<BO' + 'DY ';
                if (gAutoPrint) {
                    html += 'onLoad="self.print();self.close();return true"';
                }
                html += '>\n';

                top.frames[frmName].focus();
                var notaElem = top.frames[frmName].document.getElementById("nota");

                if (notaElem != null)
                {
                                html += notaElem.innerHTML;
                }
                else
                {
                        if (gPrintAll && document.getElementsByTagName != null) {
                                var bodyTags = top.frames[frmName].document.getElementsByTagName("body");
                                if (bodyTags.length > 0) {
                                        html += bodyTags[0].innerHTML;
                                }
                        } else {
                                alert("No se encontró la sección a imprimir...");
                                return false;
                        }
                }

                html += '\n</BO' + 'DY>\n</HT' + 'ML>';
                var pWProp = "dependent=yes,height=5,width=5,screenX=10,screenY=10,resizable=0,directories=0,hotkeys=no,menubar=0,personalbar=no,scrollbars=0,location=0,status=0,toolbar=0";
                var printWin = window.open("","printSpecial", pWProp);
                printWin.document.open();
                printWin.document.write(html);
                printWin.document.close();
                // if (gAutoPrint) {
                //         printWin.print();
                //         }
                return true;
        }
        else
        {
                alert("Disculpe, el navegador no soporta esta función.");
        }
        return false;
}
