var staffCursor=0;var staffCurrent=0;var staffPrevCurrent=0;var commSent=false;var staffWidgetId=0;var staffCommClick=0;var comRequest=new Array();var commIndex=new Array();function launchStaffCom(A){staffWidgetId=A;resetStaffCom();showStaffComPanel()}function assignMessage(){for(var A=0;A<7;A++){comRequest[A]=0}}function resetStaffCom(){comRequest=new Array();commIndex=new Array();assignMessage();staffCursor=0;staffCurrent=0;staffPrevCurrent=0;painAlertClick=0;scrollComPanel(0,4)}function staffComKeyHandler(D){switch(D){case rcOK:var C="staffUrge"+staffCursor;commSent=true;if(comRequest[staffCurrent]==1){comRequest[staffCurrent]=0;if(document.getElementById(C)!=null){document.getElementById(C).style.visibility="hidden"}}else{comRequest[staffCurrent]=1;if(document.getElementById(C)!=null){document.getElementById(C).style.visibility="visible"}}break;case rcMENU:try{document.getElementById("staffComRow"+staffCursor).style.background="url('./view/tv/images/painAlertUnSel.png') no-repeat";document.getElementById("staffComRow"+staffCursor).style.backgroundRepeat="no-repeat"}catch(B){}if(commSent){getComIndex();saveStaffData()}else{hideSeleStaffComm();staffComActive=false;showGoPanel();showGuidePanel()}break;case rcDOWN:if(staffCurrent==6){break}staffPrevCurrent=staffCursor;staffCurrent++;if(staffCursor<4){staffCursor++;highLightComOptions()}else{var E=staffCurrent-4;var A=staffCurrent;scrollComPanel(E,A)}staffCommClick=staffCurrent-staffCursor;break;case rcUP:if(staffCurrent==0){break}staffPrevCurrent=staffCursor;staffCurrent--;if(staffCursor!=0){staffCursor--;highLightComOptions()}else{var E=staffCurrent;var A=staffCurrent+4;scrollComPanel(E,A)}staffCommClick=staffCurrent-staffCursor;break;case rcREFRESH:break}}function highLightComOptions(){try{document.getElementById("staffComRow"+staffPrevCurrent).style.background="url('./view/tv/images/painAlertUnSel.png') no-repeat";document.getElementById("staffComRow"+staffPrevCurrent).style.backgroundRepeat="no-repeat"}catch(A){}try{document.getElementById("staffComRow"+staffCursor).style.background="url('./view/tv/images/painAlertSel.png') no-repeat";document.getElementById("staffComRow"+staffCursor).style.backgroundRepeat="no-repeat"}catch(A){}}function scrollComPanel(F,A){var C=0;for(var B=F;B<=A;++B){var E="staffMessage"+C;var D=staffMessages(B);document.getElementById(E).innerHTML=(D.length>16?D:D);E="staffCom"+C;document.getElementById(E).innerHTML=B+1;E="staffUrge"+C;if(comRequest[B]==1){document.getElementById(E).style.visibility="visible"}else{document.getElementById(E).style.visibility="hidden"}C++}highLightComOptions()}function staffMessages(A){var B="";switch(A){case 0:B="My telephone is not working";break;case 1:B="My meal has not arrived yet";break;case 2:B="I need assistance to use the restroom";break;case 3:B="I need assistance for a walk";break;case 4:B="My room has not been cleaned today";break;case 5:B="I need information on my CareTeam";break;case 6:B="I need assistance to raise my bed ";break}return B}function saveStaffData(){var A=commIndex.join("|");var B="method=saveStaffComInfo&widgetId="+staffWidgetId+"&serial="+serial+"&commIndex="+A;createAjaxRequest();if(ajaxRequest==null){return }ajaxRequest.onreadystatechange=function(){if(ajaxRequest.readyState==4){if(ajaxRequest.status==200){if(ajaxRequest.responseText=="recall"){saveStaffData()}else{hideSeleStaffComm();staffComActive=false;showGoPanel();showGuidePanel()}}else{if(ajaxRequest.status==500){failureInfo()}}}};ajaxRequest.open("POST","/TvHandler",true);ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");ajaxRequest.send(B);return false}function getComIndex(){var B=0;for(var A=0;A<comRequest.length;A++){if(comRequest[A]==1){commIndex[B]=A;++B}}}function hideSeleStaffComm(){for(var A=0;A<=4;A++){var B="staffUrge"+A;if(document.getElementById(B)!=null){document.getElementById(B).style.visibility="hidden"}}}function highLightStaffpanel(A){document.getElementById("staffPanel"+A).style.background="#fcf3b8"}function hideStaffCommPanel(A){document.getElementById("staffPanel"+A).style.background="none"}function moveStaffPanel(A){if(A==1){staffComKeyHandler(rcUP)}else{if(A==2){staffComKeyHandler(rcDOWN)}}}function staffPanelHome(B){var A="";A=(B==1?"#fcf3b8":"none");document.getElementById("staffPanelHomeBtn").style.background=A}function escapeStaffPanel(){staffComKeyHandler(rcMENU)}function selStaffCom(A){staffPrevCurrent=staffCursor;staffCursor=A;staffCurrent=A+staffCommClick;highLightComOptions()}function staffComAction(A){staffComKeyHandler(rcOK)}