// ///////////////////////////////////////////////////////////////////////////////////////////
//      SCRIPT NAME:	medical.js
//    SCRIPT AUTHOR:	Mark Vega
//      SCRIPT DATE:	May 2004
//  SCRIPT LOCATION:	pitcairn://target1s3/Web2/htdocs/www/libraries/grunigen/scripts/
//  SCRIPT FUNCTION:	
//     SCRIPT NOTES:		
// OTHER FILES USED:
//    LAST MODIFIED:	Added form validation functions.  02/25/2005
//                  	Added slideshow function.  04/10/2006 MFV
//                  	Added AIM status check functions.  06/19/2006
//                  	Added sendIM function.  06/24/2006
//                  	Added imEmailValidate function.  07/03/2006
//                  	Modified initValues function to reference form by name instead of
//                  	forms array index.  08/16/2006 MFV
//                  	Modified focusSrchBox function to reference form by name instead of
//                  	forms array index.  08/17/2006 MFV
//                  	Added coreSubmit function to handle form for POSTing eMedicine login
//                  	when Core Resource link is clicked.  08/16/2006 MFV
//                  	Changed root helios path from 'target6' to 'target1s3'.  01/19/2007 MFV
//                  	Revised new window function for efficiency.  01/19/2007 MFV
//                  	Revised and renamed initFormValues to initWinValues.  01/20/2007 MFV
//                  	Renamed focusSrchBox to clearSrchbox.  01/22/2007 MFV
//                  	Revised httprequest function for reusability.  01/31/2007 MFV
//                   	Changed all paths for new home on pitcairn.  06/13/2007 MFV
//                   	Moved form validation functions to formValidate.js.  06/14/2007 MFV
//                   	Moved httprequest function to xmlHttpRequest.js.  06/14/2007 MFV
//                   	Moved IM httprequest status check functions to imamedlib.js.  06/14/2007 MFV
//                   	Added function to alert Lab Training Lib browser requirements.  06/15/2007 MFV
//                  	Modified mtsWarning function to alert only if browser not IE.  09/10/2007 MFV
//                   	Modified eMedicine login form submit function.  03/04/2008 MFV 
//
// ///////////////////////////////////////////////////////////////////////////////////////////
//
// DEBUG WRITE STATEMENT
// alert("loading medical.js");
//
//
// INITIALIZE GLOBAL VARIABLES
//
// date variables
var now = new Date();
var date = now.getDate();               
var day = now.getDay();
var month = now.getMonth();
var year = now.getYear();
var dayName = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
// this window variables
var referer = window.location.href;
var winhref = '';
var winname = '';

//
// FORMAT DATE VALUES FOR DISPLAY
//
// get day name
for(i = 0; i < dayName.length; i++) {
if(day == i) {
day = dayName[i];
}
}
// get month name
for(j = 0; j < monthName.length; j++) {
if(month == j) {
month = monthName[j];
}
}
// y2k adjustment
if (year < 2000) {
year = 1900 + year
}
// assign date values
day = day + "";
month = month + "" ;
date = date + "";
year = year + "";
//
// FUNCTION TO WRITE FORMATTED DATE
//
// writes today's date as day name, month name, day, year (e.g. Saturday, January 19, 2007)
//
function writeDate() {
document.write("<p>" + day);
document.write(",");
document.write("&nbsp;");
document.write(month);
document.write("&nbsp;" + date + ",");
document.write("&nbsp;");
document.write(year + "</p>");
}
//
// IMAGE ROLLOVER FUNCTIONS - BORROWED FROM UCI LIBS HOME
//
// require two images for each image placeholder, switches img src on mouseover
//
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments;
document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//
// ONLOAD FUNCTION TO ASSIGN WINDOW NAME, INITIALIZE MEDICAL SEARCH FORM VALUES
//
function initWinValues(winname) {
// check for passed winname
if (winname) {
// set value of window name
window.name = winname;
}
// if core search form exists
if (document.getElementById('f_coresearch')) {
// set default search box text, menu selection
document.getElementById('f_coresearchfor').value = "Enter search term here";
document.getElementById('f_coresearchwhere').selectedIndex = 0;
}
}
//
// ONCLICK FUNCTION TO CLEAR CORE SEARCH BOX ON MOUSEDOWN
//
// clears default text from main search box when user clicks inside it
//
function clearCoreSearchBox() {
// if main search form exists
if (document.getElementById('f_coresearch')) {
// if default text exists
if (document.getElementById('f_coresearchfor').value == 'Enter search term here') {
// clear default text
document.getElementById('f_coresearchfor').value = '';
return true;
}
}
}
//
// FUNCTION TO SUBMIT EMEDICINE LOGIN FORMS
//
function eMedicineLogin(frm) {
// assign form element values to variables
var emedform = document.getElementById(frm);
// assign form values and submit form
emedform.action = "http://imedicine.com/login.asp";
emedform.acctnum.value = "5662";
switch(frm) {
case 'f_ddx_gen':
emedform.url.value = "http://imedicine.com/ddx_gen.asp";
break;
case 'f_emedicine':
emedform.url.value = '';
break;
default:
emedform.url.value = '';
}
emedform.submit();
}
//
// FUNCTION TO ALERT LAB TRAINING LIBRARY BROWSER REQUIREMENTS
//
// this function is called by click on Lab Training Library Core Resources link and generates warning that
// site requires Internet Explorer v6.0 or higher with pop-up blockers disabled.
//
function mtsWarning() {
if (!is_ie) {
alert("Access to the Lab Training Library requires Internet Explorer v6.0 or higher with pop-up blockers disabled. Mozilla Firefox, Netscape Navigator and other browsers are not supported by this site.");
return;
}
}



// TO BE REVIEWED

function coreSubmit(site) {
// assign form element values to variables
var coresubmitform = document.getElementById('f_coresubmit');

// check value of site
if (site == 'eMedicine') {
// assign form values and submit form
coresubmitform.action = "http://imedicine.com/login.asp";
coresubmitform.acctnum.value = "5662";
coresubmitform.url.value =  "";
coresubmitform.submit();
}
}

//
// END