function switchHintState(a,b){var c=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=SWITCH_HINT_STATE',0);c.add('TF_HINT_FAQ_ID',a);c.add('TF_HINT_SECTION_ID',b);var d=c.get()}function hideOrShowHint(a,b){hideOrShowElement("hint"+a);switchHintState(a,b)}function showSurveyCriteriaDiv(a,b,c){document.getElementById('wholePage').style.display="inline";showMenu(a,b,'',0,0,'',c,500)}function hideSurveyCriteriaDiv(a){hideRegion(a);document.getElementById('wholePage').style.display="none"}function hideOrShowElement(a){var b=document.getElementById(a);if(b){if(b.style.display=='none'){b.style.display=""}else{b.style.display="none"}}}function hideRegion(a){var b=document.getElementById(a);if(b){b.style.display='none'}}function updateSurvey(a){var b=document.getElementById('P0_SURVEY_RECORD_ID').value;var c=document.getElementById('P0_SURVEY_MED_LIST_ID').value;var d=b==-1;hideRegion(a);setIdAndRedirect(c,d)}function changeSurveyRecord(a,b){if(confirm(b)){doSubmit(a)}else{doSubmit('RESET_SURVEY_RECORD')}}function takeSurveyEditAction(a,b){closeCurrent('genericPopup');var c=document.getElementById('P0_SURVEY_EDIT_MENU');if(c){for(i=0;i<c.options.length;i++){if(c.options[i].selected){b=c.options[i].value;break}}}if(b=="SAVE"){if(a){doSubmit("SAVE_SURVEY")}else{enableSaveAsDiv()}}else if(b=="SAVE_NEW_PATIENT"){enableImportDiv('importNewPatientDiv');var d=document.getElementById('P0_RECORD_NAME');d.focus()}else if(b=="SAVE_NEW_REFERENCE"){enableImportDiv('importNewReferenceDiv');var d=document.getElementById('P0_REFERENCE_NAME');d.focus()}else if(b=="START_NEW"){removeAll("Changes to the meds list you have been working on have not been saved and will be discarded. Do you want to continue? Click Cancel if you'd like to return to your current meds list and save it first.")}else if(b=="MERGE_INTO_PATIENT"){enableImportDiv('importPatientDiv')}else if(b=="MERGE_INTO_REFERENCE"){enableImportDiv('importReferenceDiv')}}function enableImportDiv(a){var b=document.getElementById(a);if(b){b.style.display="inline";document.getElementById('wholePage').style.display="inline"}}function saveSurvey(){var a=document.getElementById('P0_SURVEY_DESCRIPTION');if(a==null||a.value==null||a.value==""){alert("Please Give Your List a Description");a.focus()}else{doSubmit("SAVE_SURVEY")}}function cancelSave(){document.getElementById('wholePage').style.display="none";document.getElementById("saveSurveyAs").style.display="none";document.getElementById("importPatientDiv").style.display="none";document.getElementById("importReferenceDiv").style.display="none";document.getElementById("importNewPatientDiv").style.display="none";document.getElementById("importNewReferenceDiv").style.display="none";var a=document.getElementById('P0_SURVEY_EDIT_MENU');if(a){a.options[0].selected=true}document.getElementById('P0_RECORD_NAME').value='';document.getElementById('P0_SEX_0').checked=true;document.getElementById('P0_SEX_1').checked=false;document.getElementById('P0_BIRTHYEAR').value='';document.getElementById('P0_REAL_FLAG_0').checked=false;document.getElementById('P0_REFERENCE_ID').value=-1;document.getElementById('P0_REFERENCE_NAME').value='';document.getElementById('P0_MED_LIST_NAME').value=''}function enableSaveAsDiv(){var a=document.getElementById("saveSurveyAs");if(a){a.style.display="inline";document.getElementById('wholePage').style.display="inline"}}function sideEffectSeverityToolTip(a,b,c){var d;if(c=="Major"){d="<b>Major</b><br/> - May be life threatening."}else if(c=="Minor"){d="<b>Minor</b><br/> - Not life threatening."}var e=document.getElementById('genericPopupTitle');e.innerHTML=d;showMenu(a,b,'',0,15,'','genericPopup')}function medlistObjectExistsToolTip(a,b,c){var d;if(c=="Condition"){d="This condition already exists<br/>in the Patient Med Cabinet."}else if(c=="Med"){d="This medication already exists<br/>in the Medlist / Patient Med Cabinet."}var e=document.getElementById('genericPopupTitle');e.innerHTML=d;showMenu(a,b,'',0,15,'','genericPopup')}function contraindicationSeverityToolTip(a,b,c){var d;if(c=="Absolute Contraindications"){d="<b>Absolute Contraindication - Most significant contraindication warning</b>.  <br/>Indicates that the drug should never be given to patients with <br/>one of the listed conditions because harm is likely to occur."}else if(c=="Relative Contraindications"){d="<b>Relative Contraindication - Clinically significant contraindication warning</b>.  <br/>Indicates that the listed conditions can be managed/treated <br/>before the drug may be given safely."}else if(c=="Contraindication Warnings"){d="<b>Contraindication Warning - Least significant contraindication warning</b>.  <br/>Indicates that adequate monitoring of patients with the <br/>listed conditions may make it safer for the drug's use."}var e=document.getElementById('genericPopupTitle');e.innerHTML=d;showMenu(a,b,'',0,15,'','genericPopup')}function pregnancyPrecautionSeverityToolTip(a,b,c,d,e){var f;if(c=="FDA-A"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDA pregnancy risk category A <br/> - Evidence of no risk</b> </br>Adequate & well-controlled studies in pregnant woen have failed to demonstrate a risk to the fetus in 1st trimester of pregnancy (and no evidence of risk in later trimesters)."}else if(c=="FDA-B"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDA pregnancy risk category B</b></br>Animal studies have failed to demonstrate a risk to the fetus but there are no well-controlled studies in pregnant women; or animal reproduction studies have shown an adverse effect (other than decrease in fertility), but adequate and well-controlled studies in pregnant women have failed to demonstate a risk to the fetus during the first trimester of pregnancy (and there is no evidence of a risk in later trimesters."}else if(c=="FDA-C"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDA pregnancy risk category C</b></br>Animal studies have shown adverse effect on fetus but no well-controlled studies in humans; potential benefits may warrant use in pregnant women despite potential risks; or no animal reproduction studies and no adequate and well-controlled studies in humans."}else if(c=="FDA-D"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDA pregnancy risk category D</b></br>Positive evidence of human fetal risk based on investigation or marketing information but potential benefits may warrant use of drug in pregnant women despite potential risks."}else if(c=="FDA-X"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDA pregnancy risk category X</b></br>Studies in animals or humans have shown fetal abnormalities and/or there is positive evidence of fetal risk based on investigational or marketing information and risks involved in use of drug in pregnant women clearly outweigh potential benefits."}else if(c=="FDB-1"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDB severity 1</b></br>No fda rating but is contraindicated or not recommended; may have animal and/or human studies or pre or postmarketing information. this is an fdb-assigned value."}else if(c=="FDB-2"){f="<b>"+d+"<br/><br/>Pregnancy Precaution Comments<br/></b>"+e+"<br/><br/><b>FDB severity 2</b></br>No fda rating but has precautions or warnings; may have animal and/or human studies or pre or post marketing information. this is an fdb-assigned value."}var g=document.getElementById('genericPopupTitle');g.innerHTML=f;showMenu(a,b,'',0,15,'','genericPopup',225)}function generalPrecautionSeverityToolTip(a,b,c,d,e,f){var g;if(f!=""){g="<b>"+e+"<br/><br/>"+c+" Comments<br/></b>"+f;var h=document.getElementById('genericPopupTitle');h.innerHTML=g;showMenu(a,b,'',0,15,'','genericPopup',225)}}function interactionSeverityToolTip(a,b,c){var d;if(c=="Severe"){d="<b>Severe Severity Interaction</b><br/> - These medicines are contraindicated and not usually taken together."}else if(c=="Serious"){d="<b>Serious Severity Interaction</b><br/> - These medicines may interact and cause very harmful effects."}else if(c=="Moderate"){d="<b>Moderate Severity Interaction</b><br/> - These medicines may cause some risk when taken together."}else if(c=="Unknown"){d="<b>Unknown Severity Interaction</b><br/> - These medicines may cause some risk when taken together."}var e=document.getElementById('genericPopupTitle');e.innerHTML=d;showMenu(a,b,'',0,15,'','genericPopup')}function removeTip(a,b,c){toolTip_enable(a,b,'<b> Remove '+c+' from survey</b>')}function infoTip(a,b,c){toolTip_enable(a,b,'<b> Click to View <br/>'+c+'<br/>Med Info Sheet</b>')}function graphInfoTip(a,b,c,d){toolTip_enable(a,b,'<b> '+c+' - </br> '+d+' </b>')}function getScrollWidth(){var a=0,myHeight=0;if(typeof(window.innerWidth)=='number'){a=window.innerWidth;myHeight=window.innerHeight}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){a=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){a=document.body.clientWidth;myHeight=document.body.clientHeight}return a}function XDSOC(){var a=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;return document.all?a.scrollLeft:pageXOffset}function toolTip_enable(a,b,c,d,f){a=(a)?a:((window.event)?event:null);var g=a.pageX?a.pageX:a.clientX+getScrollXY()[0];var h=a.pageY?a.pageY:a.clientY+getScrollXY()[1];if(toolTip_init()){tt_target=b;if(!c){c=b.getAttribute("htmldb:tip")}var i='<!--[if lte IE 6.5]><iframe class="hideSelect"></iframe><![endif]-->';if(gToolTipContent){gToolTipContent.innerHTML=c+i}else{gToolTip.innerHTML=c+i}if(!!d){gToolTip.style.width=d+"px"}if(!!f){gToolTip.style.backgroundColor=f}else{gToolTip.style.backgroundColor="lightyellow"}gToopTipPointer.style.left=(10+g)+"px";gToopTipPointer.style.top=(15+h)+"px";gToolTip.style.top=(28+h)+"px";gToolTip.style.left=(7+g)+"px";gToolTip.style.visibility="visible";gToolTip.style.zIndex=10000;gToopTipPointer.style.zIndex=10001;gToopTipPointer.style.visibility="visible";if((gToolTip.scrollWidth+7+g)>(getScrollWidth()+XDSOC())){var j=document.all?5:20;var k=(getScrollWidth()+XDSOC()-gToolTip.scrollWidth-j);gToopTipPointer.style.left=(g)+"px";if(g+gToopTipPointer.scrollWidth>k+gToolTip.scrollWidth){gToopTipPointer.style.left=(getScrollWidth()+XDSOC()-gToopTipPointer.scrollWidth-j)+"px"}gToolTip.style.left=k+"px"}try{b.addEventListener("mouseout",toolTip_disable,false)}catch(e){b.attachEvent('onmouseout',toolTip_disable)}}return false}function stopDingOnEnter(a){if(document.all){document.getElementById(a).onkeypress=function(){return stopRKey(event)}}else{document.getElementById(a).onkeypress=function(e){return stopRKey(e)}}}function nothing(){return};function runAbbySurvey(a){if(a=='TRUE'){var b=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=generateNewAbbySurvey',0);gReturn=b.GetAsync(nothing)}}function checkIfSurveyIsDone(a){var b=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=checkIfSurveyIsDone',0);gReturn=b.get();if(gReturn!="0"){var x=document.getElementById(a);x.disabled=false}else{setTimeout("checkIfSurveyIsDone('"+a+"')",1000)}}var v_oldValues=new Array();var v_selectListContainers=new Array();var v_appItemTable=new Array();var v_appItemColumn=new Array();var v_matchcolor=new Array();var v_nomatchcolor=new Array();var v_enterFunctions=new Array();var c_SelectListSize=8;function register(a,b,c,d,f,g){v_oldValues[a]=html_GetElement(a).value;v_selectListContainers[a]=document.createElement("div");v_selectListContainers[a].setAttribute("id","_"+a+"_CONTAINER");v_selectListContainers[a].style.zIndex=1000;v_selectListContainers[a].style.position="relative";v_selectListContainers[a].style.left="0px";v_selectListContainers[a].style.top="0px";html_GetElement(a).parentNode.appendChild(v_selectListContainers[a]);v_selectListContainers[a].appendChild(html_GetElement(a));if(document.all){html_GetElement(a).onkeyup=function(){return showSelectList(event)};html_GetElement(a).onkeypress=function(){return stopRKey(event)}}else{html_GetElement(a).onkeyup=function(e){return showSelectList(e)};html_GetElement(a).onkeypress=function(e){return stopRKey(e)}}v_appItemTable[a]=b;v_appItemColumn[a]=c;v_matchcolor[a]=d;v_nomatchcolor[a]=f;v_enterFunctions[a]=g}function stopRKey(a){var a=(a)?a:((event)?event:null);var b=(a.target)?a.target:((a.srcElement)?a.srcElement:null);if((a.keyCode==13)&&(b.type=="text")){return false}}var keywaspressed=false;function showSelectList(e){var a=navigator.userAgent.indexOf('Firefox/3.5')!=-1;if(a){keywaspressed=true;setTimeout(function(){showSelectListNow(e)},700);setTimeout(function(){unsetPress()},300)}else{keywaspressed=false;showSelectListNow(e)}}function unsetPress(){keywaspressed=false}function showSelectListNow(e){if(keywaspressed){return}var a;var b;if(document.all){a=e.keyCode;b=e.srcElement.getAttribute("id")}else{a=e.which;b=e.target.getAttribute("id")}if(v_oldValues[b]!=html_GetElement(b).value){v_oldValues[b]=html_GetElement(b).value;if(html_GetElement(b).value!=""){do_showSelectList(b)}else{removeSelectList(b)}}else{if(a==40||a==38||a==9){if(!e.shiftKey){if(html_GetElement("_"+b+"SELECTLIST")){html_GetElement("_"+b+"SELECTLIST").focus();vedSurveysForRecord}}}if(a==13){do_pushBackValue(b)}}return false}function recordDoesNotExist(a,b){return objectDoesNotExist(a,"recordDoesNotExist",b)}function medlistDoesNotExist(a,b){return objectDoesNotExist(a,"medlistDoesNotExist",b)}function objectDoesNotExist(a,b,c){var d=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS='+b,0);d.add('TF_NAME',a);if(b=="medlistDoesNotExist"){d.add('TF_RECORD_ID',c)}else if(b=="recordDoesNotExist"){d.add('TF_RECORD_TYPE',c)}gReturn=d.get('');return gReturn==1}function getSavedSurveysForRecord(a,b){var c=document.getElementById(b);c.innerHTML="";var d=null;if(a!=-1){var e=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=getSavedSurveysForRecord',0);e.add('TF_SURVEY_RECORD_ID',a);d=e.get('XML')}else{var e=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=getSampleSurveys',0);d=e.get('XML')}var f=d.getElementsByTagName("option");for(i=0;i<f.length;i++){var g=f[i].firstChild.firstChild.nodeValue;var h=f[i].lastChild.firstChild.nodeValue;appendToSelect(c,g,h)}}function do_showSelectList(a){var b=null;var c=html_GetElement("_"+a+"SELECTLIST");if(!c){c=createSelectList(a)}else{c.disabled=false;c.style.visibility="visible"}var d=navigator.userAgent.indexOf('Firefox/3.0')!=-1;do{var e=html_GetElement(a).value;var f=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=getSearchList',0);f.add('TF_SL_SEARCH',e);f.add('TF_SL_TABLE',v_appItemTable[a]);f.add('TF_SL_COLUMN',v_appItemColumn[a]);gReturn=f.get('XML')}while(d&&e!=html_GetElement(a).value)if(gReturn&&c){var g=gReturn.getElementsByTagName("row").length;c.length=0;if(g>0){if(g<c_SelectListSize){c.size=g}else{c.size=c_SelectListSize}for(var i=0;i<g;i++){var h=gReturn.getElementsByTagName("row")[i];appendToSelect(c,h.firstChild.nodeValue,h.firstChild.nodeValue)}setFieldColor(a,v_matchcolor[a]);c.options[0].selected=true}else if(g==0){removeSelectList(a);setFieldColor(a,v_nomatchcolor[a])}}}function setFieldColor(a,b){html_GetElement(a).style.color=b}function createSelectList(a){var b=document.createElement("select");b.setAttribute("id","_"+a+"SELECTLIST");b.style.position="absolute";b.style.display="block";b.style.width="100%";b.style.left="0px";b.style.top="20px";b.size=c_SelectListSize;if(document.all){b.onclick=function(){return pushBackValue(event)};b.onkeyup=function(){return pushBackValueReturn(event)};b.onkeypress=function(){return pushBackValueReturn(event)}}else{b.onclick=function(e){return pushBackValueReturn(e)};b.onkeyup=function(e){return pushBackValueReturn(e)};b.onkeypress=function(e){return pushBackValueReturn(e)}}v_selectListContainers[a].appendChild(b);return b}function removeSelectList(a){var b=html_GetElement("_"+a+"SELECTLIST");b.style.visibility="hidden";html_GetElement(a).focus();b.disabled=true}function do_pushBackValue(a){var b=html_GetElement("_"+a+"SELECTLIST");if(b&&b.style.visibility!="hidden"){html_GetElement(a).value=html_GetElement("_"+a+"SELECTLIST").value;v_oldValues[a]=html_GetElement(a).value;setFieldColor(a,v_matchcolor[a]);removeSelectList(a);html_GetElement(a).focus()}else{var c=v_enterFunctions[a];if(c){c()}}}function pushBackValue(e){var a;if(document.all){a=e.srcElement.getAttribute("id")}else{a=e.target.parentNode.getAttribute("id")}if(a){if(a.lastIndexOf("_CONTAINER")==a.length-"_CONTAINER".length){do_pushBackValue(a.substring(1,a.indexOf("_CONTAINER")))}else{do_pushBackValue(a.substring(1,a.indexOf("SELECTLIST")))}}}function pushBackValueReturn(e){var a;var b;if(document.all){a=e.keyCode;b=e.srcElement.getAttribute("id")}else{a=e.which;b=e.target.getAttribute("id");if(b==null){b=e.target.parentNode.getAttribute("id")}}if(a==13||a==1){do_pushBackValue(b.substring(1,b.indexOf("SELECTLIST")))}}function appendToSelect(a,b,c){var d=document.createElement("option");d.value=b;if(document.all){a.options.add(d);d.innerText=c}else{d.appendChild(document.createTextNode(c));a.appendChild(d)}}function setItem(a,b,c,d){var e=new htmldb_Get(null,c,'APPLICATION_PROCESS=returnNothing',0,d);e.add(a,b);gReturn=e.get()}function getItem(a,b,c){var d=new htmldb_Get(null,b,'APPLICATION_PROCESS=returnItem',0,c);d.add('RETURNITEM',a);gReturn=d.get();return gReturn}function needRefresh(a,b){var c=getItem('AI_PAGE_REQUESTED',a,b);if(c=="NO"){window.location=window.location}else{setItem('AI_PAGE_REQUESTED',"NO",a,b)}}function convertToInteractions(){var x=document.getElementById("innerSurveyTable");var a=x.tBodies[0];for(var i=1;i<a.rows.length;i++){var b=a.rows[i];var c;for(var j=0;j<b.cells.length;j++){c=j;var d=b.cells[j].firstChild;if(d.className=='riskValue'){break}}convertInteraction(b.cells[c],'riskCurrent');for(var j=c+1;j<b.cells.length;j++){convertInteraction(b.cells[j],'riskDrugCurrent')}}}function convertInteraction(a,b){var c=a.firstChild.innerHTML;var d='<div class="'+b+'">';if(c==1){d+='<div class="interactionIcon"> &nbsp </div>'}else{d+="&nbsp;"}d+='</div>';a.innerHTML=d}function moveSearchBox(){var a=document.getElementById("risk_tab");var b=document.getElementById("shSurveySubtitlePart1");b.innerHTML=a.innerHTML;b=document.getElementById("shSurveySubtitlePart2");var c=document.getElementById("search_field");b.innerHTML=c.innerHTML;c.innerHTML=''}function showSearchBox(){var a=document.getElementById("risk_tab");var b=document.getElementById("search_field");a.style.display="inline";b.style.display="inline"}function moveNumRowsToDisplayToTable(a,b,c,d){moveNumRowsToDisplayToTableBool(a,b,d>c)}function moveNumRowsToDisplayToTableBool(a,b,c){if(a){var d=document.getElementById(b);var e=a.getElementsByTagName('table')[0];var f=e.tBodies[0];var g=f.rows[f.rows.length-1];if(!c){g.style.display="none"}else{var h=g.cells[0];h.innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='left'>"+d.innerHTML+"</td><td align='right'>"+h.innerHTML+"</td></tr></table>";d.innerHTML=""}}}function addSortArrowsToMedListTables(a){addSortArrowsToTable('basicmedlistreport',a);addSortArrowsToTable('activemedlistreport',a);addSortArrowsToTable('proposedmedlistreport',a);addSortArrowsToTable('inactivemedlistreport',a);addSortArrowsToTable('conditionlistreport',a)}function addSortArrowsToTable(a,b){var c=document.getElementById(a);if(c){var d=c.firstChild;try{if(d.nodeName=="DIV"){d=d.firstChild}else if(d.nodeName=="#text"){d=c.childNodes[1]}if(d.nodeName!="TABLE"){d=document.getElementById("reportTable")}if(!d||d.nodeName=="SPAN"){return}var f=d.tBodies[0].rows[1].cells[0].firstChild;var g=f.tBodies[0].rows[0];var h="sort_arrow_up_empty.gif";for(var i=0;i<g.cells.length;i++){var j=g.cells[i];var k=j.innerHTML;if(k.indexOf("Sort by")!=-1){var l=j.firstChild;if(k.indexOf("up.gif")==-1&&k.indexOf("down.gif")==-1){l.innerHTML+=" <img src='"+b+"themes/theme_106/"+h+"' alt='sort' title=''/>"}else{var m=j.childNodes[1];l.appendChild(m)}}}}catch(e){return}}}function importInto(a,b,c){document.getElementById('P0_IMP_RECORD_ID').value=b;if(c){document.getElementById('P0_IMP_MED_LIST_ID').value=c}doSubmit("IMPORT_SURVEY")}function showEditMedsListMenu(a,b,c,d,e,f,g,h,i){var j=document.getElementById('saveAsOptionsTitle');var k=document.getElementById('saveAsOptionsHint');k.innerHTML="";if(d=="TRUE"){j.innerHTML="<div class=\"saveOption\"><a href=\"javascript:takeSurveyEditAction('"+c+"', 'SAVE_NEW_PATIENT');\">Merge Meds to New Patient Med Cabinet</a></div>";if(f==1){j.innerHTML+="<div class=\"saveOption\"><a href=\"javascript:takeSurveyEditAction('"+c+"', 'MERGE_INTO_PATIENT');\">Merge Meds into Existing Patient Med Cabinet</a></div>"}j.innerHTML+="<br/><br/><div class=\"saveOption\"><a href=\"javascript:takeSurveyEditAction('"+c+"', 'SAVE_NEW_REFERENCE');\">Save Meds to New Reference/Medlist</a></div>";if(g==1){j.innerHTML+="<div class=\"saveOption\"><a href=\"javascript:takeSurveyEditAction('"+c+"', 'MERGE_INTO_REFERENCE');\">Merge Meds into Existing Reference/Medlist</a></div>"}var l=document.getElementById('recordModLabel');if(i&&(h=='TRUE'||l.innerHTML=='Modified&nbsp;-&nbsp;unsaved')){k.innerHTML='If you want to "Save All Changes" please do so before using "Save As".  Unsaved changes will be undone in this record and will be saved only to the Medlist or Med Cabinet you select.'}}else{j.innerHTML="You must login before saving a survey<br/>"+"and then select save again<br/><br/>"+"<a href=\"f?p="+e+":101:0\">Login</a> - I'm already a member<br/><br/>"+"<a href=\"f?p="+e+":98:0\">Create an account</a> - I'm not already a member"}showMenu(a,b,'',0,12,'','saveAsOptions')}var curElement=null;var curDeleteId;var curPopupId;var curDeleteName;var curDivName;function showInteractionRollOver(a,b,c,d,e,f){var g=document.getElementById('genericPopupTitle');g.innerHTML="<div class='interactionRollover'><b>"+c+"</b><br/> interacts with <br/><b>"+d+"</b><br/><br/>Severity: "+e+"</div>";showMenuDelayed(a,b,c+" - "+d,f,0,'','genericPopup',0,700)}function getSeverityDescription(a){var b=["Unknown","Moderate","Serious","Severe"];return b[a]}var curConditionId=null;var curMedicationId=null;var curConditions=null;var curMedications=null;function gotoConditionsTreatedByMed(a){window.location="f?p="+a+":4029:0:::RP,4029:AI_ORIGINATING_PAGE,P4029_MEDICATION_ID:4003,"+curMedicationId}function gotoMedsTreatingCondition(a){window.location="f?p="+a+":4023:0:::RP,4023:AI_ORIGINATING_PAGE,P4023_CONDITION_ID:4003,"+curConditionId}function showDrugAddCondMenu(a,b,c,d,e){curMedicationId=c;curConditions=e;var f=document.getElementById("conditionsTreatCell");if(e){var g=document.getElementById("condtionsForMedCell");g.innerHTML=e;f.style.display=""}else{f.style.display="none"}showMenuDelayed(null,a,b,c,d,"medAddCondTitle","medAddCond",350,500)}function showCondAddMedMenu(a,b,c,d,e){curConditionId=c;curMedications=e;var f=document.getElementById("conditionTreatedByCell");if(e){var g=document.getElementById("medsForConditionCell");g.innerHTML=e;f.style.display=""}else{f.style.display="none"}showMenuDelayed(null,a,b,c,d,"changeConditionTitle","condAddMed",350,500)}function showEditDrugMenu(a,b,c,d,e,f,g){var h=document.getElementById('changeDrugGroup');h.innerHTML=f;showMenuDelayed(a,b,c,d,e,"changeDrugTitle","editMedPopup",260,500)}function showEditCondMenu(a,b,c,d,e){showMenuDelayed(a,b,c,d,e,"changeCondTitle","editCondPopup",0,500)}function showStepOneMenu(a,b,c,d,e,f,g,h,i){showMenuDelayed(a,b,c,d,e,f,g,h,i);var j=document.getElementById('P4003_MEDICATION');if(j&&isIE()){j.disabled=true}}function showMenuDelayed(a,b,c,d,e,f,g,h,i){closeCurrent();curDeleteId=curPopupId=d;timer=false;var j=function(){showMenu(a,b,c,d,e,f,g,h,true)};setTimeout(j,i)}function showMenu(a,b,c,d,e,f,g,i,j,k){if(curPopupId!=d&&j){return}if(curDivName!=null){timer=true;closePopup(curElement,curDivName)}timer=false;curDivName=g;curDeleteId=curPopupId=d;curDeleteName=(c.indexOf("<")>0)?c.substring(0,c.indexOf("<")):c;var l=b.parentNode;var h=(b.clientHeight)?b.clientHeight:(b.scrollHeight+2);if(!k){h=h-10}var m=document.getElementById(f);if(m){m.innerHTML=c}var n=document.getElementById(g);var o=getScrollWidth();if(!i){i=200;n.style.width=""}else{n.style.width=i+"px"}var p=(getLeft(b)+e);if(o<p+i){var q=document.all?37:22;p=p-i+q}n.style.left=p+'px';n.style.top=(getTop(b)+h)+'px';n.style.display="inline"}var timer=false;function stopTimer(){timer=false}function closeCurrent(a){if(!a){a=curDivName}if(a){timer=true;closePopup(curElement,curDivName)}}function closePopup(a,b){if(timer){var c=document.getElementById(b);var d=document.getElementById('P4003_MEDICATION');if(d&&isIE()&&c.style.display!="none"){d.disabled=false;d.focus()}c.style.display="none"}}function closePopupCountDown(a,b,c){if(!c){c=500}curPopupId=null;var d="closePopup(curElement, '"+b+"')";timer=true;setTimeout(d,c)}function getLeft(a){if(a.offsetParent){return a.offsetLeft+getLeft(a.offsetParent)}else{return 0}}function getTop(a){if(a.offsetParent){return a.offsetTop+getTop(a.offsetParent)}else{return 0}}function containsDOM(a,b){var c=false;do{if((c=a==b))break;b=b.parentNode}while(b!=null);return c}function checkMouseEnter(a,b){if(a.contains&&b.fromElement){return!a.contains(b.fromElement)}else if(b.relatedTarget){return!containsDOM(a,b.relatedTarget)}}function checkMouseLeave(a,b){if(a.contains&&b.toElement){return!a.contains(b.toElement)}else if(b.relatedTarget){return!containsDOM(a,b.relatedTarget)}}function setCustomSort(a,b,c){var d=document.getElementById('innerSurveyTable');if(d){var e=d.tBodies[0];firstRow=e.rows[0];for(var i=0;i<firstRow.cells.length;i++){var f=firstRow.cells[i];var g=f.getAttribute("id")+"";g.replace(/COL0?([0-9]*)/);var h=RegExp.$1;if(h!=6){var j=f.innerHTML;var k=(h==4)?"sort_arrow_up_empty.gif":"sort_arrow_down_empty.gif";if(b==h){k=(c=="asc")?"blue_arrow_up.gif":"blue_arrow_down.gif"}f.innerHTML='<a href="javascript:sort('+h+')"'+'>'+j+" <img src='"+a+"themes/theme_106/"+k+"' alt='sort' title='' /></a>"}}}}function prepare600Table(a,b,c,d){var e=document.getElementById('innerSurveyTable');var f=document.getElementById('search_and_view');var g;if(e){checkForAndRunTemplates(e);if(b!="Interactions"){g=e.tHead.rows[0].cells[0];g.innerHTML=f.innerHTML;addSearchLabels600(g);f.innerHTML=""}else{setInteractionNames600(a+"themes/theme_106/")}setCustomSort(a,c,d);moveTopPaginationToBottomLeft600();setSurveyTableBGColors()}else if(b!="Interactions"){g=document.getElementById('new_search_home');if(g){g.innerHTML=f.innerHTML;addSearchLabels600(g);f.innerHTML=""}else{addSearchLabels600(f);f.style.display="inline"}}changeViewSelectOnChange600();setColSpan()}function addSearchLabels600(a){var b=a.firstChild.tBodies[0].rows[0].cells[1];b.innerHTML="<span class='t106OptionalLabel'>View:&nbsp;</span>"+b.innerHTML;var c=a.firstChild.tBodies[0].rows[1].cells[1];c.innerHTML="<span class='t106OptionalLabel'>Search side effects for my symptoms:</span><br/>"+c.innerHTML}function setColSpan(){var a=document.getElementById('SurveyOptimalsTitle');if(a){var b=document.getElementById('innerSurveyTable');var c=b.tBodies[0].rows[0];var d=0;for(i=0;i<c.cells.length;i++){var e=c.cells[i].innerHTML;if(e.indexOf("Risk")!=-1){d=c.cells.length-i-1;a.setAttribute("colSpan",d);break}}var f=document.getElementById('shDrugsRegimensTitle2');if(f){f.setAttribute("colSpan",d-1)}}}function checkPagination(a){var b=document.getElementById('innerSurveyTable');if(b){var c=b.parentNode.parentNode.parentNode;var d=c.lastChild.innerHTML;d.replace(/[0-9]* - ([0-9]*)/);var e=RegExp.$1;if(d.indexOf("Next")==-1&&d.indexOf("Previous")==-1&&e<=a){c.lastChild.style.display="none"}}}function moveTopPaginationToBottomLeft600(){var a=document.getElementById('innerSurveyTable').tBodies[0];var b=document.getElementById('topPagination');var c=a.rows.length;var d=a.rows[c-1];var e=d.cells[0];var f=e.getAttribute("colSpan");e.setAttribute("colSpan",f-2);e.setAttribute("colspan",f-2);e.setAttribute('align','center');var g=e.innerHTML;e.innerHTML="<table width='100%'><tr><td align='left'>"+b.innerHTML+"</td><td align='right'>"+g+"</td></tr></table>";b.innerHTML='';var h=''}function setSurveyTableBGColors(){var a=document.getElementById("innerSurveyTable");var b=a.tBodies[0];for(var i=1;i<b.rows.length;i++){var c=b.rows[i];for(var j=0;j<c.cells.length;j++){var d=c.cells[j];if(d.style&&d.firstChild.style){var e;if(d.firstChild.currentStyle){e=d.firstChild.currentStyle}else{e=window.getComputedStyle(d.firstChild,null)}if(e.backgroundColor!="transparent"){d.style.backgroundColor=e.backgroundColor}}}}}function printPage(a,b,c){var d="f?p="+a+":"+b+":"+c+"::::AI_PRINTER_FRIENDLY:YES";var e=window.open(d,"print","location=0,status=1,scrollbars=1,menubar=1,toolbar=0, height=950, width=900");e.focus()}function openNews(a){var b=window.open(a,"news","location=1,status=1,scrollbars=1,menubar=1,toolbar=1,height=600, width=800");b.focus()}function openPartner(a){var b=window.open(a,"partner","location=1,status=1,scrollbars=1,menubar=1,toolbar=1,height=700, width=1050");b.focus()}function getMedicationsFromHTML(a,b){var c=[];for(var i=b;i<a.cells.length;i++){var d=a.cells[i].innerHTML;d=d.substring(d.indexOf("event,this,'"));d=d.substring(d.indexOf("'")+1);d=d.substring(0,d.indexOf("')"));c[i+1]=d}return c}function getMedSections(a,b,c){var d=[];for(var i=b;i<a.cells.length;i++){var e=document.getElementById("MEDINFO"+c[i+1]);d[i+1]=e.getAttribute("medsection")}return d}function getMedicationIDsFromHTML(a,b){var c=[];for(var i=b;i<a.cells.length;i++){var d=a.cells[i].innerHTML;d=d.substring(d.indexOf("info("));d=d.substring(d.indexOf("(")+1);d=d.substring(0,d.indexOf(","));c[i+1]=d}return c}function getMedicationsFromHTML600(a,b){var c=[];for(var i=b;i<a.cells.length;i++){var d=a.cells[i].innerHTML;d=d.substring(d.indexOf("event,this,'"));d=d.substring(d.indexOf("'")+1);d=d.substring(0,d.indexOf(" <br"));c[i]=d}return c}function setAllContraMouseovers(a){var x=document.getElementById("innerSurveyTable");var b=x.tBodies[0];var c=x.tHead.rows[1];var d=getMedicationsFromHTML(c,1);var e;for(var i=1;i<b.rows.length;i++){var f=b.rows[i];var g;for(var j=0;j<f.cells.length;j++){g=j;var h=f.cells[j].innerHTML;if(h.indexOf('interact.gif')!=-1){e=d[j-1];var k=stripHTML(f.cells[0].lastChild.innerHTML);k=k.replace(":",": ");var l=f.cells[2].firstChild.firstChild.innerHTML;l=l.substring(0,l.indexOf(":"));var m=f.cells[1].firstChild.firstChild.getAttribute("laymanterm");addContraMouseover(f.cells[j],e,k,l,m);break}}}}function showContraRollOver(a,b,c,d,e,f){var g=document.getElementById('genericPopupTitle');g.innerHTML="<div class='interactionRollover'><b>"+c+"</b><br/>"+e+"</br>if patient has Condition of Concern</br>"+"<b>"+f+"</b>"+"<br/><br/>"+d+"</div>";showMenuDelayed(a,b,'Contra',0,0,'','genericPopup',0,700)}function addContraMouseover(a,b,c,d,e){var f=a.lastChild.childNodes[0];f.onmouseover=function(){showContraRollOver(this,f,b,c,d,e)};f.onmouseout=function(){closePopupCountDown(f,'genericPopup')}}function addInteractionMouseovers(a,b,c,d,e){for(var j=0;j<c.cells.length;j++){var f=c.cells[j].lastChild;var g=f.innerHTML;if(g&&g.indexOf('interact.gif')!=-1){addInteractionMouseover(c.cells[j],a,b,d,e)}}}function addInteractionMouseover(a,b,c,d,e){var f=a.lastChild.childNodes[0];f.onmouseover=function(){showInteractionRollOver(this,f,b,c,d,e)};f.onmouseout=function(){closePopupCountDown(f,'genericPopup')}}function addGraphMouseovers(a){var x=document.getElementById("innerSurveyTable");var b=(a=="Combined")?2:1;var c;var d;var e;if(a!="Monograph"){var f=x.tHead.rows[1];c=getMedicationsFromHTML(f,b);d=getMedicationIDsFromHTML(f,b);e=getMedSections(f,b,d)}var g=x.tBodies[0];for(var i=1;i<g.rows.length;i++){var h=g.rows[i];var k;var l;for(var j=0;j<h.cells.length;j++){k=j;var m=h.cells[j].lastChild;var n=m.innerHTML;if(n.indexOf('risk-')!=-1){break}else if(m.className=='adeFeature'||m.className=="drugInfoAdeFeature"){l=m.innerHTML}}if(a=="Compare"){for(var j=k;j<h.cells.length;j++){addGraphMouseover(h.cells[j],c[j],d[j],l,e[j])}}else if(a=="Combined"){for(var j=k+1;j<h.cells.length;j++){addGraphMouseover(h.cells[j],c[j],d[j],l,e[j])}addCombinedGraphMouseover(h.cells[k],l)}else if(a=="Monograph"){for(var j=k;j<h.cells.length;j++){addMonographRiskMouseover(h.cells[j],l)}}}}var matchMouseover=/onmouseover=""/g;function addCombinedGraphMouseover(a,b){var c=a.lastChild.innerHTML;var d=a.lastChild.childNodes[1];if(c){b=stripHTML(b);var e=getCellPercentage(c);d.onmouseover=function(){showMenuDelayed(this,d,"<strong>Combined Risk</strong><br/>With this combination"+"<br/><br/>"+e+"<br/><strong>"+b+"</strong>",0,15,'genericPopupTitle','genericPopup',0,700)};d.onmouseout=function(){closePopupCountDown(d,'genericPopup')}}}function addGraphMouseover(a,b,c,d,e){var f=a.lastChild.innerHTML;if(b){var g=a.lastChild.childNodes[1];if(!e){e=""}d=stripHTML(d);var h=getCellPercentage(f);g.onmouseover=function(){showMenuDelayed(this,g,"<strong>"+b+"</strong>"+"<br/>"+e+"<div><br/>"+h+"<br/><strong>"+d+"</strong></div>",0,15,'genericPopupTitle','genericPopup',0,700)};g.onmouseout=function(){closePopupCountDown(g,'genericPopup')}}}function addMonographRiskMouseover(a,b){var c=a.lastChild.innerHTML;if(c){b=stripHTML(b);var d=getCellPercentage(c);var e=a.lastChild.childNodes[1];e.onmouseout=function(){closePopupCountDown(e,'genericPopup')};e.onmouseover=function(){showMenuDelayed(this,e,d+"<br/>"+"<strong>"+b+"</strong>",0,15,'genericPopupTitle','genericPopup')}}}function getCellPercentage(a){a=a.substring(a.indexOf("risk-")+5);a=a.substring(0,a.indexOf(".jpg"));var b="Of 100 people<br/>";if(a==1){b+="<strong>0 to 1 may experience</strong> "}else if(a==2){b+="<strong>1 to 5 may experience</strong> "}else if(a==3){b+="<strong>5 to 10 may experience</strong> "}else if(a==4){b+="<strong>10 to 25 may experience</strong> "}else if(a==5){b+="<strong>25 to 50 may experience</strong> "}else if(a==6){b+="<strong>50 to 100 may experience</strong> "}else{b="No Significant Reports"}return b}function stripHTML(a){var b=/<(?:.|\s)*?>/g;a=a.replace(b,"");b=/'/g;return a.replace(b,"\\'")}function setInteractionNames600(a){var x=document.getElementById("innerSurveyTable");var b=x.tBodies[0];var c=x.tHead.rows[3];var d=getMedicationsFromHTML600(c,0);for(var i=1;i<b.rows.length-1;i++){var e=b.rows[i];var f;for(var j=0;j<e.cells.length;j++){f=j;var g=e.cells[j].firstChild.innerHTML;if(g.indexOf('interact.gif')!=-1){break}}var h=null;for(var j=f+1;j<e.cells.length;j++){var g=e.cells[j].firstChild.innerHTML;var k=(g!=undefined&&g.indexOf('interact.gif')!=-1);if(k){if(h==null){h=d[j-f-1]}else{h+=" - "+d[j-f-1]}}}var l=e.cells[1];var m=l.firstChild.firstChild;var n=m.getAttribute("href");n=n.replace(/\)/,", '"+h+"')");m.setAttribute("href",n);m.innerHTML="<b style='font-size:8pt'>"+h+" Interaction:</b><br/> "+m.innerHTML;m.innerHTML="<img src='"+a+"mono.gif' height='13' width='13' style='float:right; vertical-align: middle;'/>"+m.innerHTML}}function setInteractionNames(a){var x=document.getElementById("innerSurveyTable");var b=x.tBodies[0];var c=x.tHead.rows[1];var d=getMedicationsFromHTML(c,1);for(var i=1;i<b.rows.length;i++){var e=b.rows[i];var f;for(var j=0;j<e.cells.length;j++){f=j;var g=e.cells[j].innerHTML;if(g.indexOf('interact.gif')!=-1){break}}var h=null;var k=null;var l=null;for(var j=f;j<e.cells.length;j++){var g=e.cells[j].innerHTML;var m=(g!=undefined&&g.indexOf('interact.gif')!=-1);if(m){if(h==null){h=d[j];k=d[j]}else{h+=" - "+d[j];l=d[j]}}}var n=e.cells[0].lastChild.innerHTML;var o=e.cells[1];var p=o.lastChild.firstChild;var q=p.getAttribute("href");var r=q.substring(q.indexOf("(")+1,q.indexOf(")"));q=q.replace(/\)/,", '"+h+"')");p.setAttribute("href",q);p.innerHTML="<img src='"+a+"mono.gif' height='15' width='15' style='float:right; vertical-align: middle;'/>"+p.innerHTML;addInteractionMouseovers(k,l,e,n,r)}}function convertInteraction(a,b){var c=a.firstChild.innerHTML;var d=(c.indexOf('interact.gif')!=-1);a.innerHTML=a.firstChild.innerHTML;return d}function moveSearchFields(){var a=document.getElementById("new_search_field");var b=document.getElementById("search_field");var c=document.getElementById("view_select");a.innerHTML="<span class='shLabel'>Search side effects for my symptoms:</span><br/>"+b.innerHTML;a=document.getElementById("new_view_select");a.innerHTML="<table><tr><td><span class='shLabel'>View:</span></td><td>"+c.innerHTML+"</td></tr></table>";b.innerHTML='';c.innerHTML='';changeViewSelectOnChange()}function changeViewSelectOnChange(){var a=document.getElementById('P4002_SURVEY_VIEW');var b=a.getAttribute('onchange')+'';b=getRequestParamater(b);a.onchange=function(){disableThenSubmit(b)}}function changeViewSelectOnChange600(){var a=document.getElementById('P3003_VIEW_SELECT');var b=a.getAttribute('onchange')+'';b=getRequestParamater(b);a.onchange=function(){disableThenSubmit(b)}}function enablePage(){if(document.getElementById('wholePage')){document.getElementById('wholePage').style.display="none";document.getElementById('processingPage').style.display="none"}}function disablePage(){document.getElementById('wholePage').style.display="inline"}function disablePageForPrinting(){var a=document.getElementById('wholePage');if(a){a.style.display="inline";a.style.cursor='default';a.style.opacity=0;a.style.filter='alpha(opacity=0)'}}function disableThenRedirect(a){disablePage();location.href=a}function disableThenSubmit(a){disablePage();doSubmit(a)}function getRequestParamater(a){var b=a.indexOf("'");var c=a.lastIndexOf("'");return a.substring(b+1,c)}function moveFirstDataRowToHeader(){var a=document.getElementById("zpGrid0DataTableTable");var b=document.getElementById("zpGrid0Head").parentNode.parentNode;b.tBodies[0].appendChild(a.rows[0]);var c=document.getElementById("zpGrid0Row0Fixed");var d=c.parentNode;var e=document.getElementById("zpGrid0HeadFixed").parentNode;e.appendChild(c)}function showSearchBox(){var a=document.getElementById("errorMessage");var b=document.getElementById("search_field");var c=document.getElementById("view_select");var d='<table cellpadding="0" cellspacing="0">'+'<tr>'+'<td class="shLabel">View:&nbsp;</td>'+'<td class="shEntryField" id="new_view_select">'+c.innerHTML+'</td>'+'</tr>'+'<tr>'+'<td class="shLabel">Search side effects for my symptoms:&nbsp;</td>'+'<td class="shEntryField" id="new_view_select">'+b.innerHTML+'</td>'+'</tr>'+'</table>';a.innerHTML=d+a.innerHTML;a.style.marginTop="1px";c.innerHTML='';b.innerHTML='';changeViewSelectOnChange()}function hideLabels(){var a=document.getElementById("innerSurveyTable");var b=a.tHead;b.rows[0].cells[0].innerHTML='&nbsp;';b.rows[1].cells[0].innerHTML='&nbsp;'}function checkForAndRunTemplates(a){var b=a.tHead;var c=b.rows.length;var i;for(i=0;i<c;i++){var d=b.rows[i];var e=d.cells.length;var j;for(j=0;j<e;j++){checkForAndRunTemplate(d.cells[j])}}}function checkForAndRunTemplate(a){var b=a.firstChild;if(b&&b.nodeName.toUpperCase()=="DIV"){var c=b.getAttribute("class");if(c==null){c=b.className}if(c=="template"){var d=b.innerHTML;var e=d.indexOf(":::");var f=d.substring(0,e);d=d.substring(e+3,d.length);var g=d.split(":::");var h=getNamesForTemplate(f);var i=getTemplateByName(f);a.innerHTML=runTemplate(i,h,g)}}}function runTemplate(a,b,c){var d=b.length;var i=0;for(i=0;i<d;i++){var e=c[i];var f=b[i];var r=new RegExp(f,'g');a=a.replace(r,e)}a=a.replace(/&APP_ID./,getAppId());a=a.replace(/&APP_SESSION./,getSessionId());return a}function templatizeDrugHeader(a,b){var c=a.firstChild.innerHTML;var d=c.split(":::");d[1]=d[1].substring(0,4);var e=new Array(4);e[0]="\\*MEDICATION_ID\\*";e[1]="\\*DRUG_DISPLAY_NAME\\*";e[2]="\\*ESCAPED_DRUG_DISPLAY_NAME\\*";e[3]="\\*MED_SECTION\\*";a.innerHTML=runTemplate(b,e,d)}function getFirstDrugIndex(a){for(var i=0;i<a.cells.length;i++){var b=a.cells[i];var c=b.className;if(c=="shCurrentDrugs"){return i}}}function prepareSourceTable(a,b,c){var d=document.getElementById("innerSurveyTable");var e=d.tHead;var f=e.rows[1];var g=60;var h=d.tBodies[0].rows[1];var j=getFirstDrugIndex(f);f.cells[j].setAttribute("span",a);var k=60;if(a==1&&g>f.cells[j].scrollWidth){templatizeDrugHeader(f.cells[j],c)}else{for(var i=j;i<f.cells.length;i++){var l=k;var m=f.cells[i];templatizeDrugHeader(m,c)}}moveTopPaginationToBottomLeft()}function isChrome(){return navigator.userAgent.toLowerCase().indexOf('chrome')>-1}function isIE(){return(navigator.appName.indexOf('Internet Explorer')!=-1)}var finalPagDiv=document.getElementById('finalPagDiv');var finalPagDivWidth=450;var currentFinalPagDivLeft=0;function moveTopPaginationToBottomLeft(){var a=document.getElementById('topPagination');var b=document.getElementById('innerSurveyTable').parentNode.parentNode.parentNode;var c=b.lastChild;var d=c.lastChild;d.setAttribute("align","left");var e=document.getElementById('numRowsToDisplay');d.innerHTML="<div style='position: relative; left: 0px' id='finalPagDiv'><table cellpadding='0' cellspacing='0' width='"+finalPagDivWidth+"px'><tr><td align='left'>"+e.innerHTML+"</td><td align='right'>"+d.innerHTML+"</td></tr></table></div>";e.innerHTML=""}function movePagination(){if(finalPagDiv){var a=getScrollWidth();var b=getLeft(finalPagDiv);var c=XDSOC();var d=a+c;var e=document.getElementById('innerSurveyTable').offsetWidth;var f=false;while(c>b&&!f){c=XDSOC();b=getLeft(finalPagDiv);currentFinalPagDivLeft+=10;if(currentFinalPagDivLeft+finalPagDivWidth>e){currentFinalPagDivLeft=e-finalPagDivWidth;f=true}finalPagDiv.style.left=currentFinalPagDivLeft+"px"}d=a+c;var g=b+finalPagDivWidth;f=false;while(g>d&&!f){currentFinalPagDivLeft-=10;if(currentFinalPagDivLeft<0){currentFinalPagDivLeft=0;f=true}finalPagDiv.style.left=currentFinalPagDivLeft+"px";b=getLeft(finalPagDiv);c=XDSOC();d=a+c;g=b+finalPagDivWidth}}else{finalPagDiv=document.getElementById('finalPagDiv')}}function moveNewSurveyButton(){var a=document.getElementById("new_survey_button");var b=document.getElementById("spotForNewSurveyButton");if(a&&b){b.innerHTML=a.innerHTML;a.innerHTML=""}}function addRecordNow(a,b,c){window.location="f?p="+c+":4020:0::RP,4002:4020:AI_RECORD_TYPE_CD,AI_ORIGINATING_PAGE:"+a+","+b}function gotoRecordMedListNow(a,b,c){window.location="f?p="+c+":4003:0:::RP,4002:AI_SELECTED_MEDS_LIST_ID,AI_SELECTED_RECORD_ID:"+b+","+a}function addRecordMedListNow(a,b,c){window.location="f?p="+c+":4005:0:::4002:P4005_MEDS_LIST_ID,AI_ORIGINATING_PAGE,AI_SELECTED_RECORD_ID:-1,"+b+","+a}function gotoImportMedsNow(a,b){window.location="f?p="+b+":4025:0:::4002,4027,4028:AI_SELECTED_RECORD_ID:"+a}var AutocompleterPS=null;if(isChrome()||(Prototype.Browser.IE&&"undefined"==typeof document.documentMode||Prototype.Browser.IE&&document.documentMode<8)){AutocompleterPS=Class.create(Ajax.Autocompleter,{initialize:function(a,b,c,d,e){a(b,c,d,e);this.clicked_outside=false;Event.observe(document,"click",this.onDocumentClick.bindAsEventListener(this));this.element.stopObserving("blur");this.element.observe("focus",this.onFocusOverride.bindAsEventListener(this));this.element.observe("blur",this.onBlurOverride.bindAsEventListener(this))},onDocumentClick:function(a){if(this.element.id!=a.target.id){this.clicked_outside=true}},onFocusOverride:function(a){var b=this;b.clicked_outside=false},onBlurOverride:function(a){var b=this;var c=function(){if(b.clicked_outside){b.clicked_outside=false;b.onBlur(a)}else{b.element.focus()}};setTimeout(c,200)}})}else{AutocompleterPS=Ajax.Autocompleter}function setMatchedCss(a){a.style.color="blue"}function setUnmatchCss(a,b){var c=a.value.toLowerCase();var d=b.firstChild;for(var i=0;i<d.childNodes.length;i++){var e=d.childNodes[i];if(c==e.innerHTML.toLowerCase()){a.style.color="blue";return}}a.style.color="red"}var matchNotChecked=/checkmark-notcheck.gif/g;var matchGrayed=/checkmark-grayed.gif/g;var matchChecked=/checkmark.gif/g;var recordChanged=false;function updateChangeStatus(a){recordChanged=true;var b=a.parentNode.parentNode.parentNode.parentNode.rows[0].cells;var c=a.parentNode.parentNode.parentNode.cells;for(var i=0;i<c.length;i++){if(b[i].id=="CHANGE_STATUS"){c[i].innerHTML="modified"}}}function getPreviousSibling(a){while(true){a=a.previousSibling;if(a==null||a.nodeName=="td"||a.nodeName=="TD"){return a}}}function focusOnMedication(){if(document.getElementById('P4003_MEDICATION')){document.getElementById('P4003_MEDICATION').focus()}if(document.getElementById('P4028_ROUTED_MED')){document.getElementById('P4028_ROUTED_MED').focus()}}function switchConditionType(a){var b=document.getElementById("OFF_LABEL_CELL");var c=document.getElementById("ON_LABEL_CELL");if(a&&a.value=="On"){b.style.display="none";document.getElementById("P4021_OFF_LABEL_CONDITION").value='';getPreviousSibling(b).style.display="none";c.style.display="";getPreviousSibling(c).style.display=""}else{if(a){getPreviousSibling(c).style.display="none";getPreviousSibling(b).style.display="";c.style.display="none";document.getElementById("P4021_ROUTED_COND_ON_LABEL").value='*null*'}getPreviousSibling(b).style.display="";b.style.display=""}}function clearHeaderTotals(){var a='Click to Map Risks';var b=document.getElementById('sideEffectsStats');if(b){b.innerHTML=a}b=document.getElementById('interactionsStats');if(b){b.innerHTML=a}b=document.getElementById('contraindicationsStats');if(b){b.innerHTML=a}}function updateMedMap(a,b,c){changeCheckBoxDisplayed(a,null);updateCondMedMap(b,c)}function updateCondMedMap(a,b){var c=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=UPDATE_COND_MED_MAP',0);c.add('TF_MED_ID',b);c.add('TF_CONDITION_ID',a);gReturn=c.get('XML')}function changeCheckBoxDisplayed(a,b){var c=document.getElementById(a);var d=document.getElementById(b);var e=(d)?d.innerHTML:0;if(c.src.match(matchNotChecked)){c.src=c.src.replace(matchNotChecked,"checkmark.gif");e++}else{c.src=c.src.replace(matchChecked,"checkmark-notcheck.gif");e--}return e}function updateShowInSurvey(a,b){var c=document.getElementById(a);var d=c.getAttribute("routeddrugid");var e=c.getAttribute("medicationid");if(c.src.match(matchGrayed)){c.focus=false;return}var f=changeCheckBoxDisplayed(a,b);var g=document.getElementById(b);if(g){g.innerHTML=f}updateChangeStatus(c);updateSameRoutedDrugs(d,e);clearHeaderTotals();showEditButtons();updateIncludeInSurveyColumns(e);updateRecordLabel()}function showEditButtons(){var a=document.getElementById('copyButtonSection');if(a){a.style.display=''}}function updateRecordLabel(){var a=document.getElementById("recordModLabel");if(a){var b=getItem("AI_MODIFIED_LABEL",getAppId(),getSessionId());a.innerHTML=b}}function updateIncludeInSurveyColumns(a,b){var c=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=SET_SHOW_IN_SURVEY',0);c.add('TF_MED_ID',a);c.add('TF_CHECKBOX_ACTION',b);gReturn=c.get('XML')}function removeAllRoutedDrugs(a){var b=document.getElementById(a);var c=b.getAttribute("routeddrugid");var d=b.getAttribute("medicationid");updateSameRoutedDrugs(c,-1);updateChangeStatus(b);updateIncludeInSurveyColumns(d,"REMOVE_ALL");updateRecordLabel()}function invertRoutedDrugSelection(a){var b=document.getElementById(a);var c=b.getAttribute("routeddrugid");var d=b.getAttribute("medicationid");var e=["REG","PROPOSED","INACTIVE"];for(var i=0;i<e.length;i++){for(var j=1;true;j++){var f="check"+e[i]+j;var g=document.getElementById(f);if(g){var h=g.getAttribute("routeddrugid");if(h==c){if(g.src.match(matchGrayed)){g.src=g.src.replace(matchGrayed,"checkmark.gif")}else{g.src=g.src.replace(matchChecked,"checkmark-grayed.gif")}updateChangeStatus(g)}}else{break}}}updateChangeStatus(b);updateIncludeInSurveyColumns(d,"FLIP_ROUTED");updateRecordLabel()}function updateSameRoutedDrugs(a,b){var c=["REG","PROPOSED","INACTIVE"];for(var i=0;i<c.length;i++){for(var j=1;true;j++){var d="check"+c[i]+j;var e=document.getElementById(d);if(e){var f=e.getAttribute("routeddrugid");var g=e.getAttribute("medicationid");if(g!=b&&f==a){if(e.src.match(matchNotChecked)){e.src=e.src.replace(matchNotChecked,"checkmark-grayed.gif")}else{e.src=e.src.replace(matchGrayed,"checkmark-notcheck.gif");e.src=e.src.replace(matchChecked,"checkmark-notcheck.gif")}updateChangeStatus(e)}}else{break}}}}function showGrayedOutRoutedInfoBox(a,b){if(b.src.match(matchGrayed)){var c=document.getElementById('genericPopup');var d=b.getAttribute("routeddrugdesc");var e=b.getAttribute("routeddrugid");var f=b.id;c.innerHTML="<div class=\"duplicateRoutedDrug\" style=\"text-align:center\">Loading...</div>";showMenu(a,b,'',0,12,'','genericPopup');var g=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=GET_ROUTED_GROUP_INCLUDED',0);g.add('TF_MED_ID',e);var h=g.get();c.innerHTML="<div class=\"duplicateRoutedDrug\"><strong>"+d+"</strong><br/>"+"A row for "+d+" in "+h+" is already included in the survey."+"<div class=\"duplicateRoutedDrugAction\"><a href=\"javascript:removeAllRoutedDrugs('"+f+"')\">Do not include "+d+" in survey</a></div>"+"<div class=\"duplicateRoutedDrugAction\"><a href=\"javascript:invertRoutedDrugSelection('"+f+"')\">Include this row of "+d+" in survey</a></div></div>"}}function updateMedSection(){if(document.getElementById('P4028_MED_END_DATE')){var a=document.getElementById('P4028_PROSPECTIVE_USE_FLAG_0').checked;var b=document.getElementById('P4028_MED_END_DATE').value;var c=document.getElementById('P4028_MED_START_DATE').value;var d=document.getElementById('medSection');d.innerHTML=(b==null||b=="")?(a?"Proposed Meds":(c==null||c=="")?"Set the Med Group using the fields below":"Active Meds"):"Inactive Meds"}}function closeMenuWhenClickedElseWhere(a){a=a||window.event;var b=a.target||a.srcElement;if(!checkContainedId(b,"viewThisQuickLinks")&&!checkContainedId(b,"surveySelector")){document.getElementById("viewThisQuickLinks").style.display="none";unregisterEventHandler(document,'click',closeMenuWhenClickedElseWhere)}}function checkContainedId(a,b){if(a==null){return false}if(a.id==b){return true}return checkContainedId(a.parentNode,b)}function registerEventHandler(a,b,c){if(typeof a.addEventListener=="function")a.addEventListener(b,c,false);else a.attachEvent("on"+b,c)}function unregisterEventHandler(a,b,c){if(typeof a.removeEventListener=="function")a.removeEventListener(b,c,false);else a.detachEvent("on"+b,c)}function toggleMenu(a,b,c,d,e,f,g,h,i){h=320;if(document.getElementById(g).style.display=="none"){if(isIE()&&g=='viewThisQuickLinks'){document.getElementById(g).style.width="335px";h=335}showMenu(a,b,c,d,e,f,g,h,i,true);registerEventHandler(document,'click',closeMenuWhenClickedElseWhere)}else{closeCurrent(g);unregisterEventHandler(document,'click',closeMenuWhenClickedElseWhere)}}function ignoreClicksForPrinting(a){Event.stop(a);var b=true;return b}function getNextRow(a){while(true){a=a.nextSibling;if(a==null||a.nodeName=="tr"||a.nodeName=="TR"){return a}}}function showOpenChildren(a){var b=parseInt(a.getAttribute("level"));var c=a;while(true){var c=getNextRow(c);if(c==null){break}var d=parseInt(c.getAttribute("level"));if(d==null||d==b){break}if(d==b+1){c.style.display="";if(c.innerHTML.indexOf("minus")!=-1){showOpenChildren(c)}}if(d<=b){break}}}function hideAllChildren(a){var b=parseInt(a.getAttribute("level"));c=a;while(true){var c=getNextRow(c);if(c==null){break}var d=parseInt(c.getAttribute("level"));if(d==null||d<=b){break}c.style.display="none"}}function switchtreeview(a,b,c){var d="level"+b+"treerow"+a;var e=document.getElementById(d);if(e.innerHTML.indexOf("plus")!=-1){switchImage(e,"plus.gif","minus.gif");showOpenChildren(e);new Ajax.Request('/dcls/updateselector?nodeId='+c+'&action=open',{method:'post'})}else{hideAllChildren(e);switchImage(e,"minus.gif","plus.gif");new Ajax.Request('/dcls/updateselector?nodeId='+c+'&action=close',{method:'post'})}}function switchImage(a,b,c){var d=a.cells[0].firstChild;var e=d.tBodies[0].rows[0].cells[0];var f=e.firstChild.firstChild;f.src=f.src.replace(b,c)}function gotoRecordMedList(a,b,c){if(confirmIfUnsaved()){gotoRecordMedListNow(a,b,c)}}function gotoImportMeds(a,b){if(confirmIfUnsaved()){gotoImportMedsNow(a,b)}}function addRecordMedlist(a,b,c){if(confirmIfUnsaved()){addRecordMedListNow(a,b,c)}}function addRecord(a,b,c){if(confirmIfUnsaved()){addRecordNow(a,b,c)}}function saveNewPatientImport(){var a=document.getElementById('P0_RECORD_NAME');var b=document.getElementById('P0_BIRTHYEAR');if(a.value==null||a.value==''){alert('Please enter a name for the new record.')}else if(!recordDoesNotExist(a.value,'P')){alert('A Patient named '+a.value+' already exists. Please enter a different Name.')}else if(b.value!=null&&b.value!=''&&!checkDate(b)){return}else{doSubmit("NEW_PATIENT_IMPORT")}}function checkNameField(a){var b=document.getElementById('P0_REFERENCE_NAME');if(a.value==-1){b.disabled=false}else{b.disabled=true}}function saveNewReferenceImport(){var a=document.getElementById('P0_REFERENCE_NAME');var b=document.getElementById('P0_REFERENCE_ID');var c=document.getElementById('P0_MED_LIST_NAME');if((a.value==null||a.value=='')&&b.value==-1){alert('Please enter a name for the new reference record. Or select an existing one.')}else if(c.value==null||c.value==''){alert("Please enter a name for the new Medication List.")}else if(b.value!=-1&&!medlistDoesNotExist(c.value,b.value)){alert('A MedList named '+c.value+' already exists in the selected Reference Folder. Please enter a different Name.')}else if(b.value==-1&&!recordDoesNotExist(a.value,'R')){alert('A Reference Folder named '+a.value+' already exists. Please enter a different Name.')}else{doSubmit("NEW_REFERENCE_IMPORT")}}function checkDate(a){var b,day,yr;var c=a.value;var d=/\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;if(d.test(c)){var e=(c.indexOf("/")!=-1)?"/":"-";var f=c.indexOf(e);var g=c.lastIndexOf(e);b=parseInt(c.substring(0,f),10);day=parseInt(c.substring(f+1,g),10);yr=parseInt(c.substring(g+1),10);var h=new Date(yr,b-1,day);if(h.getDate()==day){if(h.getMonth()+1==b){if(h.getFullYear()==yr){return true}else{alert("There is a problem with the year entry.")}}else{alert("There is a problem with the month entry.")}}else{alert("There is a problem with the date entry.")}}else{alert("Incorrect date format. Enter as mm/dd/yyyy.")}field.focus();return false}



