
var isSpanish;

//=================
function clickActiveSheet() 
//=================
// Name         : clickActiveSheet()
// Description  : Changes style sheet reference on the fly.
// Call         : clickActiveSheet()
// Parameters   : None
// Returns      : None
// Author       : Jeremy Malone
// Created      : 02/20/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        : Checks for current style sheet and bump to the next one
// Updates      :
// **************
{

var title = getActiveStyleSheet();

if(title=="small"){
setActiveStyleSheet("medium");
//textBtnOver = new Image();
//textBtnOver.src = g_HttpRelativeWebRoot + "/stellent/fragments/comUilityBarInclude/images/" + (isSpanish ? "sp_" : "") + "utility_font_ro.gif";
}
if(title=="medium"){
setActiveStyleSheet("large");
//textBtnOver = new Image();
//textBtnOver.src = g_HttpRelativeWebRoot + "/stellent/fragments/comUilityBarInclude/images/" + (isSpanish ? "sp_" : "") + "utility_font_ro.gif";
}
if(title=="large"){
setActiveStyleSheet("small");
//textBtnOver = new Image();
//textBtnOver.src = g_HttpRelativeWebRoot + "/stellent/fragments/comUilityBarInclude/images/" + (isSpanish ? "sp_" : "") + "utility_font_ro.gif";
}

}
//=================
function setActiveStyleSheet(title) 
//=================
// Name         : setActiveStyleSheet(title) 
// Description  : Changes style sheet reference 
// Call         : setActiveStyleSheet(string)
// Parameters   : title - title of the desired style sheet
// Returns      : 
// Author       : Jeremy Malone
// Created      : 02/20/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      :
// **************

{
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }

}
//=================
function getActiveStyleSheet() 
//=================
// Name         : getActiveStyleSheet() 
// Description  : Gets style sheet reference 
// Call         : getActiveStyleSheet()
// Parameters   : none
// Returns      : Active stylesheet
// Author       : Jeremy Malone
// Created      : 02/20/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      :
// **************
{
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) 
    {
        return a.getAttribute("title");
    }
  }
  return null;
}
//=================
function getPreferredStyleSheet() 
//=================
// Name         : getPreferredStyleSheet() 
// Description  : Gets preferred style sheet 
// Call         : getPreferredStyleSheet()
// Parameters   : none
// Returns      : Preferred stylesheet
// Author       : Jeremy Malone
// Created      : 02/20/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      :
// **************

{
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
//=================
function createCookie(name,value,days) 
//=================
// Name         : createCookie(name,value,days) 
// Description  : Creates stylesheet cookie
// Call         : createCookie(name,value,days)
// Parameters   : ncookie name, value and days
// Returns      : NA
// Author       : Jeremy Malone
// Created      : 02/20/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      :
// **************
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

//=================
function readCookie(name) 
//=================
// Name         : readCookie(name) 
// Description  : Reads stylesheet cookie
// Call         : readCookie(string)
// Parameters   : name of the cookie
// Returns      : Cookie info
// Author       : Jeremy Malone
// Created      : 02/20/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      :
// **************

{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

// **********************************************************************

//Retrieve cookie info and set stylesheet
//  var cookie = readCookie("style");
//  var title = cookie ? cookie : getPreferredStyleSheet();
//  setActiveStyleSheet(title);

//Update cookie with stylesheet information
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

//Set active stylesheet when apge loads
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

//Preload images
/* 
//Not used on in redesign  
patientsBtn = new Image();
patientsBtn.src = g_HttpRelativeWebRoot + "groups/jsp/documents/webcontent/" + (isSpanish ? "sp_" : "") + "patientbuttonover.gif";
emailBtn = new Image();
emailBtn.src = g_HttpRelativeWebRoot + "groups/jsp/documents/webcontent/" + (isSpanish ? "sp_" : "") + "crsemailpgbuttonovr.gif";
printBtn = new Image();
printBtn.src = g_HttpRelativeWebRoot + "groups/jsp/documents/webcontent/" + (isSpanish ? "sp_" : "") + "crsprintpgbuttonovr.gif";
*/
// **********************************************************************


//=================
function printView(root, chwFacilityName)
// Name         : printview() 
// Description  : Displays a printer friendly version of the content in a new window
// Call         : none
// Parameters   : HttpWebSitesRoot value
// Returns      : none
// Author       : John Slaughter
// Created      : 02/23/2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      :
// **************

{
  if (document.getElementById != null)
  {

      //    var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n';
    var html = '';    
    html += '<html>\n';
    html += '<HEAD>';      
    
    
    
    
    if (document.getElementsByTagName != null)
    {
      var headTags = document.getElementsByTagName("head");
    
      if (headTags.length > 0)
      
// Add in required style sheet references
      html += '<link type="text/css" rel="stylesheet" href="../../../stellent/fragments/v2stdincludes/main.css" type="text/css" media="all" />'; 
      html += '<link type="text/css" rel="stylesheet" href="../../../stellent/fragments/v2stdincludes/fontNormal.css" type="text/css" media="all" />';
      html += '<link type="text/css" rel="stylesheet" href="../../../stellent/fragments/v2stdincludes/PrintFormat.css" media="all" />';
      html += '<link type="text/css" rel="stylesheet" href="../../../include/styles/main.css" media="all" />';

// The following is a pice of javascript that is used as a replacment on the 
//link HREFs to disable links

      html +='<SCRIPT type=text/javascript>g_navNode_Root=""; function DisplayNav(){DisplayNav.prototype.Display = DisplayNav_Display;} function DisplayNav_Display (){return;} function DoNothing(){return;}</SCRIPT>';
      html += '\n<TITLE>Printer Friendly View</TITLE>\n';
    }

      html += '\n<style type="text/css">\n';   
      html += '@media print {';         
      html += 'body {color: #000000; font-family: arial; font-size: 12px; background-image: none; background-color: #ffffff}';  
      html += '.breadcrumb {display: none;}\n';    
      html += '.noprint {display: none;}\n';  
      html += '.remove {display: none;}\n';    
      html += '.printPgHeader {display: none;}\n';          
      html += '.contentLayoutTable .mainCol .photoLeft  {margin: 0 10px 10px 0; float: left;}\n';
      html += '.contentLayoutTable .mainCol .photoRight {margin: 0 0 10px 10px; float: right;}\n';      
      html += '#DetailPageNavTop {display: none;}\n';
      html += '#DetailPageNavBot {display: none;}\n';                                    
      html += '}';    
      html += '\n</style>\n';                    
    
      
// The following is a pice of javascript that will be executed when the page is displayed.  
// The code will unhide any of the hidden divs used in the detail pages for pagination so 
// the user will see all of the content and not just the virutal page they were looking at.
    html += '\n<Script Language="JavaScript">\n';	
    html += '\nfunction DetailPageFix(){\n';	
    html += '\nvar PageElem = document.getElementById("detailPageCount");\n';	
    html += '\nif (PageElem != null){\n';	
    html += '\nvar pageCnt = PageElem.innerHTML;\n';	
    html += '\nfor(var i=1;i <= pageCnt;i++){\n';	
    html += '\ndocument.getElementById("DetailPage"+i).style.display = "";\n';
    html += '\nif (document.getElementById("DetailPageHR"+i) != null) document.getElementById("DetailPageHR"+i).style.display = "";}\n';	
    html += '\ndocument.getElementById("DetailPageNavTop").style.display = "none";\n';	
    html += '\ndocument.getElementById("DetailPageNavBot").style.display = "none";}\n';	
    html += '\n}</Script>\n';	


// Set the BASE element to insure addressability to included objects (i.e. images)

   // html += '\n<base href="http://' + document.domain + '/' + root + '/">\n';
//    html += '\n<BASE href=' + document.domain + '/stellent/>\n';	

// Set the standed HTML BODY elements and config to call DetailPageFix on load

    html += '\n</HE' + 'AD>\n<BODY onload="DetailPageFix()">\n';

// Creates the plum banner with the page title
    html += '<div id="printPgHeader" class="remove">Print This Page</div>\n';      
    
// Add in print and close button/link at top of page

// Add in print and close button/link at top of page
    html += '<table width="100%" border="0" cellpadding="0" cellspacing="0">\n<tr class="remove">\n<td align="left" class="printFacilityName">' + chwFacilityName + '</td>';
    html += '<td align="right" class="printButtons">';    
    html += '\n<form><input type="button" value="' + (isSpanish ? "Imprimir esta página" : "Print this page") + '" onClick="window.print();">&nbsp;&nbsp;';
    html += '<input type="button" value="' + (isSpanish ? "Cerrar ventana" : "Close Window") + '" onClick="window.close();">\n</form></td>\n</tr>\n';		
    html += '<tr>\n<td colspan="2" class="printWindow">\n';
        
    
// Find the required PrintArea element
		
    var printPageElem = document.getElementById("PrintArea");
		
    if (printPageElem != null)
    {
//Remove Related Links from print page
/*
	if (document.getElementById("relatedLinks") != null)
	{
	   theDiv = document.getElementById("relatedLinks");
	   theDiv.style.display = 'none';		
	}
*/
// Get the HTML inside the PrintArea Element

	str = printPageElem.innerHTML;

//Redisplay Related Links on original page
/*
	if (document.getElementById("relatedLinks") != null)
	{
	   theDiv = document.getElementById("relatedLinks");
	   theDiv.style.display = 'block';		
	}	
*/
// Run HTML thru Regexp to convert links to call dummy javascript routine 
// We don not want the links to work on the print view
	AnchorMatch = /href=.+?[\)|\/]\x22/g;

	str = str.replace(AnchorMatch, 'href="javascript:DoNothing();"');

// Run HTML thru Regexp to remove any target=blank settings on links 
// to prevent them from trying to open new windows.
	BlankMatch = /target=_blank/g;
	str = str.replace(BlankMatch, ' ');
        html += str;

    }
    else
    {
        alert("Could not find the printView section in the HTML");
	return;
    }

// Add in print and close button/link and Copyright at Bottom of page
    html += '</td>\n</tr><tr class="remove">\n'
    html += '<td align="left" class="printFacilityName2">&copy;2008 Catholic Healthcare West</td>';
    html += '<td align="right" class="printButtons2">';    
    html += '\n<form><input type="button" value="' + (isSpanish ? "Imprimir esta página" : "Print this page") + '" onClick="window.print();">&nbsp;&nbsp;';
    html += '<input type="button" value="' + (isSpanish ? "Cerrar ventana" : "Close Window") + '" onClick="window.close();">\n</form></td>\n';		
    html += '</tr></table>\n'

// Wrap up standard HTML for page
    html += '\n</BO' + 'DY>\n</HT' + 'ML>';

// Set window parameters then call open routing to open new browser window passing our changed HTML

    var winParms = "width=763, scrollbars=yes, resizable=yes, toolbar=no, menubar=yes, location=no, directories=no";
    var printWin = window.open("","PrintView", winParms);
    printWin.document.open();
    printWin.document.write(html);
    printWin.document.close();

  }
  else
  {
    alert("Sorry, the print view feature works\nonly in javascript enabled browsers.");
  }
}

//=================
function popupEmailPage(url, chwFacilityName, DomainName)
// Name         : popupEmailPage() 
// Description  : Displays the emailAPage form in a popup window, and moves the focus to that window
// Call         : none
// Parameters   : url The URL to display
// Returns      : always returns false
// Author       : Brian P. Harris
// Created      : 02-25-2004
// Copyright    : 2004, Catholic Healthcare West
// Notes        :
// Updates      : 04/30/2004 bph - Since Terms and Conditions links were removed from email a page, it's no
// 		    :			     longer necessary to pass them in.
// **************
{	
	//construct the URL that we need to send to
//	urlQueryString = escape(location.search);
//	urlToSend = "http://" + hostName + "/intradoc-cgi/idc_cgi_isapi.dll" + urlQueryString;	

	urlToSend = escape(location.href);
	url = url + "?chwFN=" + escape(chwFacilityName) + "&chwPUrl=" + "http://" + DomainName + "/Classes_And_Events?iframeliteral=" + urlToSend + "&chwTitle=" + escape(document.title) + "&spanish=" + isSpanish;
	newwindow=window.open(url,'name','width=650,height=450,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}
