function getMouseLeft(event){var posx=0;if(event.pageX)posx=event.pageX;else if(event.clientX)posx=event.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;return posx}function getMouseTop(event){var posy=0;if(event.pageY)posy=event.pageY;else if(event.clientY)posy=event.clientY+document.body.scrollTop+document.documentElement.scrollTop;return posy}function getWindowHeight(){if(document.all)return document.body.offsetHeight;else return window.innerHeight}function getWindowWidth(){if(document.all)return document.body.offsetWidth;else return window.innerWidth}function showPopup(event,genericNames,brandNames,refinement,refineLink,newLink,dupText,refineList,currSearch){try{var popupPanel=document.getElementById("refinePop");popupPanel.style.display="block";var genericNamesDiv=document.getElementById("refineNames");if(genericNames!=""){genericNamesDiv.innerHTML="<label>Names:</label> "+genericNames;genericNamesDiv.style.display="block"}else genericNamesDiv.style.display="none";var brandNamesDiv=document.getElementById("refineBrands");if(brandNames!=""){brandNamesDiv.innerHTML="<label>Brand Names:</label> "+brandNames;brandNamesDiv.style.display="block"}else brandNamesDiv.style.display="none";var refinementList=refineList.split("|"),refNames="";for(var refCount=1;refCount<refinementList.length;refCount++)if(refCount==1)refNames+=refinementList[refCount].split("_")[0];else refNames+=" AND <b>"+refinementList[refCount].split("_")[0]+"</b>";var refinementDiv=document.getElementById("refinePlus");if(refineLink!="")if(refNames=="")refinementDiv.innerHTML='Search for <a href="'+refineLink+'"> '+decodePlus(currSearch)+" AND "+refinement+" </a>";else refinementDiv.innerHTML='Search for <a href="'+refineLink+'"> '+decodePlus(currSearch)+" AND "+refNames+" AND <b>"+refinement+" </b></a>";else refinementDiv.innerHTML=dupText+"<b>"+decodePlus(currSearch)+" AND "+refNames+"</b>";var refineNewDiv=document.getElementById("refineNew");refineNewDiv.innerHTML='Start a new search on JUST <a href="'+newLink+'">'+refinement+" </a>";var left=getMouseLeft(event)+20,top=getMouseTop(event)+20;if(left+200>getWindowWidth())left-=260;if(top+200>getWindowHeight())top-=260;if(navigator.userAgent.indexOf("MSIE 6.0")!=-1){var optionBlocker=document.getElementById("optMask");optionBlocker.style.position="absolute";optionBlocker.style.top=top+"px";optionBlocker.style.left=left+"px";optionBlocker.style.width=popupPanel.offsetWidth;optionBlocker.style.height=popupPanel.offsetHeight;var medstory_dashboard=document.getElementById("dashboard_wrapper");medstory_dashboard.appendChild(optionBlocker);optionBlocker.style.display="block"}popupPanel.style.top=top+"px";popupPanel.style.left=left+"px"}catch(error){alert(error)}}function decodePlus(string){return unescape(string).replace(/\+/g," ")}function closePopup(){var popupPanel=document.getElementById("refinePop");popupPanel.style.display="none";var optionBlocker=document.getElementById("optMask");optionBlocker.style.display="none"}function removeRefinement(urlStart,removeID,refinements){var newRefinements=refinements.replace("|"+removeID,"");location.href=urlStart+"&fil="+newRefinements}function filterResults(urlStart){var filterOption=document.getElementById("filter");if(filterOption.value!="")if(filterOption.value=="ALL")location.href=urlStart+"&sfil=";else location.href=urlStart+"&sfil="+filterOption.value}function moveCategories(){var tempContent=document.getElementById("nutr").innerHTML;document.getElementById("nutr").innerHTML=document.getElementById("cond").innerHTML;document.getElementById("cond").innerHTML=tempContent}function transform(){var medstory_dashboard=document.getElementById("dashboard_wrapper"),medstory_page=document.getElementById("subhead"),dashboardDiv=document.getElementById("dashboard-div"),resultsTextDiv=document.getElementById("result_display_text");if(dashboardDiv||resultsTextDiv){if(medstory_dashboard!=null){medstory_page.appendChild(medstory_dashboard);for(i=0;i<medstory_page.childNodes.length;i++)if(medstory_page.childNodes[i].id=="dashboard_wrapper")medstory_page.childNodes[i].style.display="block"}if(dashboardDiv){var url=window.location.toString(),strFound=url.match("expanded=true");if(!isNaN(strFound))showCategories(5);else showCategories(7);levelHeight()}}else if(medstory_dashboard!=null)medstory_dashboard.style.display="block"}function levelHeight(){Array.prototype.max=function(){return Math.max.apply(Math,this)};var allDivs=[],container="";if(document.getElementById("dashboard-div")){container=document.getElementById("dashboard-div");for(i=0;i<container.childNodes.length;i++){var el=container.childNodes[i];if(el.className=="category")allDivs.push(el)}}if(allDivs.length>5&&container!=""){var TopRowHeights=[],BottomRowHeights=[];for(i=0;i<allDivs.length;i++)if(i<=5)TopRowHeights.push(allDivs[i].clientHeight);else BottomRowHeights.push(allDivs[i].clientHeight);for(i=0;i<allDivs.length;i++)if(i<=5)allDivs[i].style.height=TopRowHeights.max()+"px";else allDivs[i].style.height=BottomRowHeights.max()+"px"}}function showCategories(ncat){var container="";newContainer="";if(document.getElementById("dashboard-div")){container=document.getElementById("dashboard-div");for(i=0;i<container.childNodes.length;i++){var el=container.childNodes[i];if(i<ncat)if(el.className=="category")newContainer+='<div class="category" id="'+el.id+'">'+el.innerHTML+"</div>\n"}container.innerHTML=newContainer+'<div class="clear"></div>'}}