/* global variables */
var hospiceEmployeeInfoWindow_w= 600;
var hospiceEmployeeInfoWindow_h= 720;
var hospiceReportLeftPadding= 15;
var hospiceReportTopPadding= 15;
var hospiceSupportLeftPadding= 15;
var hospiceSupportTopPadding= 15;

/* utilities */
function chgColor(divId, divColor) {
	document.getElementById(divId).style.background= divColor;
}
function getCookieVal(offset) {
	var endstr= document.cookie.indexOf(';', offset);
	if (endstr==-1) {
		endstr= document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name) {
	var arg= name+ '=';
	var alen= arg.length;
	var clen= document.cookie.length;
	var i= 0;
	while (i<clen) {
		var j= i+ alen;
		if (document.cookie.substring(i, j)==arg) {
			return getCookieVal(j);
		}
		i= document.cookie.indexOf(' ', i)+ 1;
		if (i==0) {
			break;
		}
	}
	return null;
}
function setCookie(name, value) {
	var argv= setCookie.arguments;
	var argc= setCookie.arguments.length;
	var expires= ((argc>2)? (argv[2]): (null));
	var path= ((argc>3)? (argv[3]): (null));
	var domain= ((argc > 4)? (argv[4]): (null));
	var secure= ((argc > 5)? (argv[5]): (false));
	document.cookie= name+ '='+ escape(value)+ ((expires==null)? (''): ('; expires='+ expires.toGMTString()))+ ((path==null)? (''): ('; path='+ path))+ ((domain==null)? (''): ('; domain='+ domain))+ ((secure==true)? ('; secure'): (''));
}
function getClientDateValue(dateObj) {
	var cy= dateObj.getYear();
	var cm= dateObj.getMonth()+1;
	var cd= dateObj.getDate();
	return ((cy<1000)? (cy+1900): (cy))+ ""+ ((cm<10)? ("0"+ cm): (cm))+ ""+ ((cd<10)? ("0"+ cd): (cd));
}
function getClientTimeValue(dateObj) {
	var ch= dateObj.getHours();
	var cm= dateObj.getMinutes();
	var cs= dateObj.getSeconds();
	return ((ch<10)? ("0"+ ch): (ch))+ ""+ ((cm<10)? ("0"+ cm): (cm))+ ""+ ((cs<10)? ("0"+ cs): (cs));
}
function phoneNumberMask() {
	if (window.event.keyCode==9) {
		return;
	}
	var sMask= '0123456789 ()-';
	var KeyTyped= String.fromCharCode(window.event.keyCode);
	var sSourceValue = window.event.srcElement.value;
	if ((sMask.indexOf(KeyTyped)==-1) || (sSourceValue.length>13)) {
		window.event.keyCode= 0;
		_ret= false;
	}
    sSourceValue= sSourceValue.replace(/[() -]/gi,'');
	var sTmp= '';
	for(i=0; i<sSourceValue.length; i++) {
		if(5<sSourceValue.length) {
			sTmp= '('+ sSourceValue.substring(0,3)+ ') '+ sSourceValue.substring(3,6)+ '-'+ sSourceValue.substring(6);
		}
		else if (2<sSourceValue.length) {
			sTmp= '('+ sSourceValue.substring(0,3)+ ') '+ sSourceValue.substring(3);
		}
		else if (0<sSourceValue.length) {
			sTmp= '('+ sSourceValue.substring(0);
		}
	}
	window.event.srcElement.value= sTmp;
}
function moneyFieldOnBlur(obj) {
	if (trim(obj.value)=='') {
		obj.value= '';
	}
	else {
		if (obj.value.indexOf('.')==-1) {
			obj.value= obj.value+ '.00';
		}
		else {
			if (obj.value.indexOf('.')==0) {
				obj.value= '0'+ obj.value;
			}
			if ((obj.value.indexOf('-')==0) && (obj.value.indexOf('.')==1)) {
				if (obj.value=='-.') {
					obj.value= '0.00';
				}
				else {
					obj.value= '-0.'+ obj.value.substring(2);
				}
			}
			if ((obj.value.indexOf('.'))==(obj.value.length-1)) {
				obj.value= obj.value+ '00';
			}
			else if ((obj.value.indexOf('.'))==(obj.value.length-2)) {
				obj.value= obj.value+ '0';
			}
			else if ((obj.value.indexOf('.'))<=(obj.value.length-3)) {
				obj.value= obj.value.substring(0, (obj.value.indexOf('.')+3));
			}
		}
	}
	if (obj.value=='-0.00') {
		obj.value= '0.00';
	}
}
function parseHospiceComponent(value) {
	var component= new Array(2);
	component[0]= ((value.indexOf('|')>-1)? (value.substring(0, value.indexOf('|'))): (value));
	component[1]= (((value.indexOf('|')>-1) && (value.indexOf('|')<(value.length-1)))? (parseInt(value.substring(value.indexOf('|')+ 1))): (0));
	return component;
}

/* navigation */
function naviToHospiceMain() {
	document.location.href= '/meds/hospice/';
}
function naviToHospiceHelp() {
	document.location.href= '/meds/hospice/function/help/';
}
function naviToHospiceProfile() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceProfile';
}
function naviToHospicePatientMain() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain';
}
function naviToHospiceAddNewPatient() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientInfo?act=new';
}
function naviToHospiceUpdatePatient(hospicepatientid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientInfo?act=update&hospicepatientid='+ hospicepatientid;
}
function naviToHospiceOrderInquiryMain() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderInquiryMain';
}
function naviToHospicePatientOrderInquiryMain(hospicepatientid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderInquiryMain?act=patorder&hospicepatientid='+ hospicepatientid;
}
function naviToVoidOrder(voidorderid) {
	if (confirm('Are you sure you want to Void this Order?')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderInquiryMain?act=voidorder&voidorderid='+ voidorderid;
	}
}
function naviToHospiceOrderView(hospiceorderid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderView?hospiceorderid='+ hospiceorderid;
}
function naviToHospiceOrderHistory(hospiceorderid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderHistory?hospiceorderid='+ hospiceorderid;
}
function naviToCreateOrderByEmployee() {
	if (confirm('Do you want to create a generic new order?\nMake sure you save the current order before clicking OK.')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act=initnew';
	}
}
function naviToCreateOrderByPatient(hospicepatientid, existingsize, firstorderid, multiorder) {
	if ((existingsize==0) || (firstorderid==0)) {
		if (confirm('Do you want to create a new order for this patient?\nMake sure you save the current order before clicking OK.')) {
			document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act=initnew&hospicepatientid='+ hospicepatientid;
		}
	}
	else {
		/*
		if (multiorder=='N') {
			if (confirm('There '+ ((existingsize==1)? ('is an '): ('are '+ existingsize+ ' '))+ 'existing order'+ ((existingsize>1)? ('s'): (''))+ ' for this patient in the system.\nDo you want to edit the first existing order for this patient?')) {
				document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act=initupd&hospiceorderid='+ firstorderid;
			}
		}
		else {
			if (confirm('There '+ ((existingsize==1)? ('is an '): ('are '+ existingsize+ ' '))+ 'existing order'+ ((existingsize>1)? ('s'): (''))+ ' for this patient in the system.\nDo you still want to create a new order for this patient?')) {
				document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act=initnew&hospicepatientid='+ hospicepatientid;
			}
		}
		*/
		if (confirm('There '+ ((existingsize==1)? ('is an '): ('are '+ existingsize+ ' '))+ 'existing order'+ ((existingsize>1)? ('s'): (''))+ ' for this patient in the system.\nDo you still want to create a new order for this patient?')) {
			document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act=initnew&hospicepatientid='+ hospicepatientid;
		}
	}
}
function naviToLoadOrder(hospiceorderid) {
	if (confirm('Do you want to load and edit this order?\nMake sure you save the current order before clicking OK.')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act=initupd&hospiceorderid='+ hospiceorderid;
	}
}
function naviToHospiceOrderEditHdr() {
	if (document.formHospiceOrderEditHdr) {
		formHospiceOrderEditHdr_SubmitUtil('', true, false);
	}
	else if (document.formHospiceOrderEditCart) {
		formHospiceOrderEditCart_SubmitUtil('toedithdr', true, false);
	}
	else {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr';
	}
}
function naviToHospiceOrderEditCart() {
	if (document.formHospiceOrderEditCart) {
		formHospiceOrderEditCart_SubmitUtil('', true, false);
	}
	else if (document.formHospiceOrderEditHdr) {
		formHospiceOrderEditHdr_SubmitUtil('toeditcart', true, false);
	}
	else {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditCart';
	}
}
function naviToHospiceBrowseItem() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseItem';
}
function naviToHospiceBrowseContract() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseContract';
}
function naviToHospiceBrowsePk() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowsePk';
}
function naviToHospicePickupRequestMain() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestMain';
}
function naviToHospiceAddNewPickupRequest(hospicepatientid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestInfo?act=new&hospicepatientid='+ hospicepatientid;
}
function naviToHospiceUpdatePickupRequest(pickupno) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestInfo?act=update&pickupno='+ pickupno;
}
function naviToHospiceServiceRequestMain() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain';
}
function naviToHospiceAddNewServiceRequest(hospicepatientid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestInfo?act=new&hospicepatientid='+ hospicepatientid;
}
function naviToHospiceSupportView() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceSupportView';
}
function naviToHospiceSupportEdit(supportId) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceSupportEdit?supportId='+ supportId;
}
function naviToHospiceSupportAdminView() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceSupportAdminView';
}
function naviToHospiceSupportAdminEdit(supportId) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceSupportAdminEdit?supportId='+ supportId;
}

/* launch independent window */
function launchHospiceHelp() {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceSupportNew', 'supportNewWin', 'width=750, height=480, left='+ (screen.availWidth-750)/2+ ', top='+ (screen.availHeight-480)/2+ ', status=yes');
}
function launchHospiceSupportLog() {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceSupportView', 'supportViewWin', 'left='+ hospiceSupportLeftPadding+ ', top='+ hospiceSupportTopPadding+ ', width='+ (screen.availWidth-(2*hospiceSupportLeftPadding+20))+ ', height='+ (screen.availHeight-(2*hospiceSupportTopPadding+50))+ ', scrollbars=yes, status=yes');
}
function launchHospiceSupportAdminLog() {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceSupportAdminView', 'supportAdminViewWin', 'left='+ hospiceSupportLeftPadding+ ', top='+ hospiceSupportTopPadding+ ', width='+ (screen.availWidth-(2*hospiceSupportLeftPadding+20))+ ', height='+ (screen.availHeight-(2*hospiceSupportTopPadding+50))+ ', scrollbars=yes, status=yes');
}

/* messaging */
function hospiceEditOrderOnLoadMsg(msg) {
	if (msg==1) {
		alert('The order has been created successfully.');
		naviToHospiceOrderInquiryMain();
	}
	else if (msg==2) {
		alert('The order has been updated successfully.');
		naviToHospiceOrderInquiryMain();
	}
	else if (msg==6) {
		alert('The order has been saved and submitted succesfully.');
		naviToHospiceOrderInquiryMain();
	}
	else if (msg==103) {
		alert('The order is currently incomplete.\nPlease fulfill the minimum requirement and submit again.');
	}
	else if (msg==104) {
		alert('The order has already been sent.');
	}
	else if (msg==105) {
		alert('The order has already been voided.');
	}
}

/* menu */
function displayNewOrderOption() {
	if (document.getElementById('orderopt').style.display=='none') {
		document.getElementById('orderopt').style.display= 'block';
	}
	else if (document.getElementById('orderopt').style.display=='block') {
		document.getElementById('orderopt').style.display= 'none';
	}
}

/* hospice shopping main page */
function formHospiceMain_OnLoad() {
	if (document.formHospiceMain.companyno) {
		if (getCookie('hsaveid')!=null) {
			if (getCookie('hsaveid')=='1') {
				document.formHospiceMain.companyno.value= ((getCookie('hcompanyno')!=null)? (getCookie('hcompanyno')): (''));
				document.formHospiceMain.loginid.value= ((getCookie('hloginid')!=null)? (getCookie('hloginid')): (''));
				document.formHospiceMain.saveid.checked= true;
			}
		}
		if ((!txtIsEmpty(document.formHospiceMain.companyno)) && (!txtIsEmpty(document.formHospiceMain.loginid))) {
			document.formHospiceMain.loginpwd.focus();
		}
		else {
			document.formHospiceMain.companyno.focus();
		}
	}
}
function formHospiceMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceMain_SubmitLogin();
	}
}
function formHospiceMain_VldSubmitLogin() {
	if (txtIsEmpty(document.formHospiceMain.companyno)) {
		alert('Please enter the Store ID.');
		document.formHospiceMain.companyno.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospiceMain.loginid)) {
		alert('Please enter your Login ID.');
		document.formHospiceMain.loginid.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospiceMain.loginpwd)) {
		alert('Please enter your Login Password.');
		document.formHospiceMain.loginpwd.focus();
		return false;
	}
	var expDate= new Date();
	expDate.setTime(expDate.getTime()+ (30*24*60*60*1000));
	setCookie('hcompanyno', document.formHospiceMain.companyno.value, expDate);
	setCookie('hloginid', document.formHospiceMain.loginid.value, expDate);
	if (document.formHospiceMain.saveid.checked) {
		setCookie('hsaveid', '1', expDate);
	}
	else {
		setCookie('hsaveid', '0', expDate);
	}
	return true;
}
function formHospiceMain_SubmitLogin() {
	if (formHospiceMain_VldSubmitLogin()) {
		var dateObj= new Date();
		document.formHospiceMain.clientdate.value= getClientDateValue(dateObj);
		document.formHospiceMain.clienttime.value= getClientTimeValue(dateObj);
		document.formHospiceMain.target= '_self';
		document.formHospiceMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceSignInController';
		document.formHospiceMain.submit();
	}
}
function formHospiceMain_Logout() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceSignOutController';
}

/* hospice decision page */
function formHospiceDecision_MouseOverHospice(seq) {
	chgColor('h'+ seq, 'EEEEEE');
	chgColor('n'+ seq, 'EEEEEE');
	chgColor('c'+ seq, 'EEEEEE');
}
function formHospiceDecision_MouseOutHospice(seq) {
	chgColor('h'+ seq, 'FFFFFF');
	chgColor('n'+ seq, 'FFFFFF');
	chgColor('c'+ seq, 'FFFFFF');
}
function formHospiceDecision_SelectHospice(hospiceid) {
	var dateObj= new Date();
	document.formHospiceDecision.clientdate.value= getClientDateValue(dateObj);
	document.formHospiceDecision.clienttime.value= getClientTimeValue(dateObj);
	document.formHospiceDecision.target= '_self';
	document.formHospiceDecision.action= '/meds/servlet/com.meds.hospice.servlet.HospiceSignInController?hospiceid='+ hospiceid;
	document.formHospiceDecision.submit();
}

/* hospice employee profile page */
function formHospiceProfile_OnLoad(msg) {
	if (msg==2) {
		alert('Your profile has been updated successfully.');
	}
	document.formHospiceProfile.fname.focus();
}
function formHospiceProfile_VldSubmit() {
	if ((txtIsEmpty(document.formHospiceProfile.loginpwd)) && (!txtIsEmpty(document.formHospiceProfile.confirmpwd))) {
		alert('Please enter your New Password.');
		document.formHospiceProfile.loginpwd.focus();
		return false;
	}
	if ((!txtIsEmpty(document.formHospiceProfile.loginpwd)) && (txtIsEmpty(document.formHospiceProfile.confirmpwd))) {
		alert('Please confirm your New Password.');
		document.formHospiceProfile.confirmpwd.focus();
		return false;
	}
	if ((!txtIsEmpty(document.formHospiceProfile.loginpwd)) && (!txtIsEmpty(document.formHospiceProfile.confirmpwd))) {
		if (document.formHospiceProfile.loginpwd.value!=document.formHospiceProfile.confirmpwd.value) {
			alert('Please confirm your password again.');
			document.formHospiceProfile.confirmpwd.select();
			return false;
		}
	}
	if (txtIsEmpty(document.formHospiceProfile.lname)) {
		alert('Please enter your Last Name.');
		document.formHospiceProfile.lname.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospiceProfile.email)) {
		alert('Please enter your Email Address.');
		document.formHospiceProfile.email.focus();
		return false;
	}
	if (!txtIsEmpty(document.formHospiceProfile.phone1)) {
		if (document.formHospiceProfile.phone1.value.length!=14) {
			alert('Please enter a valid Phone Number.');
			document.formHospiceProfile.phone1.select();
			return false;
		}
	}
	if (!txtIsEmpty(document.formHospiceProfile.phone2)) {
		if (document.formHospiceProfile.phone2.value.length!=14) {
			alert('Please enter a valid Phone Number.');
			document.formHospiceProfile.phone2.select();
			return false;
		}
	}
	return true;
}
function formHospiceProfile_Submit() {
	if (formHospiceProfile_VldSubmit()) {
		document.getElementById('btnSubmit').disabled= true;
		document.getElementById('btnCancel').disabled= true;
		document.formHospiceProfile.target= '_self';
		document.formHospiceProfile.action= '/meds/servlet/com.meds.hospice.servlet.HospiceProfile?act=submit';
		document.formHospiceProfile.submit();
	}
}

/* hospice patient main page */
function formHospicePatientMain_OnLoad() {
	document.formHospicePatientMain.fname.focus();
}
function formHospicePatientMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospicePatientMain_Search();
	}
}
function formHospicePatientMain_Refresh() {
	naviToHospicePatientMain();
}
function formHospicePatientMain_PageSort(page, sortby) {
	if (formHospicePatientMain_VldSearch()) {
		document.formHospicePatientMain.target= '_self';
		document.formHospicePatientMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospicePatientMain.submit();
	}
}
function formHospicePatientMain_VldSearch() {
	return true;
}
function formHospicePatientMain_Search() {
	if (formHospicePatientMain_VldSearch()) {
		document.formHospicePatientMain.target= '_self';
		document.formHospicePatientMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=search';
		document.formHospicePatientMain.submit();
	}
}
function formHospicePatientMain_SlctPatient(hospicepatientid, dmecustomerid, existingsize, firstorderid, multiorder, mode) {
	if ((!(document.formHospicePatientMain.frm)) || (document.formHospicePatientMain.frm.value=='')) {
		naviToCreateOrderByPatient(hospicepatientid, existingsize, firstorderid, multiorder);
	}
	else if (document.formHospicePatientMain.frm.value=='edithdr') {
		if (mode==0) {
			if (confirm('Are you sure you want to change the current order Ship-To and Order-For to this patient?')) {
				document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=updord&hospicepatientid='+ hospicepatientid;
			}
		}
		else if (mode==1) {
			window.open('/meds/servlet/com.meds.hospice.servlet.HospicePatientSlct?hospicepatientid='+ hospicepatientid, 'patSlctWin', 'width=375, height=180, left='+ (screen.availWidth-375)/2+ ', top='+ (screen.availHeight-180)/2);
		}
	}
	else if (document.formHospicePatientMain.frm.value=='pickupreq') {
		naviToHospiceAddNewPickupRequest(hospicepatientid);
	}
	else if (document.formHospicePatientMain.frm.value=='servicereq') {
		naviToHospiceAddNewServiceRequest(hospicepatientid);
	}
	else if (document.formHospicePatientMain.frm.value=='allequip') {
		window.open('/meds/servlet/com.meds.report.servlet.CustStatRpt?frm=hospice&method=print&txtCustID='+ dmecustomerid+ '&sOrderType=RENTAL&realOffice=', 'allEquipWin', 'width=900, height=600, left='+ (screen.availWidth-900)/2+ ', top='+ (screen.availHeight-600)/2+ ', scrollbars=yes, resizable=yes');
	}
	else if (document.formHospicePatientMain.frm.value=='curequip') {
		window.open('/meds/servlet/com.meds.report.servlet.RentedItemController?frm=hospice&filter_return=Y&customerid='+ dmecustomerid, 'curEquipWin', 'width=900, height=600, left='+ (screen.availWidth-900)/2+ ', top='+ (screen.availHeight-600)/2+ ', scrollbars=yes, resizable=yes');
	}
}

/* hospice patient selection page */
function formHospicePatientSlct_OnLoad(msg) {
	if (msg==2) {
		alert('Order information has been set successfully.');
		window.opener.document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr';
		window.close();
	}
}
function formHospicePatientSlct_Submit() {
	if ((!document.formHospicePatientSlct.fr.checked) && (!document.formHospicePatientSlct.st.checked)) {
		alert('Please check at least one box before submit.');
	}
	else {
		document.formHospicePatientSlct.target= '_self';
		document.formHospicePatientSlct.action= '/meds/servlet/com.meds.hospice.servlet.HospicePatientSlct?act=confirm';
		document.formHospicePatientSlct.submit();
	}
}

/* hospice patient info page */
function formHospicePatientInfo_OnLoad(msg) {
	if (msg==1) {
		alert('The new patient record has been created successfully.');
		naviToHospicePatientMain();
	}
	else if (msg==2) {
		alert('The patient record has been updated successfully.');
		naviToHospicePatientMain();
	}
	else if (msg==3) {
		alert('The patient record has been deleted successfully.');
		naviToHospicePatientMain();
	}
	else if (msg==102) {
		alert('The patient record already exists.');
		naviToHospicePatientMain();
	}
	else if (msg==109) {
		alert('The patient record has been saved, and an empty new order has been created and sent successfully.\nPlease check the patient\'s old address to see if any equipment pickup is required.');
		naviToHospicePatientMain();
	}
	oDateMask= new Mask("mm/dd/yyyy", "date");
	oDateMask.attach(document.formHospicePatientInfo.dob);
	oDateMask.attach(document.formHospicePatientInfo.dischargedate);
	document.formHospicePatientInfo.fname.focus();
}
function formHospicePatientInfo_AddressOnChange(mode) {
	if (mode==2) {
		document.formHospicePatientInfo.apply.disabled= false;
		document.formHospicePatientInfo.addresschanged.value= '1';
	}
}
function formHospicePatientInfo_DisableButtons() {
	if (document.getElementById('btnDelete')) {
		document.getElementById('btnDelete').disabled= true;
	}
	if (document.getElementById('btnSubmit')) {
		document.getElementById('btnSubmit').disabled= true;
	}
	if (document.getElementById('btnCancel')) {
		document.getElementById('btnCancel').disabled= true;
	}
}
function formHospicePatientInfo_Delete() {
	if (confirm('Are you sure you want to Delete this Patient?')) {
		document.getElementById('btnDelete').disabled= true;
		document.getElementById('btnSubmit').disabled= true;
		document.getElementById('btnCancel').disabled= true;
		document.formHospicePatientInfo.target= '_self';
		document.formHospicePatientInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospicePatientInfo?act=delete';
		document.formHospicePatientInfo.submit();
	}
}
function formHospicePatientInfo_VldSubmit() {
	if (txtIsEmpty(document.formHospicePatientInfo.fname)) {
		alert('Please enter the patient First Name.');
		document.formHospicePatientInfo.fname.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospicePatientInfo.lname)) {
		alert('Please enter the patient Last Name.');
		document.formHospicePatientInfo.lname.focus();
		return false;
	}
	if (document.formHospicePatientInfo.gender.options[document.formHospicePatientInfo.gender.selectedIndex].value=='') {
		alert('Please select the Gender for the patient.');
		document.formHospicePatientInfo.gender.focus();
		return false;
	}
	if (!txtIsEmpty(document.formHospicePatientInfo.dob)) {
		if (document.formHospicePatientInfo.dob.value.length!=10) {
			alert('Please enter a valid Date of Birth.');
			document.formHospicePatientInfo.dob.select();
			return false;
		}
	}
	if (!txtIsEmpty(document.formHospicePatientInfo.social)) {
		if (document.formHospicePatientInfo.social.value.length!=9) {
			alert('Please enter a valid Social Security Number.');
			document.formHospicePatientInfo.social.select();
			return false;
		}
	}
	if (txtIsEmpty(document.formHospicePatientInfo.address1)) {
		alert('Please enter the patient Address.');
		document.formHospicePatientInfo.address1.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospicePatientInfo.city)) {
		alert('Please enter the patient City.');
		document.formHospicePatientInfo.city.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospicePatientInfo.state)) {
		alert('Please enter the patient State.');
		document.formHospicePatientInfo.state.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospicePatientInfo.zip)) {
		alert('Please enter the patient Zip Code.');
		document.formHospicePatientInfo.zip.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospicePatientInfo.phone1)) {
		alert('Please enter the patient Phone Number.');
		document.formHospicePatientInfo.phone1.focus();
		return false;
	}
	else {
		if (document.formHospicePatientInfo.phone1.value.length!=14) {
			alert('Please enter a valid Phone Number for the patient.');
			document.formHospicePatientInfo.phone1.select();
			return false;
		}
	}
	if (!txtIsEmpty(document.formHospicePatientInfo.phone2)) {
		if (document.formHospicePatientInfo.phone2.value.length!=14) {
			alert('Please enter a valid Phone Number for the patient.');
			document.formHospicePatientInfo.phone2.select();
			return false;
		}
	}
	if (txtIsEmpty(document.formHospicePatientInfo.contact1)) {
		alert('Please enter the patient Contact.');
		document.formHospicePatientInfo.contact1.focus();
		return false;
	}
	return true;
}
function formHospicePatientInfo_Submit() {
	if (formHospicePatientInfo_VldSubmit()) {
		formHospicePatientInfo_DisableButtons();
		document.formHospicePatientInfo.target= '_self';
		document.formHospicePatientInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospicePatientInfo?act='+ (((document.formHospicePatientInfo.addresschanged.value=='1') && (confirm('Do you want to create and send an Empty Order for this patient with the new address?\n(For the purpose if this patient moves to another address, and you like all future ordered items go to this new order.)\n\nClick OK to save cand create an order, or Cancel to save the customer data only.')))? ('emptyorder'): ('submit'));
		document.formHospicePatientInfo.submit();
	}
}

/* hospice employee main page */
function formHospiceEmployeeMain_OnLoad() {
	if (window.parent.header.functionname) {
		hdrTitle('Account Setup');
	}
	formHospiceEmployeeMain_HospiceOnChange();
	document.formHospiceEmployeeMain.loginid.focus();
}
function formHospiceEmployeeMain_HospiceOnChange() {
	var value= document.formHospiceEmployeeMain.hospiceid.options[document.formHospiceEmployeeMain.hospiceid.selectedIndex].value;
	if (value=='') {
		document.getElementById('reqbutton').disabled= true;
		document.getElementById('addbutton').disabled= true;
	}
	else {
		var component= parseHospiceComponent(value);
		if (component[1]>0) {
			document.getElementById('reqbutton').disabled= true;
			document.getElementById('addbutton').disabled= false;
		}
		else {
			document.getElementById('reqbutton').disabled= false;
			document.getElementById('addbutton').disabled= true;
		}
	}
}
function formHospiceEmployeeMain_Account(mode) {
	var value= document.formHospiceEmployeeMain.hospiceid.options[document.formHospiceEmployeeMain.hospiceid.selectedIndex].value;
	if (value=='') {
		alert('Please select a Hospice first.');
		document.formHospiceEmployeeMain.hospiceid.focus();
	}
	else {
		var component= parseHospiceComponent(value);
		if (mode=='r') {
			window.open('/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=license&hospiceid='+ component[0], 'hsLicenseWin', 'width=400, height=250, left='+ (screen.availWidth-400)/2+ ', top='+ (screen.availHeight-250)/2);
		}
		else if (mode=='a') {
			window.open('/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeInfo?act=new&hospiceid='+ component[0], 'hsNewWin', 'scrollbars, width='+ hospiceEmployeeInfoWindow_w+ ', height='+ hospiceEmployeeInfoWindow_h+ ', left='+ (screen.availWidth-hospiceEmployeeInfoWindow_w)/2+ ', top='+ (screen.availHeight-(hospiceEmployeeInfoWindow_h+ 20))/2);
		}
	}
}
function formHospiceEmployeeMain_RequestMore() {
	formHospiceEmployeeMain_Account('r');
}
function formHospiceEmployeeMain_AddNew() {
	formHospiceEmployeeMain_Account('a');
}
function formHospiceEmployeeMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceEmployeeMain_Search();
	}
}
function formHospiceEmployeeMain_HospiceSearchByOnChange() {
	if (document.formHospiceEmployeeMain.hospicesearchby.options[document.formHospiceEmployeeMain.hospicesearchby.selectedIndex].value!='') {
		document.formHospiceEmployeeMain.hospicesearchvalue.focus();
	}
}
function formHospiceEmployeeMain_Refresh() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=refresh';
}
function formHospiceEmployeeMain_PageSort(page, sortby) {
	if (formHospiceEmployeeMain_VldSearch()) {
		document.formHospiceEmployeeMain.target= '_self';
		document.formHospiceEmployeeMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospiceEmployeeMain.submit();
	}
}
function formHospiceEmployeeMain_VldSearch() {
	if (document.formHospiceEmployeeMain.hospicesearchby.options[document.formHospiceEmployeeMain.hospicesearchby.selectedIndex].value=='I') {
		if (txtIsEmpty(document.formHospiceEmployeeMain.hospicesearchvalue)) {
			alert('Please enter the Hospice ID.');
			document.formHospiceEmployeeMain.hospicesearchvalue.focus();
			return false;
		}
	}
	else if (document.formHospiceEmployeeMain.hospicesearchby.options[document.formHospiceEmployeeMain.hospicesearchby.selectedIndex].value=='N') {
		if (txtIsEmpty(document.formHospiceEmployeeMain.hospicesearchvalue)) {
			alert('Please enter the Hospice Name.');
			document.formHospiceEmployeeMain.hospicesearchvalue.focus();
			return false;
		}
	}
	else if (document.formHospiceEmployeeMain.hospicesearchby.options[document.formHospiceEmployeeMain.hospicesearchby.selectedIndex].value=='') {
		if (!txtIsEmpty(document.formHospiceEmployeeMain.hospicesearchvalue)) {
			alert('Please select the Hospice Search Criteria.');
			document.formHospiceEmployeeMain.hospicesearchby.focus();
			return false;
		}
	}
	return true;
}
function formHospiceEmployeeMain_Search() {
	if (formHospiceEmployeeMain_VldSearch()) {
		document.formHospiceEmployeeMain.target= '_self';
		document.formHospiceEmployeeMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=search';
		document.formHospiceEmployeeMain.submit();
	}
}
function formHospiceEmployeeMain_SlctLogin(hospiceemployeeid) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeInfo?act=update&hospiceemployeeid='+ hospiceemployeeid, 'hsUpdWin', 'scrollbars, width='+ hospiceEmployeeInfoWindow_w+ ', height='+ hospiceEmployeeInfoWindow_h+ ', left='+ (screen.availWidth-hospiceEmployeeInfoWindow_w)/2+ ', top='+ (screen.availHeight-(hospiceEmployeeInfoWindow_h+ 20))/2);
}

/* hospice employee license page */
function formHospiceEmployeeLicense_OnLoad(message) {
	if (message==1) {
		alert('Your request has been sent to Bonafide Management Systems, and we will process within 24 hours.');
		window.close();
	}
	if (document.formHospiceEmployeeLicense.license) {
		document.formHospiceEmployeeLicense.license.focus();
	}
}
function formHospiceEmployeeLicense_VldSubmit() {
	if (document.formHospiceEmployeeLicense.license) {
		if (txtIsEmpty(document.formHospiceEmployeeLicense.license)) {
			alert('Please enter the number of Additional License(s) you want to purchase.');
			document.formHospiceEmployeeLicense.license.focus();
			return false;
		}
		else if (parseInt(document.formHospiceEmployeeLicense.license.value)<1) {
			alert('Please enter a valid number of Additional License(s) you want to purchase.');
			document.formHospiceEmployeeLicense.license.select();
			return false;
		}
	}
	return confirm('Are you sure you want to purchase the license?');
}
function formHospiceEmployeeLicense_Submit() {
	if (formHospiceEmployeeLicense_VldSubmit()) {
		document.formHospiceEmployeeLicense.target= '_self';
		document.formHospiceEmployeeLicense.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=purchase';
		document.formHospiceEmployeeLicense.submit();
	}
}

/* hospice employee login setup page */
function formHospiceEmployeeInfo_OnLoad(msg) {
	if (msg==1) {
		alert('The new Login Account has been created successfully.');
		window.opener.document.formHospiceEmployeeMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=search';
		window.opener.document.formHospiceEmployeeMain.submit();
		window.close();
	}
	else if (msg==2) {
		alert('The Login Account has been updated successfully.');
		window.opener.document.formHospiceEmployeeMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=search';
		window.opener.document.formHospiceEmployeeMain.submit();
		window.close();
	}
	else if (msg==3) {
		alert('The Login Account has been deleted successfully.');
		window.opener.document.formHospiceEmployeeMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeMain?act=search';
		window.opener.document.formHospiceEmployeeMain.submit();
		window.close();
	}
	else if (msg==101) {
		alert('The Login ID you entered has been used already.\nPlease change it and submit again.');
	}
	document.formHospiceEmployeeInfo.fname.focus();
}
function formHospiceEmployeeInfo_Delete() {
	if (confirm('Are you sure you want to Delete this Account?')) {
		document.getElementById('btnDelete').disabled= true;
		document.getElementById('btnSubmit').disabled= true;
		document.getElementById('btnCancel').disabled= true;
		document.formHospiceEmployeeInfo.target= '_self';
		document.formHospiceEmployeeInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeInfo?act=delete';
		document.formHospiceEmployeeInfo.submit();
	}
}
function formHospiceEmployeeInfo_VldSubmit(mode) {
	if (document.formHospiceEmployeeInfo.hospiceid.options[document.formHospiceEmployeeInfo.hospiceid.selectedIndex].value=='') {
		alert('Please select one Hospice for this login.');
		document.formHospiceEmployeeInfo.hospiceid.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospiceEmployeeInfo.loginid)) {
		alert('Please enter the Login ID.');
		document.formHospiceEmployeeInfo.loginid.focus();
		return false;
	}
	if (mode==1) {
		if (txtIsEmpty(document.formHospiceEmployeeInfo.loginpwd)) {
			alert('Please enter the Password for the user.');
			document.formHospiceEmployeeInfo.loginpwd.focus();
			return false;
		}
		if (txtIsEmpty(document.formHospiceEmployeeInfo.confirmpwd)) {
			alert('Please confirm the Password for the user.');
			document.formHospiceEmployeeInfo.confirmpwd.focus();
			return false;
		}
		if (document.formHospiceEmployeeInfo.loginpwd.value!=document.formHospiceEmployeeInfo.confirmpwd.value) {
			alert('Please confirm the password again.');
			document.formHospiceEmployeeInfo.confirmpwd.select();
			return false;
		}
	}
	else if (mode==2) {
		if ((txtIsEmpty(document.formHospiceEmployeeInfo.loginpwd)) && (!txtIsEmpty(document.formHospiceEmployeeInfo.confirmpwd))) {
			alert('Please enter the New Password for the user.');
			document.formHospiceEmployeeInfo.loginpwd.focus();
			return false;
		}
		if ((!txtIsEmpty(document.formHospiceEmployeeInfo.loginpwd)) && (txtIsEmpty(document.formHospiceEmployeeInfo.confirmpwd))) {
			alert('Please confirm the New Password for the user.');
			document.formHospiceEmployeeInfo.confirmpwd.focus();
			return false;
		}
		if ((!txtIsEmpty(document.formHospiceEmployeeInfo.loginpwd)) && (!txtIsEmpty(document.formHospiceEmployeeInfo.confirmpwd))) {
			if (document.formHospiceEmployeeInfo.loginpwd.value!=document.formHospiceEmployeeInfo.confirmpwd.value) {
				alert('Please confirm the password again.');
				document.formHospiceEmployeeInfo.confirmpwd.select();
				return false;
			}
		}
	}
	if (txtIsEmpty(document.formHospiceEmployeeInfo.lname)) {
		alert('Please enter the User Last Name.');
		document.formHospiceEmployeeInfo.lname.focus();
		return false;
	}
	if (txtIsEmpty(document.formHospiceEmployeeInfo.email)) {
		alert('Please enter the Email Address for the user.');
		document.formHospiceEmployeeInfo.email.focus();
		return false;
	}
	if (!txtIsEmpty(document.formHospiceEmployeeInfo.phone1)) {
		if (document.formHospiceEmployeeInfo.phone1.value.length!=14) {
			alert('Please enter a valid Phone Number for the user.');
			document.formHospiceEmployeeInfo.phone1.select();
			return false;
		}
	}
	if (!txtIsEmpty(document.formHospiceEmployeeInfo.phone2)) {
		if (document.formHospiceEmployeeInfo.phone2.value.length!=14) {
			alert('Please enter a valid Phone Number for the user.');
			document.formHospiceEmployeeInfo.phone2.select();
			return false;
		}
	}
	if (document.formHospiceEmployeeInfo.dmerep.options[document.formHospiceEmployeeInfo.dmerep.selectedIndex].value=='') {
		alert('Please select one Employee as the default order-creating user.');
		document.formHospiceEmployeeInfo.dmerep.focus();
		return false;
	}
	if (document.formHospiceEmployeeInfo.dmeoffice.options[document.formHospiceEmployeeInfo.dmeoffice.selectedIndex].value=='') {
		alert('Please select one Office as the default order office.');
		document.formHospiceEmployeeInfo.dmeoffice.focus();
		return false;
	}
	return true;
}
function formHospiceEmployeeInfo_Submit(mode) {
	if (formHospiceEmployeeInfo_VldSubmit(mode)) {
		if (document.getElementById('btnDelete')) {
			document.getElementById('btnDelete').disabled= true;
		}
		document.getElementById('btnSubmit').disabled= true;
		document.getElementById('btnCancel').disabled= true;
		document.formHospiceEmployeeInfo.target= '_self';
		document.formHospiceEmployeeInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmployeeInfo?act=submit';
		document.formHospiceEmployeeInfo.submit();
	}
}

/* hospice order inquiry main page */
function formHospiceOrderInquiryMain_OnLoad(msg) {
	if (msg==5) {
		alert('The order has been voided successfully.');
	}
	oDateMask= new Mask("mm/dd/yyyy", "date");
	oDateMask.attach(document.formHospiceOrderInquiryMain.orderdatefrom);
	oDateMask.attach(document.formHospiceOrderInquiryMain.orderdateend);
	document.formHospiceOrderInquiryMain.orderid.focus();
}
function formHospiceOrderInquiryMain_PatientSearchByOnChange() {
	if (document.formHospiceOrderInquiryMain.patientsearchby.options[document.formHospiceOrderInquiryMain.patientsearchby.selectedIndex].value=='') {
		document.formHospiceOrderInquiryMain.patientsearchvalue.value= '';
	}
	document.formHospiceOrderInquiryMain.patientsearchvalue.focus();
}
function formHospiceOrderInquiryMain_EmployeeSearchByOnChange() {
	if (document.formHospiceOrderInquiryMain.employeesearchby.options[document.formHospiceOrderInquiryMain.employeesearchby.selectedIndex].value=='') {
		document.formHospiceOrderInquiryMain.employeesearchvalue.value= '';
	}
	document.formHospiceOrderInquiryMain.employeesearchvalue.focus();
}
function formHospiceOrderInquiryMain_BillToSearchByOnChange() {
	if (document.formHospiceOrderInquiryMain.billtosearchby.options[document.formHospiceOrderInquiryMain.billtosearchby.selectedIndex].value=='') {
		document.formHospiceOrderInquiryMain.billtosearchvalue.value= '';
	}
	document.formHospiceOrderInquiryMain.billtosearchvalue.focus();
}
function formHospiceOrderInquiryMain_ShipToSearchByOnChange() {
	if (document.formHospiceOrderInquiryMain.shiptosearchby.options[document.formHospiceOrderInquiryMain.shiptosearchby.selectedIndex].value=='') {
		document.formHospiceOrderInquiryMain.shiptosearchvalue.value= '';
	}
	document.formHospiceOrderInquiryMain.shiptosearchvalue.focus();
}
function formHospiceOrderInquiryMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceOrderInquiryMain_Search();
	}
}
function formHospiceOrderInquiryMain_OrderStatusOnChange() {
	if (document.formHospiceOrderInquiryMain.orderstatus.options[document.formHospiceOrderInquiryMain.orderstatus.selectedIndex].value=='') {
		document.formHospiceOrderInquiryMain.displayvoidorder.checked= true;
	}
	else if (document.formHospiceOrderInquiryMain.orderstatus.options[document.formHospiceOrderInquiryMain.orderstatus.selectedIndex].value=='V') {
		document.formHospiceOrderInquiryMain.displayvoidorder.checked= true;
	}
	else {
		document.formHospiceOrderInquiryMain.displayvoidorder.checked= false;
	}
}
function formHospiceOrderInquiryMain_OrderTypeCheck(obj) {
	if (obj.checked) {
		if (obj.name=='displaypatientorderonly') {
			document.formHospiceOrderInquiryMain.displaygenericorderonly.checked= false;
		}
		else if (obj.name=='displaygenericorderonly') {
			document.formHospiceOrderInquiryMain.displaypatientorderonly.checked= false;
		}
	}
}
function formHospiceOrderInquiryMain_Refresh() {
	naviToHospiceOrderInquiryMain();
}
function formHospiceOrderInquiryMain_PageSort(page, sortby) {
	if (formHospiceOrderInquiryMain_VldSearch()) {
		document.formHospiceOrderInquiryMain.target= '_self';
		document.formHospiceOrderInquiryMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderInquiryMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospiceOrderInquiryMain.submit();
	}
}
function formHospiceOrderInquiryMain_VldSearch() {
	if (document.formHospiceOrderInquiryMain.patientsearchby.options[document.formHospiceOrderInquiryMain.patientsearchby.selectedIndex].value!='') {
		if (txtIsEmpty(document.formHospiceOrderInquiryMain.patientsearchvalue)) {
			alert('Please enter the Patient search criteria.');
			document.formHospiceOrderInquiryMain.patientsearchvalue.focus();
			return false;
		}
	}
	else {
		if (!txtIsEmpty(document.formHospiceOrderInquiryMain.patientsearchvalue)) {
			alert('Please enter the Patient search criteria.');
			document.formHospiceOrderInquiryMain.patientsearchby.focus();
			return false;
		}
	}
	if (document.formHospiceOrderInquiryMain.employeesearchby.options[document.formHospiceOrderInquiryMain.employeesearchby.selectedIndex].value!='') {
		if (txtIsEmpty(document.formHospiceOrderInquiryMain.employeesearchvalue)) {
			alert('Please enter the Employee search criteria.');
			document.formHospiceOrderInquiryMain.employeesearchvalue.focus();
			return false;
		}
	}
	else {
		if (!txtIsEmpty(document.formHospiceOrderInquiryMain.employeesearchvalue)) {
			alert('Please enter the Employee search criteria.');
			document.formHospiceOrderInquiryMain.employeesearchby.focus();
			return false;
		}
	}
	if (document.formHospiceOrderInquiryMain.billtosearchby.options[document.formHospiceOrderInquiryMain.billtosearchby.selectedIndex].value!='') {
		if (txtIsEmpty(document.formHospiceOrderInquiryMain.billtosearchvalue)) {
			alert('Please enter the Bill-To search criteria.');
			document.formHospiceOrderInquiryMain.billtosearchvalue.focus();
			return false;
		}
	}
	else {
		if (!txtIsEmpty(document.formHospiceOrderInquiryMain.billtosearchvalue)) {
			alert('Please enter the Bill-To search criteria.');
			document.formHospiceOrderInquiryMain.billtosearchby.focus();
			return false;
		}
	}
	if (document.formHospiceOrderInquiryMain.shiptosearchby.options[document.formHospiceOrderInquiryMain.shiptosearchby.selectedIndex].value!='') {
		if (txtIsEmpty(document.formHospiceOrderInquiryMain.shiptosearchvalue)) {
			alert('Please enter the Ship-To search criteria.');
			document.formHospiceOrderInquiryMain.shiptosearchvalue.focus();
			return false;
		}
	}
	else {
		if (!txtIsEmpty(document.formHospiceOrderInquiryMain.shiptosearchvalue)) {
			alert('Please enter the Ship-To search criteria.');
			document.formHospiceOrderInquiryMain.shiptosearchby.focus();
			return false;
		}
	}
	return true;
}
function formHospiceOrderInquiryMain_Search() {
	if (formHospiceOrderInquiryMain_VldSearch()) {
		document.formHospiceOrderInquiryMain.target= '_self';
		document.formHospiceOrderInquiryMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderInquiryMain?act=search';
		document.formHospiceOrderInquiryMain.submit();
	}
}
function formHospiceOrderInquiryMain_LaunchOrderReport(name) {
	if (name=='ordsum') {
		document.formHospiceOrderInquiryMain.action='/meds/hospice/function/order/report/ordsum.jsp';
	}
	else if (name=='custord') {
		document.formHospiceOrderInquiryMain.action='/meds/hospice/function/order/report/custord.jsp';
	}
	document.formHospiceOrderInquiryMain.target='rptWin';
	window.open('', 'rptWin', 'left='+ hospiceReportLeftPadding+ ', top='+ hospiceReportTopPadding+ ', width='+ (screen.availWidth-(2*hospiceReportLeftPadding+20))+ ', height='+ (screen.availHeight-(2*hospiceReportTopPadding+50))+ ', scrollbars=yes');
	document.formHospiceOrderInquiryMain.submit();
}

/* hospice order summary report */
function formHospiceOrderSummaryReport_OnLoad() {
	window.print();
}

/* hospice customer order report */
function formHospiceCustomerOrderReport_OnLoad() {
	window.print();
}

/* hospice order viewing page */
function formHospiceOrderView_OnLoad(msg) {
}
function formHospiceOrderView_Print(hospiceorderid) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceOrderPrint?hospiceorderid='+ hospiceorderid, 'ordPrintWin', 'left='+ hospiceReportLeftPadding+ ', top='+ hospiceReportTopPadding+ ', width='+ (screen.availWidth-(2*hospiceReportLeftPadding+20))+ ', height='+ (screen.availHeight-(2*hospiceReportTopPadding+50))+ ', scrollbars=yes');
}
function formHospiceOrderView_LaunchOrderDeliveryReport(hospiceorderid) {
	window.open('/meds/hospice/function/order/report/orddlvr.jsp?hospiceorderid='+ hospiceorderid, 'rptWin', 'left='+ hospiceReportLeftPadding+ ', top='+ hospiceReportTopPadding+ ', width='+ (screen.availWidth-(2*hospiceReportLeftPadding+20))+ ', height='+ (screen.availHeight-(2*hospiceReportTopPadding+50))+ ', scrollbars=yes');
}

/* hospice order delivery report */
function formHospiceOrderDeliveryReport_OnLoad() {
	window.print();
}

/* hospice order printing page */
function formHospiceOrderPrint_OnLoad() {
	window.print();
}

/* hospice order history page */
function formHospiceOrderHistory_OnLoad() {
}

/* hospice order edit header page */
function formHospiceOrderEditHdr_OnLoad(msg) {
	hospiceEditOrderOnLoadMsg(msg);
	oDateMask= new Mask("mm/dd/yyyy", "date");
	oDateMask.attach(document.formHospiceOrderEditHdr.orderdate);
	document.formHospiceOrderEditHdr.orderdate.focus();
}
function formHospiceOrderEditHdr_SearchPatient() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=search&frm=edithdr';
}
function formHospiceOrderEditHdr_FieldOnChange() {
	document.getElementById('btnSaveChange').disabled= false;
}
function formHospiceOrderEditHdr_SubmitUtil(act, svsession, svdatabase) {
	document.formHospiceOrderEditHdr.target= '_self';
	document.formHospiceOrderEditHdr.action= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditHdr?act='+ act+ '&svsession='+ ((svsession)? (1): (0))+ '&svdatabase='+ ((svdatabase)? (1): (0));
	document.formHospiceOrderEditHdr.submit();
}
function formHospiceOrderEditHdr_SaveSend() {
	if (confirm('Are you sure you want to Save and Submit this order?')) {
		formHospiceOrderEditHdr_SubmitUtil('svsend', true, true);
	}
}
function formHospiceOrderEditHdr_SaveExit() {
	formHospiceOrderEditHdr_SubmitUtil('svexit', true, true);
}

/* hospice order edit cart page */
function formHospiceOrderEditCart_OnLoad(msg) {
	hospiceEditOrderOnLoadMsg(msg);
}
function formHospiceOrderEditCart_FieldOnChange() {
	document.getElementById('btnSaveChange').disabled= false;
}
function formHospiceOrderEditCart_VldSubmitUtil() {
	if (document.formHospiceOrderEditCart.tot) {
		for (ctr=0; ctr<parseInt(document.formHospiceOrderEditCart.tot.value); ctr++) {
			var obj= eval('document.formHospiceOrderEditCart.orderqty'+ ctr);
			if (txtIsEmpty(obj)) {
				alert('Please enter the Order Quantity.');
				obj.focus();
				return false;
			}
			else if (parseInt(obj.value)<1) {
				alert('Please enter a Valid Order Quantity.');
				obj.select();
				return false;
			}
		}
	}
	return true;
}
function formHospiceOrderEditCart_SubmitUtil(act, svsession, svdatabase) {
	if (formHospiceOrderEditCart_VldSubmitUtil()) {
		document.formHospiceOrderEditCart.target= '_self';
		document.formHospiceOrderEditCart.action= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditCart?act='+ act+ '&svsession='+ ((svsession)? (1): (0))+ '&svdatabase='+ ((svdatabase)? (1): (0));
		document.formHospiceOrderEditCart.submit();
	}
}
function formHospiceOrderEditCart_RemoveItem(idx, pkhdrseq) {
	if ((pkhdrseq>0)? (confirm('This item comes from a package. Removing this item will remove the entire package from your order.\nAre you sure you want to Remove this Package from your shopping cart?')): (confirm('Are you sure you want to Remove this Item from your shopping cart?'))) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceOrderEditCart?act=rmvitem&idx='+ idx;
	}
}
function formHospiceOrderEditCart_UpdateCart() {
	formHospiceOrderEditCart_SubmitUtil('updcart', true, false);
}
function formHospiceOrderEditCart_SaveSend() {
	if (confirm('Are you sure you want to Save and Submit this order?')) {
		formHospiceOrderEditCart_SubmitUtil('svsend', true, true);
	}
}
function formHospiceOrderEditCart_SaveExit() {
	formHospiceOrderEditCart_SubmitUtil('svexit', true, true);
}

/* hospice browse items page */
function formHospiceBrowseItem_OnLoad(msg) {
	if (msg==4) {
		alert('The item has been added to your shopping cart successfully.');
	}
	document.formHospiceBrowseItem.searchdescription.focus();
}
function formHospiceBrowseItem_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceBrowseItem_Search();
	}
}
function formHospiceBrowseItem_Refresh() {
	naviToHospiceBrowseItem();
}
function formHospiceBrowseItem_PageSort(page) {
	if (formHospiceBrowseItem_VldSearch()) {
		document.formHospiceBrowseItem.target= '_self';
		document.formHospiceBrowseItem.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseItem?act=search&page='+ page;
		document.formHospiceBrowseItem.submit();
	}
}
function formHospiceBrowseItem_VldSearch() {
	return true;
}
function formHospiceBrowseItem_Search() {
	if (formHospiceBrowseItem_VldSearch()) {
		document.formHospiceBrowseItem.target= '_self';
		document.formHospiceBrowseItem.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseItem?act=search';
		document.formHospiceBrowseItem.submit();
	}
}
function formHospiceBrowseItem_ItemTypeOnChange(idx) {
	var qtyObj= eval('document.formHospiceBrowseItem.addqty'+ idx);
	var typeObj= eval('document.formHospiceBrowseItem.addtype'+ idx);
	if (typeObj.options[typeObj.selectedIndex].value=='R') {
		qtyObj.value= '1';
	}
}
function formHospiceBrowseItem_AddToCart(idx, page) {
	if (formHospiceBrowseItem_VldSearch()) {
		var qtyObj= eval('document.formHospiceBrowseItem.addqty'+ idx);
		var typeObj= eval('document.formHospiceBrowseItem.addtype'+ idx);
		if (txtIsEmpty(qtyObj)) {
			alert('Please enter the Order Quantity.');
			qtyObj.focus();
		}
		else if (parseInt(qtyObj.value)<1) {
			alert('Please enter a Valid Order Quantity.');
			qtyObj.select();
		}
		else if (typeObj.options[typeObj.selectedIndex].value=='') {
			alert('Please select the Item Type.');
			typeObj.focus();
		}
		else if ((parseInt(qtyObj.value)>1) && (typeObj.options[typeObj.selectedIndex].value=='R')) {
			alert('Order Quantity for rental item should always be One.');
			qtyObj.select();
		}
		else {
			document.getElementById('btnAdd'+ idx).disabled= true;
			document.formHospiceBrowseItem.target= '_self';
			document.formHospiceBrowseItem.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseItem?act=add&idx='+ idx+ '&page='+ page;
			document.formHospiceBrowseItem.submit();
		}
	}
}

/* hospice browse contract items page */
function formHospiceBrowseContract_OnLoad(msg) {
	if (msg==4) {
		alert('The item(s) has been added to your shopping cart successfully.');
	}
}
function formHospiceBrowseContract_CheckPackage(obj) {
	var typeitemidlist= obj.value.split(',');
	for (ctr=0; ctr<typeitemidlist.length; ctr++) {
		var chkobj= eval("document.getElementById('_citemid"+ typeitemidlist[ctr]+ "')");
		if ((chkobj) && (!chkobj.disabled)) {
			chkobj.checked= obj.checked;
		}
	}
}
function formHospiceBrowseContract_SelectOrDeselect(mode) {
	for (ctr=0; ctr<document.formHospiceBrowseContract.elements.length; ctr++) {
		if (document.formHospiceBrowseContract.elements[ctr].type=='checkbox') {
			var obj= document.formHospiceBrowseContract.elements[ctr];
			if (!obj.disabled) {
				if ((obj.name.length>7) && (obj.name.substring(0,7)=='citemid')) {
					obj.checked= mode;
				}
			}
		}
	}
}
function formHospiceBrowseContract_AddToCart() {
	var itemslct= false;
	for (ctr=0; ctr<document.formHospiceBrowseContract.elements.length; ctr++) {
		if (document.formHospiceBrowseContract.elements[ctr].type=='checkbox') {
			var obj= document.formHospiceBrowseContract.elements[ctr];
			if (!obj.disabled) {
				if ((obj.name.length>7) && (obj.name.substring(0,7)=='citemid') && (obj.checked)) {
					itemslct= true;
					break;
				}
			}
		}
	}
	if (!itemslct) {
		alert('Please select at least One Item to add to your shopping cart.');
		return;
	}
	else {
		document.getElementById('btnSal').disabled= true;
		document.getElementById('btnDal').disabled= true;
		document.getElementById('btnAdd').disabled= true;
		document.formHospiceBrowseContract.target= '_self';
		document.formHospiceBrowseContract.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseContract?act=add&extra=0';
		document.formHospiceBrowseContract.submit();
	}
}
function formHospiceBrowseContract_AddSingleExtraToCart(hospicecontractid, titleid, itemid) {
	if (confirm('This contract item has been added to your shopping cart for the patient.\nDo you want to add an extra one? (Separate rental charge may apply.)')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowseContract?act=add&extra=1&tot=1&contractid='+ hospicecontractid+ '&citemtitleid0='+ titleid+ '&citemid0='+ itemid;
	}
}

/* hospice browse packages page */
function formHospiceBrowsePk_OnLoad(msg) {
	if (msg==4) {
		alert('The package has been added to your shopping cart successfully.');
	}
	document.formHospiceBrowsePk.searchpackage.focus();
}
function formHospiceBrowsePk_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceBrowsePk_Search();
	}
}
function formHospiceBrowsePk_Refresh() {
	naviToHospiceBrowsePk();
}
function formHospiceBrowsePk_PageSort(page) {
	if (formHospiceBrowsePk_VldSearch()) {
		document.formHospiceBrowsePk.target= '_self';
		document.formHospiceBrowsePk.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowsePk?act=search&page='+ page;
		document.formHospiceBrowsePk.submit();
	}
}
function formHospiceBrowsePk_VldSearch() {
	return true;
}
function formHospiceBrowsePk_Search() {
	if (formHospiceBrowsePk_VldSearch()) {
		document.formHospiceBrowsePk.target= '_self';
		document.formHospiceBrowsePk.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowsePk?act=search';
		document.formHospiceBrowsePk.submit();
	}
}
function formHospiceBrowsePk_AddToCart(idx, page) {
	if (formHospiceBrowsePk_VldSearch()) {
		var qtyObj= eval('document.formHospiceBrowsePk.addqty'+ idx);
		if (txtIsEmpty(qtyObj)) {
			alert('Please enter the Order Quantity.');
			qtyObj.focus();
		}
		else if (parseInt(qtyObj.value)<1) {
			alert('Please enter a Valid Order Quantity.');
			qtyObj.select();
		}
		else {
			document.getElementById('btnAdd'+ idx).disabled= true;
			document.formHospiceBrowsePk.target= '_self';
			document.formHospiceBrowsePk.action= '/meds/servlet/com.meds.hospice.servlet.HospiceBrowsePk?act=add&idx='+ idx+ '&page='+ page;
			document.formHospiceBrowsePk.submit();
		}
	}
}

/* hospice contract setup main page */
function formHospiceContractMain_OnLoad(msg) {
	if (window.parent.header.functionname) {
		hdrTitle('Contract Setup');
	}
	document.formHospiceContractMain.hospicesearchvalue.focus();
}
function formHospiceContractMain_NaviToNewContract() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractInfo?act=new';
}
function formHospiceContractMain_NaviToEditContract(hospicecontractid) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractInfo?act=update&hospicecontractid='+ hospicecontractid;
}
function formHospiceContractMain_HospiceSearchByOnChange() {
	if (document.formHospiceContractMain.hospicesearchby.options[document.formHospiceContractMain.hospicesearchby.selectedIndex].value!='') {
		document.formHospiceContractMain.hospicesearchvalue.focus();
	}
}
function formHospiceContractMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceContractMain_Search();
	}
}
function formHospiceContractMain_Refresh() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=refresh';
}
function formHospiceContractMain_PageSort(page, sortby) {
	if (formHospiceContractMain_VldSearch()) {
		document.formHospiceContractMain.target= '_self';
		document.formHospiceContractMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospiceContractMain.submit();
	}
}
function formHospiceContractMain_VldSearch() {
	if (document.formHospiceContractMain.hospicesearchby.options[document.formHospiceContractMain.hospicesearchby.selectedIndex].value=='I') {
		if (txtIsEmpty(document.formHospiceContractMain.hospicesearchvalue)) {
			alert('Please enter the Hospice ID.');
			document.formHospiceContractMain.hospicesearchvalue.focus();
			return false;
		}
	}
	else if (document.formHospiceContractMain.hospicesearchby.options[document.formHospiceContractMain.hospicesearchby.selectedIndex].value=='N') {
		if (txtIsEmpty(document.formHospiceContractMain.hospicesearchvalue)) {
			alert('Please enter the Hospice Name.');
			document.formHospiceContractMain.hospicesearchvalue.focus();
			return false;
		}
	}
	else if (document.formHospiceContractMain.hospicesearchby.options[document.formHospiceContractMain.hospicesearchby.selectedIndex].value=='') {
		if (!txtIsEmpty(document.formHospiceContractMain.hospicesearchvalue)) {
			alert('Please select the Hospice Search Criteria.');
			document.formHospiceContractMain.hospicesearchby.focus();
			return false;
		}
	}
	return true;
}
function formHospiceContractMain_Search() {
	if (formHospiceContractMain_VldSearch()) {
		document.formHospiceContractMain.target= '_self';
		document.formHospiceContractMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=search';
		document.formHospiceContractMain.submit();
	}
}
function formHospiceContractMain_AssignGroup(hospicecontractid) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceContractType?hospicecontractid='+ hospicecontractid, 'typeWin', 'scrollbars, width=700, height=675, left='+ (screen.availWidth-700)/2+ ', top=25');
}
function formHospiceContractMain_ContractItemPricing(hospicecontractid) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceContractCharge?hospicecontractid='+ hospicecontractid, 'chargeWin', 'scrollbars, width=700, height=675, left='+ (screen.availWidth-700)/2+ ', top=25');
}
function formHospiceContractMain_ExtraDeliveryPricing(hospicecontractid) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceContractExtra?hospicecontractid='+ hospicecontractid, 'extraWin', 'scrollbars, width=725, height=675, left='+ (screen.availWidth-725)/2+ ', top=25');
}
function formHospiceContractMain_DeleteContract(hospicecontractid) {
	if (confirm('Are you sure you want to Delete this Contract?')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=delete_contract&hospicecontractid='+ hospicecontractid;
	}
}
function formHospiceContractMain_DeleteContractItem(contractitemsysid) {
	if (confirm('Are you sure you want to Remove the Item from this contract?')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=delete_contractitem&contractitemsysid='+ contractitemsysid;
	}
}
function formHospiceContractMain_EditContractItemTitle(titleid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=init&frm=contractmain&target=hdr&titleid='+ titleid+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=500, height=350, left='+ (screen.availWidth-500)/2+ ', top='+ (screen.availHeight-350)/2);
}
function formHospiceContractMain_EditContractItemCustomizedTitle(contractid, titleid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=init&frm=contractmain&target=cus&titleid='+ titleid+ '&page='+ page+ '&sortby='+ sortby+ '&contractid='+ contractid, 'editCusWin', 'width=500, height=350, left='+ (screen.availWidth-500)/2+ ', top='+ (screen.availHeight-350)/2);
}
function formHospiceContractMain_UploadImage(titleid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=init&target=upl&titleid='+ titleid+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=500, height=40, left='+ (screen.availWidth-500)/2+ ', top='+ (screen.availHeight-40)/2);
}
function formHospiceContractMain_HideDisplayItemDiv(idx) {
	var divObj= document.getElementById('citemdiv'+ idx);
	if (divObj) {
		if (divObj.style.display=='block') {
			divObj.style.display= 'none';
		}
		else if (divObj.style.display=='none') {
			divObj.style.display= 'block';
		}
	}
}

/* hospice contract setup info page */
function formHospiceContractInfo_OnLoad(msg) {
	if (msg==1) {
		alert('The contract has been created successfully.');
		formHospiceContractInfo_NaviToContractMain();
		return;
	}
	else if (msg==2) {
		alert('The contract has been updated successfully.');
		formHospiceContractInfo_NaviToContractMain();
		return;
	}
	else if (msg==3) {
		alert('The contract has been deleted successfully.');
		formHospiceContractInfo_NaviToContractMain();
		return;
	}
	else if (msg==107) {
		alert('There is already a contract created for this hospice.\nThe current contract data was not saved.');
	}
	document.formHospiceContractInfo.description.focus();
}
function formHospiceContractInfo_NaviToContractMain() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain';
}
function formHospiceContractInfo_VldSubmit() {
	if (document.formHospiceContractInfo.hospiceid.options[document.formHospiceContractInfo.hospiceid.selectedIndex].value=='') {
		alert('Please select one Hospice.');
		document.formHospiceContractInfo.hospiceid.focus();
		return false;
	}
	if ((txtIsEmpty(document.formHospiceContractInfo.drate)) && (txtIsEmpty(document.formHospiceContractInfo.wrate)) && (txtIsEmpty(document.formHospiceContractInfo.mrate))) {
		alert('Please enter the Contract Rental Rates.');
		document.formHospiceContractInfo.drate.focus();
		return false;
	}
	if (window.eitem.document.formHospiceContractInfoExistItem.tot) {
		if (parseInt(window.eitem.document.formHospiceContractInfoExistItem.tot.value)<1) {
			alert('Please assign at least One Item to this contract.');
			return false;
		}
	}
	return true;
}
function formHospiceContractInfo_Submit() {
	if (formHospiceContractInfo_VldSubmit()) {
		document.formHospiceContractInfo.target= '_self';
		document.formHospiceContractInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractInfo?act=submit';
		document.formHospiceContractInfo.submit();
	}
}
function formHospiceContractInfo_Delete() {
	if (confirm('Are you sure you want to Delete this Contract?')) {
		document.formHospiceContractInfo.target= '_self';
		document.formHospiceContractInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractInfo?act=delete';
		document.formHospiceContractInfo.submit();
	}
}
function formHospiceContractInfo_InvSearchFieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceContractInfo_InvSearch();
	}
}
function formHospiceContractInfo_VldInvSearch() {
	if ((txtIsEmpty(document.formHospiceContractInfo.searchdescription)) && (txtIsEmpty(document.formHospiceContractInfo.searchmake)) && (txtIsEmpty(document.formHospiceContractInfo.searchpartno))) {
		alert('Please enter your Search Criteria.');
		document.formHospiceContractInfo.searchdescription.focus();
		return false;
	}
	return true;
}
function formHospiceContractInfo_InvSearch() {
	if (formHospiceContractInfo_VldInvSearch()) {
		document.formHospiceContractInfo.target= 'sitem';
		document.formHospiceContractInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractItemSearch?act=search';
		document.formHospiceContractInfo.submit();
	}
}
function formHospiceContractInfo_InvSearchRefresh() {
	window.sitem.document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractItemSearch?act=refresh';
	document.formHospiceContractInfo.searchdescription.value= '';
	document.formHospiceContractInfo.searchmake.value= '';
	document.formHospiceContractInfo.searchpartno.value= '';
	document.formHospiceContractInfo.searchdescription.focus();
}
function formHospiceContractInfo_VldInvSearchAdd() {
	if (window.sitem.document.formHospiceContractInfoSrchItem.sct) {
		if (parseInt(window.sitem.document.formHospiceContractInfoSrchItem.sct.value)==0) {
			var oneSlct= false;
			for (ctr=0; ctr<window.sitem.document.formHospiceContractInfoSrchItem.elements.length; ctr++) {
				if (window.sitem.document.formHospiceContractInfoSrchItem.elements[ctr].type=='checkbox') {
					if ((!window.sitem.document.formHospiceContractInfoSrchItem.elements[ctr].disabled) && (window.sitem.document.formHospiceContractInfoSrchItem.elements[ctr].checked)) {
						oneSlct= true;
						break;
					}
				}
			}
			if (!oneSlct) {
				alert('Please select at least One Item to add to the contract.');
				return false;
			}
		}
	}
	return true;
}
function formHospiceContractInfo_InvSearchAdd() {
	if (formHospiceContractInfo_VldInvSearchAdd()) {
		window.sitem.document.formHospiceContractInfoSrchItem.target= '_self';
		window.sitem.document.formHospiceContractInfoSrchItem.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractItemSearch?act=add';
		window.sitem.document.formHospiceContractInfoSrchItem.submit();
	}
}

/* hospice contract setup info page - existing item iframe page */
function formHospiceContractInfoExistItem_OnLoad(msg) {
}
function formHospiceContractInfoExistItem_RemoveItem(idx) {
	if (confirm('Are you sure you want to Remove this item from the contract?')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceContractInfo?act=rmvitem&idx='+ idx;
	}
}

/* hospice contract setup info page - search item iframe page */
function formHospiceContractInfoSrchItem_OnLoad(msg) {
	if (msg==4) {
		alert('All selected items have been added to your contract successfully.');
		window.parent.eitem.document.location.href= '/meds/hospice/function/contract/iframe/eitem.jsp';
	}
}
function formHospiceContractInfoSrchItem_PageSort(page, sortby) {
	document.formHospiceContractInfoSrchItem.target= '_self';
	document.formHospiceContractInfoSrchItem.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractItemSearch?act=search&page='+ page+ '&sortby='+ sortby;
	document.formHospiceContractInfoSrchItem.submit();
}

/* hospice contract setup type page */
function formHospiceContractType_OnLoad(msg, newtypeid) {
	if (msg==1) {
		alert('The new contract type record has been created successfully.\nNow you can assign items to this contract type.');
		if (document.formHospiceContractType.rdo) {
			if (document.formHospiceContractType.rdo.length) {
				for (ctr=0; ctr<document.formHospiceContractType.rdo.length; ctr++) {
					if (parseInt(eval('document.formHospiceContractType.typeid'+ ctr).value)==newtypeid) {
						document.formHospiceContractType.rdo[ctr].checked= true;
						formHospiceContractType_RadioOnClick(ctr, false);
						break;
					}
				}
			}
			else {
				if (document.formHospiceContractType.typeid0) {
					if (parseInt(document.formHospiceContractType.typeid0.value)==newtypeid) {
						document.formHospiceContractType.rdo.checked= true;
						formHospiceContractType_RadioOnClick(0, false);
					}
				}
			}
		}
	}
	else if (msg==9) {
		alert('The contract type record has been saved successfully.');
	}
	else if (msg==108) {
		alert('The contract type name you entered already exists.\nPlease change and submit again.');
	}
	if (document.formHospiceContractType.typeid.value=='') {
		document.formHospiceContractType.typename.value= '';
		document.formHospiceContractType.typename.disabled= true;
		document.getElementById('btnSv').disabled= true;
	}
	document.formHospiceContractType.newtypename.focus();
}
function formHospiceContractType_RadioOnClick(idx, precheck) {
	for (ctr=0; ctr<document.formHospiceContractType.elements.length; ctr++) {
		if (document.formHospiceContractType.elements[ctr].type=='checkbox') {
			if (document.formHospiceContractType.elements[ctr].checked) {
				var obj= document.formHospiceContractType.elements[ctr];
				if ((obj.name.length>3) && (obj.name.substring(0,3)=='chk')) {
					obj.checked= false;
				}
			}
		}
	}
	if (precheck) {
		var idlist= window.event.srcElement.value.split(',');
		for (ctr=0; ctr<idlist.length; ctr++) {
			var chkobj= eval('document.getElementById("_chk'+ idlist[ctr]+ '")');
			if (chkobj) {
				chkobj.checked= true;
			}
		}
	}
	document.formHospiceContractType.typeid.value= eval('document.formHospiceContractType.typeid'+ idx).value;
	document.formHospiceContractType.typename.value= eval('document.formHospiceContractType.typename'+ idx).value;
	document.formHospiceContractType.typename.disabled= false;
	document.getElementById('btnSv').disabled= false;
}
function formHospiceContractType_DeleteContractType(typeid) {
	if (confirm('Are you sure you want to Delete this Contract Type?')) {
		document.formHospiceContractType.target= '_self';
		document.formHospiceContractType.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractType?act=delete&typeid='+ typeid;
		document.formHospiceContractType.submit();
	}
}
function formHospiceContractType_AddNewKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceContractType_AddNew();
	}
}
function formHospiceContractType_VldAddNew() {
	if (txtIsEmpty(document.formHospiceContractType.newtypename)) {
		alert('Please enter the Contract Type Name.');
		document.formHospiceContractType.newtypename.focus();
		return false;
	}
	return true;
}
function formHospiceContractType_AddNew() {
	if (formHospiceContractType_VldAddNew()) {
		document.formHospiceContractType.target= '_self';
		document.formHospiceContractType.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractType?act=new';
		document.formHospiceContractType.submit();
	}
}
function formHospiceContractType_VldSave() {
	if (document.formHospiceContractType.typeid.disabled) {
		alert('Please select one Contract Type.');
		return false;
	}
	else if (txtIsEmpty(document.formHospiceContractType.typeid)) {
		alert('Please select one Contract Type.');
		return false;
	}
	if (document.formHospiceContractType.typename.disabled) {
		alert('Please select one Contract Type.');
		return false;
	}
	else if (txtIsEmpty(document.formHospiceContractType.typename)) {
		alert('Please enter the Contract Type Name.');
		document.formHospiceContractType.typename.focus();
		return false;
	}
	var oneChk= false;
	for (ctr=0; ctr<document.formHospiceContractType.elements.length; ctr++) {
		if (document.formHospiceContractType.elements[ctr].type=='checkbox') {
			if (document.formHospiceContractType.elements[ctr].checked) {
				var obj= document.formHospiceContractType.elements[ctr];
				if ((obj.name.length>3) && (obj.name.substring(0,3)=='chk')) {
					if (obj.checked) {
						oneChk= true;
					}
				}
			}
		}
	}
	if (!oneChk) {
		alert('Please assign at least One Item to this contract type.');
		return false;
	}
	return true;
}
function formHospiceContractType_Save() {
	if (formHospiceContractType_VldSave()) {
		document.formHospiceContractType.target= '_self';
		document.formHospiceContractType.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractType?act=save';
		document.formHospiceContractType.submit();
	}
}

/* hospice contract setup extra delivery pricing page */
function formHospiceContractExtra_OnLoad(msg) {
	if (msg==2) {
		alert('The extra item delivery pricing setup has been saved successfully.');
		window.close();
	}
}
function formHospiceContractExtra_VldSubmit() {
	if (document.formHospiceContractExtra.tot) {
		for (ctr=0; ctr<parseInt(document.formHospiceContractExtra.tot.value); ctr++) {
			var cobj= eval('document.formHospiceContractExtra.chargeby'+ ctr);
			var aobj= eval('document.formHospiceContractExtra.amount'+ ctr);
			var fobj= eval('document.formHospiceContractExtra.factor'+ ctr);
			if ((cobj.options[cobj.selectedIndex].value!='') && (txtIsEmpty(aobj))) {
				alert('Please enter the Amount.');
				aobj.focus();
				return false;
			}
			else if ((cobj.options[cobj.selectedIndex].value=='') && (!txtIsEmpty(aobj))) {
				alert('Please select the Charge By method.');
				cobj.focus();
				return false;
			}
			else if ((cobj.options[cobj.selectedIndex].value!='') && (!txtIsEmpty(aobj))) {
				if (parseFloat(aobj.value)<=0.0) {
					alert('Please enter a Valid Amount.');
					aobj.select();
					return false;
				}
				else {
					if (txtIsEmpty(fobj)) {
						alert('Please enter the Quantity Limit.');
						fobj.focus();
						return false;
					}
					else if (parseInt(fobj.value)<1) {
						alert('Please enter a valid Quantity Limit.');
						fobj.select();
						return false;
					}
				}
			}
			else if ((cobj.options[cobj.selectedIndex].value=='') && (txtIsEmpty(aobj))) {
				if (!txtIsEmpty(fobj)) {
					if (parseInt(fobj.value)<1) {
						alert('Please enter a valid Quantity Limit.');
						fobj.select();
						return false;
					}
					else {
						alert('Please enter the Charge By method and the Amount.');
						cobj.focus();
						return false;
					}
				}
			}
		}
	}
	return true;
}
function formHospiceContractExtra_Submit() {
	if (formHospiceContractExtra_VldSubmit()) {
		document.formHospiceContractExtra.target= '_self';
		document.formHospiceContractExtra.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractExtra?act=save';
		document.formHospiceContractExtra.submit();
	}
}

/* hospice contract charge setup page */
function formHospiceContractCharge_OnLoad(msg) {
	if (msg==2) {
		alert('The contract item pricing setup has been saved successfully.');
		window.close();
	}
}
function formHospiceContractCharge_VldSubmit() {
	if (document.formHospiceContractCharge.tot) {
		for (ctr=0; ctr<parseInt(document.formHospiceContractCharge.tot.value); ctr++) {
			var cobj= eval('document.formHospiceContractCharge.chargeby'+ ctr);
			var aobj= eval('document.formHospiceContractCharge.amount'+ ctr);
			if ((cobj.options[cobj.selectedIndex].value!='') && (txtIsEmpty(aobj))) {
				alert('Please enter the Amount.');
				aobj.focus();
				return false;
			}
			else if ((cobj.options[cobj.selectedIndex].value=='') && (!txtIsEmpty(aobj))) {
				alert('Please select the Charge By method.');
				cobj.focus();
				return false;
			}
			else if ((cobj.options[cobj.selectedIndex].value!='') && (!txtIsEmpty(aobj))) {
				if (parseFloat(aobj.value)<=0.0) {
					alert('Please enter a Valid Amount.');
					aobj.select();
					return false;
				}
			}
		}
	}
	return true;
}
function formHospiceContractCharge_Submit() {
	if (formHospiceContractCharge_VldSubmit()) {
		document.formHospiceContractCharge.target= '_self';
		document.formHospiceContractCharge.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractCharge?act=save';
		document.formHospiceContractCharge.submit();
	}
}

/* hospice inventory setup main page */
function formHospiceInvMain_OnLoad(msg) {
	if (window.parent.header.functionname) {
		hdrTitle('Item Setup');
	}
	document.formHospiceInvMain.searchdescription.focus();
}
function formHospiceInvMain_NaviToInvAdd() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceInvAdd';
}
function formHospiceInvMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceInvMain_Search();
	}
}
function formHospiceInvMain_Refresh() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=refresh';
}
function formHospiceInvMain_PageSort(page, sortby) {
	if (formHospiceInvMain_VldSearch()) {
		document.formHospiceInvMain.target= '_self';
		document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospiceInvMain.submit();
	}
}
function formHospiceInvMain_VldSearch() {
	return true;
}
function formHospiceInvMain_Search() {
	if (formHospiceInvMain_VldSearch()) {
		document.formHospiceInvMain.target= '_self';
		document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=search';
		document.formHospiceInvMain.submit();
	}
}
function formHospiceInvMain_EditStphdr(titleid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=init&target=hdr&titleid='+ titleid+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=500, height=350, left='+ (screen.availWidth-500)/2+ ', top='+ (screen.availHeight-350)/2);
}
function formHospiceInvMain_UploadImage(titleid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=init&target=upl&titleid='+ titleid+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=500, height=40, left='+ (screen.availWidth-500)/2+ ', top='+ (screen.availHeight-40)/2);
}
function formHospiceInvMain_EditStpdtl(hospicehisysid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=init&target=dtl&hospicehisysid='+ hospicehisysid+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=375, height=160, left='+ (screen.availWidth-375)/2+ ', top='+ (screen.availHeight-160)/2);
}
function formHospiceInvMain_RemoveStpdtl(hospicehisysid) {
	if (confirm('Are you sure you want to Remove this item setup from your online shopping center?\n(We will NOT delete this item record from your database.)')) {
		if (formHospiceInvMain_VldSearch()) {
			document.formHospiceInvMain.target= '_self';
			document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=remove&hospicehisysid='+ hospicehisysid;
			document.formHospiceInvMain.submit();
		}
	}
}

/* hospice add new inventory setup page */
function formHospiceInvAdd_OnLoad(msg) {
	if (msg==4) {
		alert('The items have been added to your online shopping center successfully.');
		formHospiceInvAdd_NaviToInvMain();
	}
	document.formHospiceInvAdd.searchmake.focus();
}
function formHospiceInvAdd_DisablePageButtons() {
	if (document.getElementById('btnSch')) {
		document.getElementById('btnSch').disabled= true;
	}
	if (document.getElementById('btnRef')) {
		document.getElementById('btnRef').disabled= true;
	}
	if (document.getElementById('btnBck')) {
		document.getElementById('btnBck').disabled= true;
	}
	if (document.getElementById('btnAdd')) {
		document.getElementById('btnAdd').disabled= true;
	}
}
function formHospiceInvAdd_NaviToInvMain() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain';
}
function formHospiceInvAdd_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceInvAdd_Search();
	}
}
function formHospiceInvAdd_Refresh() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceInvAdd?act=refresh';
}
function formHospiceInvAdd_PageSort(page, sortby) {
	if (formHospiceInvAdd_VldSearch()) {
		formHospiceInvAdd_DisablePageButtons();
		document.formHospiceInvAdd.target= '_self';
		document.formHospiceInvAdd.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvAdd?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospiceInvAdd.submit();
	}
}
function formHospiceInvAdd_VldSearch() {
	if ((txtIsEmpty(document.formHospiceInvAdd.searchmake)) && (txtIsEmpty(document.formHospiceInvAdd.searchpartno)) && (txtIsEmpty(document.formHospiceInvAdd.searchdescription))) {
		alert('Please enter at least One Search Criteria before search.');
		document.formHospiceInvAdd.searchmake.focus();
		return false;
	}
	if (document.formHospiceInvAdd.tot) {
		for (ctr=0; ctr<parseInt(document.formHospiceInvAdd.tot.value); ctr++) {
			if (txtIsEmpty(eval('document.formHospiceInvAdd.description'+ ctr))) {
				alert('Please enter a Short Description for the item.');
				eval('document.formHospiceInvAdd.description'+ ctr).focus();
				return false;
			}
		}
	}
	return true;
}
function formHospiceInvAdd_Search() {
	if (formHospiceInvAdd_VldSearch()) {
		formHospiceInvAdd_DisablePageButtons();
		document.formHospiceInvAdd.target= '_self';
		document.formHospiceInvAdd.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvAdd?act=search';
		document.formHospiceInvAdd.submit();
	}
}
function formHospiceInvAdd_VldAddItem(existing) {
	if (existing==0) {
		var current= 0;
		for (ctr=0; ctr<document.formHospiceInvAdd.elements.length; ctr++) {
			if (document.formHospiceInvAdd.elements[ctr].type=='checkbox') {
				if (document.formHospiceInvAdd.elements[ctr].checked) {
					current++;
					break;
				}
			}
		}
		if (current==0) {
			alert('Please select at least One Item.');
			document.formHospiceInvAdd.searchmake.focus();
			return false;
		}
	}
	if (document.formHospiceInvAdd.searchhospice.options[document.formHospiceInvAdd.searchhospice.selectedIndex].value=='-1') {
		alert('Please select a Hospice or All Hospices for your setup.');
		document.formHospiceInvAdd.searchhospice.focus();
		return false;
	}
	if (!formHospiceInvAdd_VldSearch()) {
		return false;
	}
	return true;
}
function formHospiceInvAdd_AddItem(existing) {
	if (formHospiceInvAdd_VldAddItem(existing)) {
		if (confirm('Are you sure you want to Add all the checked item(s) to your online shopping center for '+ ((document.formHospiceInvAdd.searchhospice.options[document.formHospiceInvAdd.searchhospice.selectedIndex].value=='')? ('All Hospices'): (document.formHospiceInvAdd.searchhospice.options[document.formHospiceInvAdd.searchhospice.selectedIndex].text))+ '?')) {
			formHospiceInvAdd_DisablePageButtons();
			document.formHospiceInvAdd.target= '_self';
			document.formHospiceInvAdd.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvAdd?act=add';
			document.formHospiceInvAdd.submit();
		}
	}
}

/* hospice edit inventory setup header page */
function formHospiceInvEditHdr_OnLoad(msg) {
	if (msg==2) {
		alert('The item setup has been updated successfully.');
		if (document.formHospiceInvEditHdr.frm.value=='contractmain') {
			window.opener.document.formHospiceContractMain.target= '_self';
			window.opener.document.formHospiceContractMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=search&page='+ document.formHospiceInvEditHdr.page.value+ '&sortby='+ document.formHospiceInvEditHdr.sortby.value;
			window.opener.document.formHospiceContractMain.submit();
			window.close();
		}
		else {
			window.opener.document.formHospiceInvMain.target= '_self';
			window.opener.document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=search&page='+ document.formHospiceInvEditHdr.page.value+ '&sortby='+ document.formHospiceInvEditHdr.sortby.value;
			window.opener.document.formHospiceInvMain.submit();
			window.close();
		}
	}
	document.formHospiceInvEditHdr.description.focus();
}
function formHospiceInvEditHdr_VldSubmit() {
	if (txtIsEmpty(document.formHospiceInvEditHdr.description)) {
		alert('Please enter a Short Description for this item.');
		document.formHospiceInvEditHdr.description.focus();
		return false;
	}
	return true;
}
function formHospiceInvEditHdr_Submit() {
	if (formHospiceInvEditHdr_VldSubmit()) {
		document.formHospiceInvEditHdr.target= '_self';
		document.formHospiceInvEditHdr.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=submit&target=hdr';
		document.formHospiceInvEditHdr.submit();
	}
}

/* hospice edit inventory customized setup header page */
function formHospiceInvEditCus_OnLoad(msg) {
	if (msg==2) {
		alert('The item setup has been updated successfully.');
		if (document.formHospiceInvEditCus.frm.value=='contractmain') {
			window.opener.document.formHospiceContractMain.target= '_self';
			window.opener.document.formHospiceContractMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceContractMain?act=search&page='+ document.formHospiceInvEditCus.page.value+ '&sortby='+ document.formHospiceInvEditCus.sortby.value;
			window.opener.document.formHospiceContractMain.submit();
			window.close();
		}
		else {
			window.opener.document.formHospiceInvMain.target= '_self';
			window.opener.document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=search&page='+ document.formHospiceInvEditCus.page.value+ '&sortby='+ document.formHospiceInvEditCus.sortby.value;
			window.opener.document.formHospiceInvMain.submit();
			window.close();
		}
	}
	document.formHospiceInvEditCus.description.focus();
}
function formHospiceInvEditCus_VldSubmit() {
	if (txtIsEmpty(document.formHospiceInvEditCus.description)) {
		alert('Please enter a Short Description for this item.');
		document.formHospiceInvEditCus.description.focus();
		return false;
	}
	return true;
}
function formHospiceInvEditCus_Submit() {
	if (formHospiceInvEditCus_VldSubmit()) {
		document.formHospiceInvEditCus.target= '_self';
		document.formHospiceInvEditCus.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=submit&target=cus';
		document.formHospiceInvEditCus.submit();
	}
}

/* hospice edit inventory upload image page */
function formHospiceInvEditUpl_OnLoad(msg) {
	if (msg==8) {
		alert('The image has been uploaded successfully.');
		if (window.opener.document.formHospiceContractMain) {
			window.close();
		}
		else if (window.opener.document.formHospiceInvMain) {
			window.opener.document.formHospiceInvMain.target= '_self';
			window.opener.document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=search&page='+ document.formHospiceInvEditUpl.page.value+ '&sortby='+ document.formHospiceInvEditUpl.sortby.value;
			window.opener.document.formHospiceInvMain.submit();
			window.close();
		}
	}
	else if (msg==106) {
		alert('The image upload process was failed.\nPlease limit your image size to less than 3 MB and try again.');
	}
	document.formHospiceInvEditUpl.imagefile.focus();
}
function formHospiceInvEditUpl_VldSubmit() {
	if (txtIsEmpty(document.formHospiceInvEditUpl.imagefile)) {
		alert('Please select one image file from your local computer.');
		document.formHospiceInvEditUpl.imagefile.focus();
		return false;
	}
	return true;
}
function formHospiceInvEditUpl_Submit() {
	if (formHospiceInvEditUpl_VldSubmit()) {
		document.formHospiceInvEditUpl.target= '_self';
		document.formHospiceInvEditUpl.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=submit&target=upl&titleid='+ document.formHospiceInvEditUpl.titleid.value+ '&page='+ document.formHospiceInvEditUpl.page.value+ '&sortby='+ document.formHospiceInvEditUpl.sortby.value;
		document.formHospiceInvEditUpl.submit();
	}
}

/* hospice edit inventory setup detail page */
function formHospiceInvEditDtl_OnLoad(msg) {
	if (msg==2) {
		alert('The item setup has been updated successfully.');
		window.opener.document.formHospiceInvMain.target= '_self';
		window.opener.document.formHospiceInvMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvMain?act=search&page='+ document.formHospiceInvEditDtl.page.value+ '&sortby='+ document.formHospiceInvEditDtl.sortby.value;
		window.opener.document.formHospiceInvMain.submit();
		window.close();
	}
}
function formHospiceInvEditDtl_VldSubmit() {
	return true;
}
function formHospiceInvEditDtl_Submit() {
	if (formHospiceInvEditDtl_VldSubmit()) {
		document.formHospiceInvEditDtl.target= '_self';
		document.formHospiceInvEditDtl.action= '/meds/servlet/com.meds.hospice.servlet.HospiceInvEdit?act=submit&target=dtl';
		document.formHospiceInvEditDtl.submit();
	}
}

/* hospice package setup main page */
function formHospicePkMain_OnLoad(msg) {
	if (window.parent.header.functionname) {
		hdrTitle('Package Setup');
	}
	document.formHospicePkMain.searchdescription.focus();
}
function formHospicePkMain_LaunchPackageAdd() {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospicePkAdd', 'addWin', 'width=525, height=465, left='+ (screen.availWidth-525)/2+ ', top='+ (screen.availHeight-465)/2);
}
function formHospicePkMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospicePkMain_Search();
	}
}
function formHospicePkMain_Refresh() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain?act=refresh';
}
function formHospicePkMain_PageSort(page, sortby) {
	if (formHospicePkMain_VldSearch()) {
		document.formHospicePkMain.target= '_self';
		document.formHospicePkMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospicePkMain.submit();
	}
}
function formHospicePkMain_VldSearch() {
	return true;
}
function formHospicePkMain_Search() {
	if (formHospicePkMain_VldSearch()) {
		document.formHospicePkMain.target= '_self';
		document.formHospicePkMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain?act=search';
		document.formHospicePkMain.submit();
	}
}
function formHospicePkMain_ViewPkItem(pkhdrseq) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospicePkItem?pkhdrseq='+ pkhdrseq, 'pkItemWin', 'scrollbars, width=600, height=450, left='+ (screen.availWidth-600)/2+ ', top='+ (screen.availHeight-450)/2);
}
function formHospicePkMain_EditPackageTitle(pkhdrseq, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospicePkEdit?act=init&target=title&pkhdrseq='+ pkhdrseq+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=500, height=300, left='+ (screen.availWidth-500)/2+ ', top='+ (screen.availHeight-300)/2);
}
function formHospicePkMain_EditPackagePrice(pkhdrseq, hospicehpksysid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospicePkEdit?act=init&target=price&pkhdrseq='+ pkhdrseq+ '&hospicehpksysid='+ hospicehpksysid+ '&page='+ page+ '&sortby='+ sortby, 'editWin', 'width=450, height=250, left='+ (screen.availWidth-450)/2+ ', top='+ (screen.availHeight-250)/2);
}
function formHospicePkMain_RemovePackagePrice(hospicehpksysid) {
	if (confirm('Are you sure you want to Remove this package setup from your online shopping center?')) {
		if (formHospicePkMain_VldSearch()) {
			document.formHospicePkMain.target= '_self';
			document.formHospicePkMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain?act=remove&hospicehpksysid='+ hospicehpksysid;
			document.formHospicePkMain.submit();
		}
	}
}

/* hospice edit package title setup page */
function formHospicePkEditTitle_OnLoad(msg) {
	if (msg==2) {
		alert('The package setup has been updated successfully.');
		window.opener.document.formHospicePkMain.target= '_self';
		window.opener.document.formHospicePkMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain?act=search&page='+ document.formHospicePkEditTitle.page.value+ '&sortby='+ document.formHospicePkEditTitle.sortby.value;
		window.opener.document.formHospicePkMain.submit();
		window.close();
	}
	document.formHospicePkEditTitle.oldescription.focus();
}
function formHospicePkEditTitle_VldSubmit() {
	if (txtIsEmpty(document.formHospicePkEditTitle.oldescription)) {
		alert('Please enter the Package Name.');
		document.formHospicePkEditTitle.oldescription.focus();
		return false;
	}
	return true;
}
function formHospicePkEditTitle_Submit() {
	if (formHospicePkEditTitle_VldSubmit()) {
		document.formHospicePkEditTitle.target= '_self';
		document.formHospicePkEditTitle.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkEdit?act=submit&target=title';
		document.formHospicePkEditTitle.submit();
	}
}

/* hospice edit package price setup page */
function formHospicePkEditPrice_OnLoad(msg) {
	if (msg==2) {
		alert('The package setup has been updated successfully.');
		window.opener.document.formHospicePkMain.target= '_self';
		window.opener.document.formHospicePkMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain?act=search&page='+ document.formHospicePkEditPrice.page.value+ '&sortby='+ document.formHospicePkEditPrice.sortby.value;
		window.opener.document.formHospicePkMain.submit();
		window.close();
	}
}
function formHospicePkEditPrice_VldSubmit() {
	return true;
}
function formHospicePkEditPrice_Submit() {
	if (formHospicePkEditPrice_VldSubmit()) {
		document.formHospicePkEditPrice.target= '_self';
		document.formHospicePkEditPrice.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkEdit?act=submit&target=price';
		document.formHospicePkEditPrice.submit();
	}
}

/* hospice add new package setup page */
function formHospicePkAdd_OnLoad(msg) {
	if (msg==4) {
		if (confirm('The package has been setup successfully. Do you want to add another one?\nClick OK to add another package or Cancel to exit this page.')) {
			document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePkAdd';
		}
		else {
			window.opener.document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePkMain';
			window.close();
		}
	}
	formHospicePkAdd_PackageOnChange();
	document.formHospicePkAdd.pkhdrseq.focus();
}
function formHospicePkAdd_PackageOnChange() {
	if (document.formHospicePkAdd.pkhdrseq.options[document.formHospicePkAdd.pkhdrseq.selectedIndex].value=='') {
		document.formHospicePkAdd.price.disabled= false;
		document.formHospicePkAdd.drate.disabled= false;
		document.formHospicePkAdd.wrate.disabled= false;
		document.formHospicePkAdd.mrate.disabled= false;
	}
	else {
		var tmp= document.formHospicePkAdd.pkhdrseq.options[document.formHospicePkAdd.pkhdrseq.selectedIndex].value;
		if (tmp.indexOf('|')>-1) {
			if (tmp.substring(tmp.indexOf('|')+1)=='Y') {
				document.formHospicePkAdd.price.disabled= false;
				document.formHospicePkAdd.drate.disabled= false;
				document.formHospicePkAdd.wrate.disabled= false;
				document.formHospicePkAdd.mrate.disabled= false;
				document.formHospicePkAdd.message.value= '(kit package)';
			}
			else if (tmp.substring(tmp.indexOf('|')+1)=='N') {
				document.formHospicePkAdd.price.value= '';
				document.formHospicePkAdd.drate.value= '';
				document.formHospicePkAdd.wrate.value= '';
				document.formHospicePkAdd.mrate.value= '';
				document.formHospicePkAdd.price.disabled= true;
				document.formHospicePkAdd.drate.disabled= true;
				document.formHospicePkAdd.wrate.disabled= true;
				document.formHospicePkAdd.mrate.disabled= true;
				document.formHospicePkAdd.message.value= '(non-kit package)';
			}
		}
	}
}
function formHospicePkAdd_VldSubmit() {
	if (document.formHospicePkAdd.pkhdrseq.options[document.formHospicePkAdd.pkhdrseq.selectedIndex].value=='') {
		alert('Please select one Package before submit.');
		document.formHospicePkAdd.pkhdrseq.focus();
		return false;
	}
	return true;
}
function formHospicePkAdd_Submit() {
	if (formHospicePkAdd_VldSubmit()) {
		document.formHospicePkAdd.target= '_self';
		document.formHospicePkAdd.action= '/meds/servlet/com.meds.hospice.servlet.HospicePkAdd?act=submit';
		document.formHospicePkAdd.submit();
	}
}

/* hospice pickup request main page */
function formHospicePickupRequestMain_OnLoad(msg) {
	if (msg==3) {
		alert('The pickup request has been deleted successfully.');
	}
	oDateMask= new Mask("mm/dd/yyyy", "date");
	oDateMask.attach(document.formHospicePickupRequestMain.scheduledatefrom);
	oDateMask.attach(document.formHospicePickupRequestMain.scheduledateend);
	document.formHospicePickupRequestMain.patientsearchvalue.focus();
}
function formHospicePickupRequestMain_SearchPatient() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=search&frm=pickupreq';
}
function formHospicePickupRequestMain_PatientSearchByOnChange() {
	if (document.formHospicePickupRequestMain.patientsearchby.options[document.formHospicePickupRequestMain.patientsearchby.selectedIndex].value=='') {
		document.formHospicePickupRequestMain.patientsearchvalue.value= '';
	}
	document.formHospicePickupRequestMain.patientsearchvalue.focus();
}
function formHospicePickupRequestMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospicePickupRequestMain_Search();
	}
}
function formHospicePickupRequestMain_Refresh() {
	naviToHospicePickupRequestMain();
}
function formHospicePickupRequestMain_PageSort(page, sortby) {
	if (formHospicePickupRequestMain_VldSearch()) {
		document.formHospicePickupRequestMain.target= '_self';
		document.formHospicePickupRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospicePickupRequestMain.submit();
	}
}
function formHospicePickupRequestMain_VldSearch() {
	return true;
}
function formHospicePickupRequestMain_Search() {
	if (formHospicePickupRequestMain_VldSearch()) {
		document.formHospicePickupRequestMain.target= '_self';
		document.formHospicePickupRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestMain?act=search';
		document.formHospicePickupRequestMain.submit();
	}
}
function formHospicePickupRequestMain_SlctPickup(pickupno) {
	naviToHospiceUpdatePickupRequest(pickupno);
}
function formHospicePickupRequestMain_DeletePickup(pickupno, page, sortby) {
	if (confirm('Are you sure you want to Delete this Pickup Schedule?')) {
		document.formHospicePickupRequestMain.target= '_self';
		document.formHospicePickupRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestMain?act=delete&pickupno='+ pickupno+ '&page='+ page+ '&sortby='+ sortby;
		document.formHospicePickupRequestMain.submit();
	}
}

/* hospice pickup request info page */
function formHospicePickupRequestInfo_OnLoad(msg) {
	if (msg==1) {
		alert('The pickup request has been created successfully.');
		naviToHospicePickupRequestMain();
	}
	else if (msg==2) {
		alert('The pickup request has been updated successfully.');
		naviToHospicePickupRequestMain();
	}
	oDateMask= new Mask("mm/dd/yyyy", "date");
	oDateMask.attach(document.formHospicePickupRequestInfo.scheduledate);
	oDateMask.attach(document.formHospicePickupRequestInfo.deceaseddate);
	document.formHospicePickupRequestInfo.scheduledate.focus();
}
function formHospicePickupRequestInfo_VldSubmit() {
	if (txtIsEmpty(document.formHospicePickupRequestInfo.scheduledate)) {
		alert('Please enter the Pickup Scheduled Date.');
		document.formHospicePickupRequestInfo.scheduledate.focus();
		return false;
	}
	else {
		if (document.formHospicePickupRequestInfo.scheduledate.value.length!=10) {
			alert('Please enter a valid Pickup Scheduled Date.');
			document.formHospicePickupRequestInfo.scheduledate.select();
			return false;
		}
	}
	if (!txtIsEmpty(document.formHospicePickupRequestInfo.deceaseddate)) {
		if (document.formHospicePickupRequestInfo.deceaseddate.value.length!=10) {
			alert('Please enter a valid Patient Deceased Date.');
			document.formHospicePickupRequestInfo.deceaseddate.select();
			return false;
		}
	}
	var oneChecked= false;
	for (ctr=0; ctr<parseInt(document.formHospicePickupRequestInfo.tot.value); ctr++) {
		var chkObj= eval('document.formHospicePickupRequestInfo.chk'+ ctr);
		if ((chkObj) && (chkObj.checked)) {
			var qtyObj= eval('document.formHospicePickupRequestInfo.pickupqty'+ ctr);
			var maxObj= eval('document.formHospicePickupRequestInfo.maxqty'+ ctr);
			if ((qtyObj) && (maxObj)) {
				if (txtIsEmpty(qtyObj)) {
					alert('Please enter the Pickup Quantity.');
					qtyObj.focus();
					return false;
				}
				else {
					if (parseInt(qtyObj.value)<1) {
						alert('Please enter a valie Pickup Quantity.');
						qtyObj.select();
						return false;
					}
					else if (parseInt(qtyObj.value)>parseInt(maxObj.value)) {
						alert('The pickup quantity you entered Exceeds the Maximum Available quantity ('+ parseInt(maxObj.value)+ ').');
						qtyObj.select();
						return false;
					}
				}
				oneChecked= true;
			}
		}
	}
	if (!oneChecked) {
		alert('Please select at least One Item for pickup.');
		return false;
	}
	return true;
}
function formHospicePickupRequestInfo_Submit() {
	if (formHospicePickupRequestInfo_VldSubmit()) {
		document.getElementById('btnSubmit').disabled= true;
		document.getElementById('btnCancel').disabled= true;
		document.formHospicePickupRequestInfo.target= '_self';
		document.formHospicePickupRequestInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospicePickupRequestInfo?act=submit';
		document.formHospicePickupRequestInfo.submit();
	}
}

/* hospice service request main page */
function formHospiceServiceRequestMain_OnLoad(msg) {
	if (msg==3) {
		alert('The service request has been deleted successfully.');
	}
	oDateMask= new Mask("mm/dd/yyyy", "date");
	oDateMask.attach(document.formHospiceServiceRequestMain.requestdatefrom);
	oDateMask.attach(document.formHospiceServiceRequestMain.requestdateend);
	document.formHospiceServiceRequestMain.patientsearchvalue.focus();
}
function formHospiceServiceRequestMain_SearchPatient() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=search&frm=servicereq';
}
function formHospiceServiceRequestMain_PatientSearchByOnChange() {
	if (document.formHospiceServiceRequestMain.patientsearchby.options[document.formHospiceServiceRequestMain.patientsearchby.selectedIndex].value=='') {
		document.formHospiceServiceRequestMain.patientsearchvalue.value= '';
	}
	document.formHospiceServiceRequestMain.patientsearchvalue.focus();
}
function formHospiceServiceRequestMain_FieldKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceServiceRequestMain_Search();
	}
}
function formHospiceServiceRequestMain_Refresh() {
	naviToHospiceServiceRequestMain();
}
function formHospiceServiceRequestMain_PageSort(page, sortby) {
	if (formHospiceServiceRequestMain_VldSearch()) {
		document.formHospiceServiceRequestMain.target= '_self';
		document.formHospiceServiceRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain?act=search&page='+ page+ '&sortby='+ sortby;
		document.formHospiceServiceRequestMain.submit();
	}
}
function formHospiceServiceRequestMain_VldSearch() {
	return true;
}
function formHospiceServiceRequestMain_Search() {
	if (formHospiceServiceRequestMain_VldSearch()) {
		document.formHospiceServiceRequestMain.target= '_self';
		document.formHospiceServiceRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain?act=search';
		document.formHospiceServiceRequestMain.submit();
	}
}
function formHospiceServiceRequestMain_SlctService(dueid, page, sortby) {
	window.open('/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain?act=update_view&dueid='+ dueid+ '&page='+ page+ '&sortby='+ sortby, 'serviceUpdWin', 'width=450, height=400, left='+ (screen.availWidth-450)/2+ ', top='+ (screen.availHeight-400)/2);
}
function formHospiceServiceRequestMain_DeleteService(dueid, page, sortby) {
	if (confirm('Are you sure you want to Delete this Service Request?')) {
		document.formHospiceServiceRequestMain.target= '_self';
		document.formHospiceServiceRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain?act=delete&dueid='+ dueid+ '&page='+ page+ '&sortby='+ sortby;
		document.formHospiceServiceRequestMain.submit();
	}
}

/* hospice service request update page */
function formHospiceServiceRequestUpd_OnLoad(msg) {
	if (msg==2) {
		alert('This service request record has been updated successfully.');
		window.opener.document.formHospiceServiceRequestMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain?act=search&page='+ document.formHospiceServiceRequestUpd.page.value+ '&sortby='+ document.formHospiceServiceRequestUpd.sortby.value;
		window.opener.document.formHospiceServiceRequestMain.submit();
		window.close();
	}
	document.formHospiceServiceRequestUpd.memo.focus();
}
function formHospiceServiceRequestUpd_Submit() {
	document.formHospiceServiceRequestUpd.target= '_self';
	document.formHospiceServiceRequestUpd.action= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestMain?act=update_submit';
	document.formHospiceServiceRequestUpd.submit();
}

/* hospice service request info page */
function formHospiceServiceRequestInfo_OnLoad(msg) {
	if (msg==1) {
		alert('The service request has been created successfully.');
		naviToHospiceServiceRequestMain();
	}
}
function formHospiceServiceRequestInfo_VldSubmit() {
	var oneChecked= false;
	for (ctr=0; ctr<parseInt(document.formHospiceServiceRequestInfo.tot.value); ctr++) {
		var chkObj= eval('document.formHospiceServiceRequestInfo.chk'+ ctr);
		if ((chkObj) && (chkObj.checked)) {
			oneChecked= true;
		}
	}
	if (!oneChecked) {
		alert('Please select at least One Item for service.');
		return false;
	}
	return true;
}
function formHospiceServiceRequestInfo_Submit() {
	if (formHospiceServiceRequestInfo_VldSubmit()) {
		document.getElementById('btnSubmit').disabled= true;
		document.getElementById('btnCancel').disabled= true;
		document.formHospiceServiceRequestInfo.target= '_self';
		document.formHospiceServiceRequestInfo.action= '/meds/servlet/com.meds.hospice.servlet.HospiceServiceRequestInfo?act=submit';
		document.formHospiceServiceRequestInfo.submit();
	}
}

/* hospice email main page */
function formHospiceEmailMain_OnLoad(msg) {
	if (window.parent.header.functionname) {
		hdrTitle('Email Setup');
	}
	if (msg==4) {
		alert('The email address has been added to the confirmation list successfully.');
	}
	else if (msg==2) {
		alert('The email confirmation list has been updated successfully.');
	}
	else if (msg==3) {
		alert('The email address has been deleted successfully.');
	}
	document.formHospiceEmailMain.emailaddress.focus();
}
function formHospiceEmailMain_VldAddNewEmail() {
	if (txtIsEmpty(document.formHospiceEmailMain.emailaddress)) {
		alert('Please enter an email address.');
		document.formHospiceEmailMain.emailaddress.focus();
		return false;
	}
	return true;
}
function formHospiceEmailMain_AddNewEmail() {
	if (formHospiceEmailMain_VldAddNewEmail()) {
		document.formHospiceEmailMain.target= '_self';
		document.formHospiceEmailMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmailMain?act=add';
		document.formHospiceEmailMain.submit();
	}
}
function formHospiceEmailMain_Refresh() {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceEmailMain';
}
function formHospiceEmailMain_Search() {
	document.formHospiceEmailMain.target= '_self';
	document.formHospiceEmailMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmailMain?act=search';
	document.formHospiceEmailMain.submit();
}
function formHospiceEmailMain_SearchOnKeyDown(event) {
	if (event.keyCode==13) {
		formHospiceEmailMain_Search();
	}
}
function formHospiceEmailMain_FieldOnChange() {
	document.getElementById('btnSubmit').disabled= false;
}
function formHospiceEmailMain_VldUpdateEmail() {
	if (document.formHospiceEmailMain.tot) {
		for (ctr=0; ctr<parseInt(document.formHospiceEmailMain.tot.value); ctr++) {
			var emailObj= eval('document.formHospiceEmailMain.emailaddress'+ ctr);
			var eventObj= eval('document.formHospiceEmailMain.emailevent'+ ctr);
			if (emailObj) {
				if (txtIsEmpty(emailObj)) {
					alert('Please enter an email address.');
					emailObj.focus();
					return false;
				}
			}
		}
	}
	return true;
}
function formHospiceEmailMain_UpdateEmail() {
	if (formHospiceEmailMain_VldUpdateEmail()) {
		document.formHospiceEmailMain.target= '_self';
		document.formHospiceEmailMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmailMain?act=update';
		document.formHospiceEmailMain.submit();
	}
}
function formHospiceEmailMain_DeleteEmail(hospiceemailid) {
	if (confirm('Are you sure you want to Delete this Email Setup?')) {
		document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospiceEmailMain?act=delete&hospiceemailid='+ hospiceemailid;
	}
}
function formHospiceEmailMain_PageSort(page, sortBy) {
	document.formHospiceEmailMain.target= '_self';
	document.formHospiceEmailMain.action= '/meds/servlet/com.meds.hospice.servlet.HospiceEmailMain?act=pagesort&page=' + page;
	document.formHospiceEmailMain.submit();
}

/* hospice reports menu */
function formHospiceReportMain_SearchPatient(report) {
	document.location.href= '/meds/servlet/com.meds.hospice.servlet.HospicePatientMain?act=search&frm='+ report;
}
