/* ----------------------------------------------------------------------
* 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:
*/


/*************************************
 focusFirstText
 Move cursor focus to first text field
 on a form
 
 problem when no text fields - returns
 object has no properties error
*************************************/
function focusFirstText() {
  for (var i=0; document.forms.length; i++) {
      if (document.forms[i].name == 'main_form') {
          for (var x=0; document.forms[i].elements.length; x++) {
              if (document.forms[i].elements[x].type == 'text') {
                 document.forms[i].elements[x].focus();
                 break;
              }
          }
          break;
      }
  }
}

/*************************************
 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=775,height=450');
  }
  
/*************
 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=775,height=450');
  }
  
 
/*************
 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=775,height=450');
  } 

/*************
 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=775,height=450');
  } 
 

/*************
 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();
    }

/*************
 wkLinkWithNewWindow
**************/
  function wkLinkWithNewWindow(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=775,height=450');
  }
    
/*************
 wkLinkWithNewWindowWithAlert
**************/
  function wkLinkWithNewWindowWithAlert(url, alert_text) {
    // show the message
    if (alert_text != "") {
        alert(alert_text);
    }
    
	// 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=775,height=450');
  }
  
/*************
 wkLinkWithAlert
 Description: Display an alert and then refresh the window with the new url
 Also display the site disclaimer
**************/
  function wkLinkWithAlert(url, alert_text) {
    // show the message
    if (alert_text != "") {
        alert(alert_text);
    }
    window.location = url;
  }
