

  //stop rh mouseclick over images

function right(e) {
var msg = "All images on this site are copyright\nand may not be used without prior permission";
if (navigator.appName == 'Netscape' && e.which == 3) {
alert(msg);
return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
alert(msg);
return false;
}
else return true;
}

function trap() 
  {
  if(document.images)
    {
    for(i=0;i<document.images.length;i++)
      {
      document.images[i].onmousedown = right;
      document.images[i].onmouseup = right;
      }
    }
  }
  //stop rh mouseclick over images


var correctwidth=1024 
var stylesheet
if (screen.width<correctwidth) {
stylesheet = "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"/css/hh2_lores.css\">";
document.write(stylesheet);
} 

ie5  = (document.all && document.getElementById); 
ns6 = (!document.all && document.getElementById);

//NS init:
if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc; }

var xmlHttp;
var rootpath;
rootpath = "http://www.edwardbach.org/";   // be sure to change this to your URL
function GetXmlHttpObject(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 




function submitform(thisform)
{alert(thisform);
//document.forms[thisform].submit();
document.thisform.submit();
}

function changedetailpanelinnerstuff(thisid)
{
//ensure any card already hilited is cleared
		if(lastcard){
			var lastcardpic=lastcard.replace('card','pic');
			var lastcardid=lastcard.replace('card','');
		document.getElementById(lastcard).className = "";
		var thissrc = '/images/bach flower remedy products/' + lastcardid + '.gif';
		if (thisid > 79) {document.getElementById(lastcardpic).src = thissrc};
		}

//in case a prescription is showing
var thisdiv = 'Detail' + thisid+'';
var thiscard = 'card' + thisid+'';
var thispic = 'pic' + thisid+'';
//alert(lastcard);
lastcard = thiscard;
lastpic=thispic;
HideCurrentDetail()

document.getElementById(thisdiv).style.visibility="visible";
MM_showHideLayers(thisdiv,'','show','Sidebars','','show');

lastplant = thisdiv;
document.getElementById('OpacityMask').style.visibility="visible";

document.getElementById(thiscard).className = "tabpicOnview";	
}





function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}








function fadeIn() {
    if(opac < 100){
       opac+=fadespeed;
        if(ie5) document.getElementById(itemtofadein).filters.alpha.opacity = opac;
        if(ns6) document.getElementById(itemtofadein).style.MozOpacity = opac/100;
        setTimeout('fadeIn()', 0);
    }
}
function fadeIn2() {
    if(opac3 < 100){
       opac3+=fadespeed2;
        if(ie5) document.getElementById(itemtofadein).filters.alpha.opacity = opac3;
        if(ns6) document.getElementById(itemtofadein).style.MozOpacity = opac3/100;
        setTimeout('fadeIn2()', 0);
    }
}
function fadeOut() {
	if(opac2 > leavelevel){
		opac2-=fadespeed;
		
		if(ie5) document.getElementById(itemtofadeout).filters.alpha.opacity = opac2;
		if(ns6) document.getElementById(itemtofadeout).style.MozOpacity = opac2/100;
		setTimeout('fadeOut()', 0);
	}
}

function adjustheight(thislayer)
{trap();
if (!thislayer) {return}
//if thislayer is nominatedset the ht to theat of thislayer	
var a = document.getElementById(thislayer).clientHeight;
var b = findPosY(document.getElementById(thislayer));
var tallestDivBottom = a+b;

var yellowbase = tallestDivBottom;
if (yellowbase < 597) {yellowbase = 598};
var shadowpic2 = yellowbase - 597;
if (document.location.pathname == '/index.asp'||document.location.pathname == '/') {

	yellowbase=yellowbase-30;
	shadowpic2 = yellowbase - 580;
	}
	
var opacitymaskht = yellowbase - 100;
var maskexists = document.getElementById("OpacityMask");
var sidebarexists = document.getElementById("Sidebars");

shadowpic2 = shadowpic2.toString() + "px";
yellowbase = yellowbase.toString() + "px";
document.getElementById('shadowpic2').style.height=shadowpic2;
document.getElementById('FloatingLayer').style.height=yellowbase;

if(maskexists){document.getElementById('OpacityMask').style.height=opacitymaskht-70};
if(sidebarexists){document.getElementById('Sidebars').style.height=opacitymaskht-70};

var ztab2 = document.getElementById('tab2');
var ztab3 = document.getElementById('tab3');

if(thislayer=='tab2'){
if (ztab3 != null){document.getElementById('tab3').style.height=a.toString() + "px"};
document.getElementById('tab1').style.height=a.toString() + "px";
}

if(thislayer=='tab1'){
if (ztab2 != null){document.getElementById('tab2').style.height=a.toString() + "px"};
if (ztab3 != null){document.getElementById('tab3').style.height=a.toString() + "px"};
}
}
//why not tab3 same? cos only one tab3 and its on remedies and is the longest anyway






function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}




function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}
function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
/* First thing is to declare global variables
   to contain the X and Y coordinates of the
   mouse cursor. */
var currentX = 0;
var currentY = 0;
var showtip = 1;
	
/* Use "object sniffing" technique to determine
   if the browser has the captureEvent method.
   This tells us if the client is a Mozilla-type browser.
   If so, we tell the document object to 
   capture the MOUSEMOVE event. */
if (document.captureEvent){
  document.captureEvent(Event.MOUSEMOVE);
}

/* The getMousePosition() function will be the
   event-handling function that sets
   currentX and currentY. */
function getMousePosition(evt){

/* Internet Explorer and Mozilla have differences
   both in the way they implement events and the
   way they determine x/y coordinates. */
  if (ie5){
   //window.event 
    /* This is the Internet Explorer way.
       Adds the x and y coordinates relative to the screen
       to the number of pixels the user has scrolled 
       horizontally and vertically. */
   // currentX = window.event.clientX + document.body.scrollLeft;
	currentX = window.event.clientX + document.documentElement.scrollLeft;
    //currentY = window.event.clientY + document.body.scrollTop;
	currentY = window.event.clientY + document.documentElement.scrollTop;		
  }
  else if (evt){
    
    /* In Mozilla/Netscape browsers, you just need to access
       the pageX and pageY properties to determine coordinates. */
    currentX = evt.pageX;
    currentY = evt.pageY;
  }


}

// register getMousePosition() as an event handler for the onmousemove event.
document.onmousemove = getMousePosition;



//following were used in establishing why document.body.scrollTop did not work in ie
//window.onscroll = fff;

function fff(){ 
    //fix top positioning 
    var topPosFix = typeof window.pageYOffset != 'undefined' ? 
        window.pageYOffset:document.documentElement && 
document.documentElement.scrollTop ? 
        document.documentElement.scrollTop: document.body.scrollTop? 
document.body.scrollTop:0; 
alert('document.documentElement.scrollTop='+document.documentElement.scrollTop 
+', document.body.scrollTop='+document.body.scrollTop) 
}

/* The positionElement function will place an object
   at the coordinates (currentX+10, currentY+10).
   Parameter: any valid ID attribute of an element. */
function positionElement(id){
  // set elem to the element with specified id.
  elem = document.getElementById(id);
  if (elem){
    /* If the element exists, set the CSS style "left"
       to currentX + 10, and the CSS style "top" to
       currentY + 10. */

//need to account for floating layer
    var currentwidth = document.body.offsetWidth;
	var flpos = (currentwidth/2)-400
elem.style.left = (currentX-(flpos+55)) + "px";
elem.style.top = (currentY-215) + "px";
  }
}










