var focusedElement=null;var modal;var dialog;var body;var html;var modalShowing;try{var isSafari=window.navigator.vendor.match(/Apple/)}catch(ex){isSafari=false}if(isSafari){var dialogFocuser=document.createElement("a");dialogFocuser.href="#";dialogFocuser.style.display="block";dialogFocuser.style.height="0";dialogFocuser.style.width="0";dialogFocuser.style.position="absolute";dialog.insertBefore(dialogFocuser,dialog.firstChild)}else{dialogFocuser=dialog}var rand=function(b,a){var c=Math.random();return parseInt(b+(c*(a-b)))};var randColor=function(){return"rgb("+rand(0,255)+","+rand(0,255)+","+rand(0,255)+")"};window.onunload=function(){dialogFocuser=focusedElement=modal=dialog=body=html=null};var onfocus=function(c){c=c||window.event;var a=c.target||c.srcElement;if(!modalShowing){focusedElement=a;return}var b=a.parentNode;while(b&&b.parentNode&&b!==dialog){b=b.parentNode}if(b!==dialog){dialogFocuser.focus()}};var onblur=function(){if(!modalShowing){focusedElement=body}};function showModal(){modal=document.getElementById("modal");dialog=document.getElementById("dialog");body=document.getElementById("body");html=document.documentElement;modal=(html.className==="modal");html.tabIndex=-1;dialog.tabIndex=-1;body.tabIndex=-1;html.onfocus=html.onfocusin=onfocus;html.onblur=html.onfocusout=onblur;if(isSafari){html.addEventListener("DOMFocusIn",onfocus);html.addEventListener("DOMFocusOut",onblur)}if(modalShowing){return}modalShowing=true;html.className="modal";dialog.focus()}function hideModal(){if(!modalShowing){return}modalShowing=false;html.className="";if(focusedElement){try{focusedElement.focus()}catch(a){}}};
