﻿// JScript File
//GetPrint('divPrintContent');
function GetPrint(print_areaId)
{
     
        //Change current window settings
        PrintSetting();
        var pp = window.open('',"PrintPreview","status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");        
        pp.document.writeln('<HTML><HEAD><TITLE>Print Preview</TITLE>');
        pp.document.writeln('<LINK  href="Styles/main-layout.css" type="text/css" rel="stylesheet"  media="screen"/>');        
        pp.document.writeln('<LINK  href="Styles/Volunteer.css" type="text/css" rel="stylesheet"  media="screen"/>');        
        pp.document.writeln('<LINK  href="Styles/content-layout.css" type="text/css" rel="stylesheet" media="screen"/><base target="_self">');
        pp.document.writeln('</HEAD><BODY>');
        pp.document.writeln('<FORM method="post" name="PrintForm" id="PrintForm">');
        pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');      
        pp.document.writeln('<INPUT ID="PRINT" type="button"  value="Print"');
        pp.document.writeln('onclick="javascript:location.reload(true);window.print();"/>');
        pp.document.writeln('<INPUT ID="CLOSE" type="button"  value="Close" onclick="window.close();"/>');
        pp.document.writeln('</TD></TR><TR><TD align="center"><img id="imgLoading" src="Images/Loading.gif" /></TD></TABLE>');       
        //Make all the controls readonly
        MakeReadOnly();  
        var strContent = document.getElementById(print_areaId).innerHTML;
        //strContent
          
        while (strContent.match("scroll")!=null)
        {
             strContent = (strContent.replace(/scroll/,"visible"));
             
        }
        while (strContent.match("auto")!=null)
        {
             strContent = (strContent.replace(/auto/,"visible"));
             
        }
       
        pp.document.writeln(strContent);      
        
        pp.document.writeln('<script type ="text/javascript" language="javascript">');
        pp.document.writeln('document.getElementById("imgLoading").style.visibility="hidden";window.print();</script>');
        pp.document.writeln('</form></body></HTML>'); 
        pp.focus();        
        return false;
        
 }

/******************************************************************************
This function hides the sections which are not required in Print Preivew
Parameters-- None
******************************************************************************/

function PrintSetting()
{
    //divTopRight
    var divHide = document.getElementById('divTopRight');
    if (divHide!=null)
    {
        divHide.style.display= 'none';
    }
    divHide =null;
    //divLower
    divHide = document.getElementById('divLower');
    if (divHide!=null)
    {
        divHide.style.display= 'none';
         
    }
    //divUpper
    divHide = document.getElementById('divUpper');
    if (divHide!=null)
    {
        divHide.style.display= 'none';
         
    }
}

/******************************************************************************
This function makes the editable controls readonly in Print Preivew
Parameters-- None
******************************************************************************/

function MakeReadOnly()
{
    
    for(i=0;i<document.getElementsByTagName("input").length;i++)              
    {
        var tempInput = document.getElementsByTagName("input")[i].id;
        document.getElementById(tempInput).disabled="disabled";                       
    }
    for(j=0;j<document.getElementsByTagName("textarea").length;j++)            
    {
       
        var tempTextArea = document.getElementsByTagName("textarea")[j].id;            
        document.getElementById(tempTextArea).readOnly ="readonly";                       
        
    }
    for(k=0;k<document.getElementsByTagName("select").length;k++)              
    {
        
        var tempSelect = document.getElementsByTagName("select")[k].id;            
        document.getElementById(tempSelect).disabled="disabled";                       
        
    }   
}