﻿//Generating Pop-up Print Preview page
function getPrint(print_area) {
    //Creating new page
    
    //var pp = window.open();
    var pp = window.open('', 'PrintPreview', 'toolbar=yes,status=no,scrollbars=yes');
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><TITLE>Print Preview</TITLE><LINK href="App_Themes/ChoiceHealth/ChoiceHealth_Print.css"  type="text/css" rel="stylesheet">')
//    pp.document.writeln('<script language="javascript" src="../Common/Script.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/CommonFunctions.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/jquery-1[1].3.2.min.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/jquery[1].maskedinput-1.2.2.min.js" type="text/javascript"></script>')
    pp.document.writeln('<LINK href=PrintStyle.css  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
    //Adding form Tag
    pp.document.writeln('<form  method="post">');
    //Creating two buttons Print and Close within a table
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);self.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
    //Writing print area of the calling page
    
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>');
    pp.document.close();
}		


function getPrintFromMaster(print_area) {
    //Creating new page
    //var pp = window.open();
    var pp = window.open('','PrintPreview','toolbar=yes,status=no,scrollbars=yes');
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><TITLE>Print Preview</TITLE><LINK href="../App_Themes/ChoiceHealth/ChoiceHealth_Print.css"  type="text/css" rel="stylesheet">')
//    pp.document.writeln('<script language="javascript" src="../Common/Script.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/CommonFunctions.js" type="text/javascript"></script>')
//    //pp.document.writeln('<script language="javascript" src="../Common/jquery-1[1].3.2.min.js" type="text/javascript"></script>')
    //pp.document.writeln('<script language="javascript" src="../Common/jquery[1].maskedinput-1.2.2.min.js" type="text/javascript"></script>')

    pp.document.writeln('<LINK href="../App_Themes/ChoiceHealth/ChoiceHealth_Print.css"  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
    
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
    
    //Adding form Tag
    pp.document.writeln('<form  method="post">');
 
    //Creating two buttons Print and Close within a table
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
    
    //Writing print area of the calling page
    pp.document.writeln(document.getElementById(print_area).innerHTML);
   
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>');
    pp.document.close();

}	

function getPrintFromAdminMaster(print_area) {
    //Creating new page 
    //var pp = window.open();
    var pp = window.open('', 'PrintPreview', 'toolbar=no,status=no,scrollbars=yes');
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href="../../App_Themes/Admin/Admin.css"  type="text/css" rel="stylesheet">')
//    pp.document.writeln('<script language="javascript" src="../Common/Script.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/CommonFunctions.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/jquery-1[1].3.2.min.js" type="text/javascript"></script>')
//    pp.document.writeln('<script language="javascript" src="../Common/jquery[1].maskedinput-1.2.2.min.js" type="text/javascript"></script>')

    //pp.document.writeln('<LINK href=PrintStyle.css  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
    //Adding form Tag
    pp.document.writeln('<form  method="post">');
    //Creating two buttons Print and Close within a table
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" class="button" value="Print" onclick="javascript:location.reload(true);self.print();">&nbsp;&nbsp; <INPUT ID="CLOSE" type="button" class="button" value="Close" onclick="window.close();">&nbsp;&nbsp;</TD></TR><TR><TD></TD></TR></TABLE>');
    //Writing print area of the calling page
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>');
    pp.document.close();

}

function ShowSubMenu(divIDArray) {
    if (divIDArray != '') {
        var divLIndex = divIDArray.indexOf(',');
        if (divLIndex > 0) {
            var divlist = divIDArray.split(",");
            for (i = 0; i < divlist.length; i++) {
                var TempDiv = document.getElementById(divlist[i]);
                if (TempDiv != null && TempDiv != 'undefined') {
//                    if (i == 0) {
//                        if (TempDiv.style.display == 'none') {
//                            TempDiv.style.display = '';
//                        }
//                        else {
//                            TempDiv.style.display = 'none';
//                        }
//                    }
//                    else {
//                        TempDiv.style.display = '';
//                    }
                    TempDiv.style.display = '';
                }
            }
        }
        else {
            var TempDiv = document.getElementById(divIDArray);
           
            if (TempDiv != null) {
//                if (TempDiv.style.display == 'none') {
//                    TempDiv.style.display = '';
//                }
//                else {
//                    TempDiv.style.display = 'none';
//                }
                TempDiv.style.display = '';
               
            }
        }
    }    
}

function SetLinkActive(linkId) {
    var TempLink = document.getElementById(linkId);         
    if(TempLink != null)
            TempLink.style.color="#cd8929"; 
}
function SetMainMenuActive()
{
       var TempLink = document.getElementById('ctl00_ctl00_tdLogIn');
       if(TempLink != null)
            TempLink.className ='active';
}

function GetURISetActive() {
    var QString = getQueryVariable('PageURI');
    if (QString != '') {
        SetLinkActive(QString);
        SetAllParentActive(QString);
        ShowSubMenu('div'+ QString);
    }
}
function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}


function SetAllParentActive(LinkID, id) {
    var node = document.getElementById(LinkID);
    var parent = node;
    
    if (parent != null && parent != "") {
        var strParentID = parent.id;
        var intIndex = strParentID.indexOf("CPHLeftNav");

        // set current Link Active
        var TempLink = node;
        if (TempLink != null) {
            TempLink.style.color = "#cd8929";
        }

        // Show all Childs of the link clicked
        for (var i = 0; i < parent.parentNode.childNodes.length; i++) {
            if (parent.parentNode.childNodes[i].id != null && parent.parentNode.childNodes[i].id != "") {
                document.getElementById(parent.parentNode.childNodes[i].id).style.display = '';
            }
        }
       
        // Show all respective parent of the link clicked
        // check if not reached to Top most parent - Left_Naviagation div
        while (intIndex == -1) {

            parent = parent.parentNode;
            strParentID = parent.id;
            intIndex = strParentID.indexOf("CPHLeftNav");

            // check if Parent id not null or blank
            if (parent.id != null && parent.id != "") {
                var TempDiv = document.getElementById(parent.id);
                if (TempDiv != null) {
                    TempDiv.style.display = '';
                }


            }
        }
    }


}
