function CWSLayout_MakeInvisibleIfEmptySpace()
{
	var allElements=document.getElementsByName("_invisibleIfEmptySpace");
	var agt=navigator.userAgent.toLowerCase();
	var isNav=((agt.indexOf('mozilla')!=-1)&&((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1)));
	var isIE=(agt.indexOf("msie")!=-1);
	for (var curElement=0; curElement < allElements.length; curElement++)
	{
		if ((isIE && allElements[curElement].childNodes.length==0)
			|| (isNav && allElements[curElement].childNodes.length < 1))
		{
			allElements[curElement].style.display="none";
		}
		else
		{
		    var theElement = allElements[curElement].innerHTML;
		    theElement = theElement.replace(/^\s+|\s+$/g,"");
            if (theElement == "&nbsp;")
            {
                allElements[curElement].style.display="none";
            }
		}
	}
}



    function ClickToPrintLeftNav1() {
        var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        disp_setting += "scrollbars=yes,width=650, height=500, left=100, top=25";
        var content_vlue;
        var title_vlue;
        var sDivs = document.getElementsByTagName("div");
        for (var n = 0; n < sDivs.length; ++n) {
            if (sDivs[n].className == 'pageTitle') {
                content_vlue = "<div class='pageTitle'>"+ sDivs[n].innerHTML +"</div>";
                title_vlue = (String(sDivs[n].innerHTML)).trim(); 
            }
            
            if (sDivs[n].className == 'mainContent')
                content_vlue +=  "<div class='mainContent'>"+ sDivs[n].innerHTML +"</div>";
        }
        if (title_vlue=='undefined' || title_vlue =='')
        {
                title_vlue = 'Print Page';
        }

        var docprint = window.open("", "", disp_setting);

        docprint.document.open();
        docprint.document.write("<html><head><title>" + title_vlue + "</title>");
        for (var i=0; i<document.styleSheets.length; i++) {
          docprint.document.write("<link rel='stylesheet' type='text/css' href='"+document.styleSheets[i].href+"'/>");
         }
        docprint.document.write("<style type='text/css'>td, p {font-family: arial, tahoma, helvetica, sans-serif; font-size: 10.1pt;}</style>");
        docprint.document.write("<style type='text/css'> .pageTitle, .mainContent {margin: 10px;}</style>");
        docprint.document.write("</head><body onLoad='self.print()'>");
        docprint.document.write(content_vlue);
        docprint.document.write('</body></html>');
        docprint.document.close();
        docprint.focus();
    }

    function ClickToPrintLeftNav2() {
        var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        disp_setting += "scrollbars=yes,width=650, height=500, left=100, top=25";
        var content_vlue;
        var title_vlue;
        var sDivs = document.getElementsByTagName("div");
        for (var n = 0; n < sDivs.length; ++n) {
            if (sDivs[n].className == 'pageTitle') {
                content_vlue = "<div class='pageTitle'>"+ sDivs[n].innerHTML +"</div>";
                title_vlue = (String(sDivs[n].innerHTML)).trim(); 
            }
            
            if (sDivs[n].className == 'mainContent')
                content_vlue +=  "<div class='mainContent'>"+ sDivs[n].innerHTML +"</div>";
        }
        if (title_vlue=='undefined' || title_vlue =='')
        {
                title_vlue = 'Print Page';
        }

        var docprint = window.open("", "", disp_setting);

        docprint.document.open();
        docprint.document.write("<html><head><title>" + title_vlue + "</title>");
        for (var i=0; i<document.styleSheets.length; i++) {
          docprint.document.write("<link rel='stylesheet' type='text/css' href='"+document.styleSheets[i].href+"'/>");
         }
        docprint.document.write("<style type='text/css'>td, p {font-family: verdana; font-size: 9.6pt;} body{margin-top:10px;}</style>");
        docprint.document.write("<style type='text/css'>.pageTitle,.mainContent{padding: 0px 16px 1em;}</style>");
        docprint.document.write("</head><body onLoad='self.print()'>");
        docprint.document.write(content_vlue);
        docprint.document.write('</body></html>');
        docprint.document.close();
        docprint.focus();
    }

    function ClickToPrintLeftNav3() {
        var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        disp_setting += "scrollbars=yes,width=650, height=500, left=100, top=25";
        var content_vlue;
        var title_vlue;
        var sDivs = document.getElementsByTagName("div");
        for (var n = 0; n < sDivs.length; ++n) {
            if (sDivs[n].className == 'pageTitle') {
                content_vlue = "<div class='pageTitle'>"+ sDivs[n].innerHTML +"</div>";
                title_vlue = (String(sDivs[n].innerHTML)).trim(); 
            }
            
            if (sDivs[n].className == 'mainContent')
                content_vlue +=  "<div class='mainContent'>"+ sDivs[n].innerHTML +"</div>";
        }
        if (title_vlue=='undefined' || title_vlue =='')
        {
                title_vlue = 'Print Page';
        }

        var docprint = window.open("", "", disp_setting);

        docprint.document.open();
        docprint.document.write("<html><head><title>" + title_vlue + "</title>");
        for (var i=0; i<document.styleSheets.length; i++) {
          docprint.document.write("<link rel='stylesheet' type='text/css' href='"+document.styleSheets[i].href+"'/>");
         }
        docprint.document.write("<style type='text/css'>td, p {font-family: arial, tahoma, helvetica, sans-serif; font-size: 9.6pt;} body {background-color: white; margin-top:10px;}</style>");
        docprint.document.write("<style type='text/css'>.mainContent{margin: 0px 0px 10px 15px;}</style>");
        docprint.document.write("</head><body onLoad='self.print()'>");
        docprint.document.write(content_vlue);
        docprint.document.write('</body></html>');
        docprint.document.close();
        docprint.focus();
    }

    function ClickToPrintTopNav1() {
        var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        disp_setting += "scrollbars=yes,width=650, height=500, left=100, top=25";
        var content_vlue;
        var title_vlue;
        var sDivs = document.getElementsByTagName("div");
        for (var n = 0; n < sDivs.length; ++n) {
            if (sDivs[n].className == 'pageTitle') {
                content_vlue = "<div class='pageTitle'>"+ sDivs[n].innerHTML +"</div>";
                title_vlue = (String(sDivs[n].innerHTML)).trim(); 
            }
            
            if (sDivs[n].className == 'mainContent')
                content_vlue += "<div class='mainContent'>"+ sDivs[n].innerHTML +"</div>";
        }
        if (title_vlue=='undefined' || title_vlue =='')
        {
                title_vlue = 'Print Page';
        }

        var docprint = window.open("", "", disp_setting);

        docprint.document.open();
        docprint.document.write("<html><head><title>" + title_vlue + "</title>");
        for (var i=0; i<document.styleSheets.length; i++) {
          docprint.document.write("<link rel='stylesheet' type='text/css' href='"+document.styleSheets[i].href+"'/>");
         }
        docprint.document.write("<style type='text/css'>td, p {font-family: verdana; font-size: 9.6pt;} body{margin-top:10px;}</style>");
        docprint.document.write("</head><body onLoad='self.print()'>");
        docprint.document.write(content_vlue);
        docprint.document.write('</body></html>');
        docprint.document.close();
        docprint.focus();
    }

    function ClickToPrintTopNav2() {
        var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        disp_setting += "scrollbars=yes,width=650, height=500, left=100, top=25";
        var content_vlue;
        var title_vlue;
        var sDivs = document.getElementsByTagName("div");
        for (var n = 0; n < sDivs.length; ++n) {
            if (sDivs[n].className == 'pageTitle') {
                content_vlue = "<div class='pageTitle'>"+ sDivs[n].innerHTML +"</div>";
                title_vlue = (String(sDivs[n].innerHTML)).trim(); 
            }
            
            if (sDivs[n].className == 'mainContent')
                content_vlue += "<div class='mainContent'>"+ sDivs[n].innerHTML +"</div>";
        }
        if (title_vlue=='undefined' || title_vlue =='')
        {
                title_vlue = 'Print Page';
        }

        var docprint = window.open("", "", disp_setting);

        docprint.document.open();
        docprint.document.write("<html><head><title>" + title_vlue + "</title>");
        for (var i=0; i<document.styleSheets.length; i++) {
          docprint.document.write("<link rel='stylesheet' type='text/css' href='"+document.styleSheets[i].href+"'/>");
         }
        docprint.document.write("<style type='text/css'>td, p {font-family: verdana; font-size: 9.6pt;} body {background-color: white; margin-top:10px}</style>");
        docprint.document.write("<style type='text/css'>.mainContent{margin-left:10px; padding-bottom: 1.0em;}</style>");
        docprint.document.write("</head><body onLoad='self.print()'>");
        docprint.document.write(content_vlue);
        docprint.document.write('</body></html>');
        docprint.document.close();
        docprint.focus();
    }



function EmailToFriend() {
        var currentPage = String(window.location);
        var currentURL = currentPage.toLowerCase();
        var emailLink;
        var rootURL = currentPage.substring((currentPage.indexOf("/") + 2)); //remove http://
        //For English Page
        if (String(window.location).indexOf("en-US") > 0 || String(window.location).indexOf("en-us") > 0)
         {
            if(currentURL.indexOf("https") > -1)
            {
              emailLink = "https://" + rootURL.substring(0, (rootURL.indexOf("/"))) + "/en-US/CWSApps/EmailFriend.aspx?link=";
            }
            else
            {
              emailLink = "http://" + rootURL.substring(0, (rootURL.indexOf("/"))) + "/en-US/CWSApps/EmailFriend.aspx?link=";
            }
         }
        //For Spanish Page
        if (String(window.location).indexOf("es-MX") > 0 || String(window.location).indexOf("es-mx") > 0)
        {
          if(currentURL.indexOf("https") > -1)
          {
            emailLink = "https://" + rootURL.substring(0, (rootURL.indexOf("/"))) + "/es-MX/CWSApps/EmailFriend.aspx?link=";
          }
          else
          {
            emailLink = "http://" + rootURL.substring(0, (rootURL.indexOf("/"))) + "/es-MX/CWSApps/EmailFriend.aspx?link=";
          }
   
        }
        emailLink = emailLink + window.location;
        emailLink = emailLink.replace("#", " ");
        var sDiv = document.getElementById("emailLink");
        sDiv.href = emailLink;
    }

    function SetImagesLeftNav()
    {
          _spBodyOnLoadWrapper();

         var length = document.styleSheets.length-1;
         var cssFile;
         
        do{
            cssFile = document.styleSheets[length].href;
            length = length-1;
           }while(cssFile == '' || cssFile == null);

         if (String(cssFile).indexOf("darkBlue") > 0 || String(cssFile).indexOf("cyfairmedpartners") > 0)
         {
           if(document.getElementById('print') != null)
           {
               document.getElementById('print').src = '/_layouts/HospitalMasterPages/Styles/LeftNav1/Images/darkbluebgnd/print_leftnav1darkblue.gif';
               document.getElementById('email').src = '/_layouts/HospitalMasterPages/Styles/LeftNav1/Images/darkbluebgnd/email_leftnav1darkblue.gif';
           }
         }
         else
         {
            if(document.getElementById('print') != null)
            {
                document.getElementById('print').src = '/_layouts/HospitalMasterPages/Styles/LeftNav1/Images/lightbluebgnd/print_leftnav1lightblue.gif';
                document.getElementById('email').src = '/_layouts/HospitalMasterPages/Styles/LeftNav1/Images/lightbluebgnd/email_leftnav1lightblue.gif';
            }
         }
    }

    function SetImagesTopNav()
    {
          _spBodyOnLoadWrapper();

         var length = document.styleSheets.length-1;
         var cssFile;
         
         do{
            cssFile = document.styleSheets[length].href;
            length = length-1;
           }while(cssFile == '' || cssFile == null);

         if (String(cssFile).indexOf("darkBlue") > 0)
         {
           if(document.getElementById('print') != null)
           {
               document.getElementById('print').src = '/_layouts/HospitalMasterPages/Styles/TopNav1/Images/darkbluebgnd/print_topnav1darkblue.gif';
               document.getElementById('email').src = '/_layouts/HospitalMasterPages/Styles/TopNav1/Images/darkbluebgnd/email_topnav1darkblue.gif';
           }
         }
         else
         {
            if(document.getElementById('print') != null)
            {
                document.getElementById('print').src = '/_layouts/HospitalMasterPages/Styles/TopNav1/Images/lightbluebgnd/print_topnav1lightblue.gif';
                document.getElementById('email').src = '/_layouts/HospitalMasterPages/Styles/TopNav1/Images/lightbluebgnd/email_topnav1lightblue.gif';
            }
         }
    }
    
