/* ----------------------------------------------------------------------
* Harmonie WebKit for Health Care v.2
*
* (c) Copyright 1999, Harmonie Group, Inc.  All rights reserved.
*
* This source code is owned by Harmonie Group, Inc.  Copying or
* distributing any part of this file, electronically or otherwise, either
* in its original or derivative form, or altering or removing this
* copyright notice is in violation of federal and international copyright 
* laws.
* ==========================================================================
* FILE: wk-javascript.js
* AUTHOR: Chris Perkins
* CREATION DATE: 25 August 1999
*
* DESCRIPTION:
* General WebKit javascript functions
*
* NOTES:
*
* MODIFICATIONS:
*/


/*************************************
 EVENT HANDLERS
*************************************/
/*************
 onClick
**************/
/*
function handleOnClick(evt) {
  if (evt.srcElement.type == "link") {
    alert('handling link event');
  }
 }
 
window.onClick = handleOnClick(event);
*/
/*************
 wkDisclaimer
 Description: display pop-up box containing disclaimer if a disclaimer
 has been defined for this website
 NOTE: depends on gDisclaimer global variable being set
**************/
  function wkDisclaimer() {
    // as long as there's a disclaimer defined pop up an alert box
    if (gDisclaimer != "") {
      alert(gDisclaimer);
    }
  }
      
/*************
 wkExtLink
 Description: Open links to external websites in a new, smaller window
 Also display the site disclaimer
**************/
  function wkExtLink(url) {
    // show the site disclaimer
    wkDisclaimer();
	// open the link in the new window
	var external_link;
    external_link=window.open(url, 'ExternalLink', 'toolbar=yes,directories=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes,width=600,height=300');
  }
  
/*************
 wkExtLinkNoDisclaimer(urL)
 Description: Open links to external websites in a new, smaller window
**************/
  function wkExtLinkNoDisclaimer(url) {
	// open the link in the new window
	var external_link;
    external_link=window.open(url, 'ExternalLink', 'toolbar=yes,directories=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes,width=600,height=300');
  }
  
 
/*************
 wkNewWindowBlank(urL)
 Description: Open a link in a new window 
**************/
  function wkNewWindowBlank(url) {
	// open the link in the new window
	var new_window;
    new_window = window.open(url, 'WebKit', 'toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes,width=300,height=400');
  } 

/*************
 wkNewWindowNoToolbar(urL)
 Description: Open a link in a new window 
**************/
  function wkNewWindowNoToolbar(url) {
	// open the link in the new window
	var new_window;
    new_window = window.open(url, 'WebKit', 'toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=500,height=150');
  } 
 

/*************
 wkChangeColor
 Description: used to implement text roll-overs with style sheets
**************/
  function wkChangeColor(inputColor) {
    // switch the text color using style sheets
    if (window.event.srcElement.className == "Item") {
	  window.event.srcElement.style.color = inputColor;
    }
  }

/*************
 wksendForm
 Description: performs actions on a form or something like that
**************/
	function wksendForm(formObj, form_action, action_id, action_rank) {
		formObj.form_action.value = form_action;
		formObj.action_id.value = action_id;
		formObj.action_rank.value = action_rank;
		formObj.submit.click();
	}

/*************
 wksubmitForm
 Description: submits a form without an actual submit button
**************/
    function wksubmitForm(formObj, action, action_id, action_rank) {
        formObj.form_action.value = action;
		formObj.action_id.value = action_id;
		formObj.action_rank.value = action_rank;
        formObj.submit();
    }

/*************
 wkPrintHidden
 Description: open a file in a new window, send to the printer, and close
**************/

    function wkPrintHidden(filename) {
        var hiddenWindow;
        hiddenWindow = window.open(filename, 'PrintHidden', 'toolbar=no,directories=no,menubar=no,location=yes,scrollbars=no,status=no,resizable=no,width=0,height=0');   
        hiddenWindow.print();
        hiddenWindow.close();
    }

/** AZ MOD  Sept. 27/06 * start**********
 2 Functions added:  toUNP  and CSClickReturn
 Description: open a new window to TeraNet online patient payment website
**************/


function toUNP() {

window.open("https://www.e-comunity.ca/unp/UNPFrontControllerServlet?LANG=en&OPCODE=FormInfo&APP_ID=100032&BRAND=site","","width=560,height=650,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=yes");	

return;

}

function toUNP_WLMH() {

window.open("https://www.e-comunity.ca/unp/UNPFrontControllerServlet?LANG=en&OPCODE=FormInfo&APP_ID=100038&BRAND=site","","width=560,height=650,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=yes");	

return;

}

function CSClickReturn () {
	var bAgent = window.navigator.userAgent; 
	var bAppName = window.navigator.appName;
	
	if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0)) { 
		return true; // dont follow link
	} else {
		return false; // dont follow link
	}
	
}

/** AZ MOD  Sept. 27/06 * end**********


/*************
 wkLinkWithNewWindow
**************/
  function wkLinkWithNewWindow(url) {
	// open the link in the new window . New height increased to 400, Left = 200, Top = 150.
	var external_link;
    external_link=window.open(url, 'ExternalLink', 'toolbar=yes,directories=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes,top = 150, left = 200, width=600,height=400');
  }
    
/*************
 wkLinkWithNewWindowWithAlert
**************/
  function wkLinkWithNewWindowWithAlert(url, alert_text) {
    var bContinue = true;
    // show the message
    if (alert_text != "") {
        bContinue = confirm(alert_text);
    }
    
	// open the link in the new window
    if (bContinue) {
  	  var external_link;
      external_link=window.open(url, 'ExternalLink', 'toolbar=yes,directories=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes,width=600,height=300');
    }
    else {
      return;
    }
  }
  
/*************
 wkLinkWithAlert
 Description: Display an alert and then refresh the window with the new url
 Also display the site disclaimer
**************/
  function wkLinkWithAlert(url, alert_text) {
    var bContinue = true;
    // show the message
    if (alert_text != "") {
        bContinue = confirm(alert_text);
    }
    if (bContinue) {
      window.location = url;
    }
    else {
      return;
    }
  }
  

/*************
 Date Object
*************/

	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if (year < 2000)
	year = year + 1900;