/* patienthealthinternational.com Javascript - shows bodymap image map */ function addMasterScript(){ //this adds in the master root.js file which includes all basic JS functionality //this must be included in all local js files //Do not copy code from the root.js file, use this function to import it instead if(document.getElementById){ //browser supports getElementById - attempt to add js functionality //this is a site-specific js file so include the master //create a script element if(document.createElement){ elScript=document.createElement('script'); if(elScript){ //include master file elScript.src='/_mshost81109/system/styles/root/javascript/root.js'; //elScript.src='../styles/root/javascript/root.js'; elScript.type='text/javascript'; //get a handle to this script file elHead=document.getElementsByTagName('head'); if(elHead){ //get script elExistingScript=document.getElementsByTagName('script'); if(elExistingScript){ //add into head before previous element elHead[0].insertBefore(elScript,elExistingScript[0]); //attachEvents function is called when the master file loads //so global functionality is still enabled } } } } } } //call the above function addMasterScript(); // set some flags we can use to tell what kind of browser we are dealing with. var isNS4 = document.layers ? true : false; var isIE4 = document.all ? true : false; var isDom = document.getElementById ? true : false; function popupDisplay( bodypartId, imageId, xPos, yPos, autohide, width, roxPos, royPos) { // first find the bodymap var bodymap = getImage('bodymapImage'); if (!(bodymap)) { return; } // hide any currently displayed popup popupHideCurrent( bodymap ); // display the list of conditions for the selected body part. var popup = getElementStyle('conditionList' + bodypartId); if (!(popup)) { return; } popup.display = 'block'; if (isNS4) { popup.visibility = 'show'; } if (autohide == 'false') { // now get the popup element rather than the style of the popup. popup = getElement('conditionList' + bodypartId); popup.onmouseout = null; } bodymap.currentpopup = bodypartId; // show any rollover image var rollover = document.getElementById('bodymapImageRollover'); if(rollover){ rolloverImage=rollover.lastChild; if(rolloverImage){ setAttributeCrossBrowser(rolloverImage,'class','rollover' + bodypartId); } } } function popupHide( bodypartId ) { // check if we are still inside the popup // get the mouse position var posx = 0; var posy = 0; var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft; posy = e.clientY + document.body.scrollTop; } // get the popups x, y, height, width. var popup = getElement('conditionList' + bodypartId ); var popx = parseInt(getAbsX(popup)); if (isNaN(popx)) return; var popy = parseInt(getAbsY(popup)); if (isNaN(popy)) return; var poph = parseInt(getHeight(popup)); if (isNaN(poph)) return; var popw = parseInt(getWidth(popup)); if (isNaN(popw)) return; posx = parseInt(posx); if (isNaN(posx)) return; posy = parseInt(posy); if (isNaN(posy)) return; // Check if the mouse is actually inside the div, but over another element. if (((posx-2) >= popx) && ((posx+2) <= (popx + popw)) && ((posy-2) >= popy) && ((posy+2) <= (popy + poph))) { // it is, so don't hide the popup. return; } popup = getElementStyle( 'conditionList' + bodypartId ); popup.display = 'none'; if (isNS4) { popup.visibility = 'hidden'; } bodymap.currentpopup = undefined; // hide any rollover image var rollover = getElementStyle( bodymapRolloverID ); if (!(rollover)) { return; } rollover.display = 'none'; if (isNS4) { rollover.visibility = 'hidden'; } } function popupHideCurrent(bodymap) { if (!(bodymap.currentpopup)) { return; } popup = getElementStyle( 'conditionList' + bodymap.currentpopup ); popup.display = 'none'; if (isNS4) { popup.visibility = 'hidden'; } } function getElementStyle( name ) { if (!(getElement(name))) { return; } var elt; if (isDom) { elt = document.getElementById(name).style; } else if (isIE4) { elt = document.all(name).style; } else if (isNS4) { elt = document.layers[name]; } return elt; } function getElement( name ) { var elt; if (isDom) { elt = document.getElementById(name) } else if (isIE4) { elt = document.all(name); } else if (isNS4) { elt = document.layers[name]; } return elt; } function getImage( name ) { var image; if (isDom) { image = document.getElementById(name); } else if (isIE4) { image = document.all(name); } else if (isNS4) { image = document.images[name]; } return image; } function getAbsX(elt) { // get the absolute x coord of elt. // NS4 has element.x, whereas for NS6 and IE we need to do other stuff return (elt.x) ? elt.x : getAbsPos(elt,"Left"); } function getAbsY(elt) { // get the absolute y coord of elt. // NS4 has element.y, whereas for NS6 and IE we need to do other stuff return (elt.y) ? elt.y : getAbsPos(elt,"Top"); } function getAbsPos(elt,which) { // for IE and NS6 we need to get the offset of the elements within all its // containers. var iPos = 0; while (elt != null) { iPos += elt["offset" + which]; elt = elt.offsetParent; } return iPos; } function getHeight(elt) { // get the height of the element in pixels. if (isNS4) { return elt.clip.height; } else { return elt.clientHeight; } } function getWidth(elt) { // get the width of the element in pixels if (isNS4) { return elt.clip.width; } else { return elt.clientWidth; } } function addMap(){ //attach mouseover events to body image map for(i=1;i<9;i++){ area=document.getElementById('area'+i); if(area){ assignMouseover(area,i); } } } function assignMouseover(el,i){ //avoids reference problem with loop el.onmouseover=function(){ popupDisplay(i); } } function fnSwitchpage(the_form){ //Get the selected link URL from the dropdown var link_chosen; link_chosen=the_form.selection.options[the_form.selection.selectedIndex].value; //Redirect to this URL window.location=link_chosen; return false; } function switchPageSelect() { //Put the Redirect forms into an array var form_id=new Array; if (document.getElementById('frm_conditions')) { form_id[0]=document.getElementById('frm_conditions'); } if (document.getElementById('frm_medicines')) { form_id[1]=document.getElementById('frm_medicines'); } if (form_id.length > 0) { for (var i = 0; i < form_id.length; i++) { form_id[i].onsubmit = function () { // On submit tell fnSwitchpage function which form to use return fnSwitchpage(this); } } } } var toCall=new Array; toCall[0]=addMap; toCall[1]=switchPageSelect;