/* VERSION=$Rev: 135 $ $Date: 2007-07-17 23:19:11 -0700 (Tue, 17 Jul 2007) $ */
if( document.all )    {n=0;ie=1;ns6=0;fShow="visible";fHide="hidden";}
if( document.getElementById&&!document.all)    {n=0;ie=0;ns6=1;fShow="visible";fHide="hidden";}
if( document.layers ) {n=1;ie=0;ns6=0;fShow="show";fHide="hide";}
//Top Nav bar script v2- http://www.dynamicdrive.com/dynamicindex1/sm/index.htm
opr6=ie&&navigator.userAgent.indexOf("Opera")!=-1
window.onerror=new Function("return true")
rightX=0;
function Menu( nWidth, sAlign )
{
	this.bgColor="#9900CC";
    this.bgColorItem="#9900CC";
	if( ie ) 
	    this.menuFont="bold 14px Arial";
	if( n )  
	    this.menuFont="bold 14px Verdana";
	//this.fontColor="black";
  
	this.addTitle=addTitle;
	this.addItem=addItem;
	this.showMenu=showMenu;
	this.addBreak=addBreak;
	this.addImage=addImage;
	this.mainPaneBorder=1;
	this.subMenuPaneBorder=3;
	this.subMenuPaneWidth=nWidth;

	lastMenu=null;
	rightY=0;
	rightX=0;
	leftY=0;
	leftX=0;

	htmlString="<!-- MENU PANE DECLARATION BEGINS -->\n\n";
	if( ie||ns6 ) 
	    htmlString += "<div id='MainTable' style='position:relative;top:0'>\n";
//	if( n )  htmlString += "<layer name='MainTable'>\n";
    htmlString += "<span class='mainPaneBorder'>";
    htmlString += "<table width='100%' bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"'>\n";
//	htmlString += "<table width='100%' class='mainPaneBorder' bgcolor='"+this.bgColor+"'>\n";
	htmlString += "<tr>";
	if( n ) 
	    htmlString += "<td>&nbsp;";
	htmlString += "<!-- MAIN MENU STARTS -->\n";
	htmlString += "<!-- MAIN_MENU -->\n";
	htmlString += "<!-- MAIN MENU ENDS -->\n";
	if( n ) 
	    htmlString += "</td>";
	htmlString += "</tr>\n";
	htmlString += "</table>\n";
	htmlString += "</span>\n";
	htmlString += "\n";
	htmlString += "<!-- SUB MENU STARTS -->\n";
	htmlString += "<!-- SUB_MENU -->\n";
	htmlString += "<!-- SUB MENU ENDS -->\n";
	htmlString += "\n";
	if( ie||ns6 ) 
	    htmlString+= "</div>\n";
//	if( n )  htmlString+= "</layer>\n";
	htmlString += "<!-- MENU PANE DECALARATION ENDS -->\n";
}
function addImage( )
{
    imgString="<div id='header'>";
    imgString += "<a href='http://www.drbeth.com/index.htm'>";
    imgString += "<img src='http://www.drbeth.com/images/drBethLogo.gif' width='130' height='53' border='0' alt='Dr. Beth Home' /></a>";
    imgString += "</div>";
    document.writeln(imgString);
}
function addTitle( idTitle, text, hint, location, altLocation, fBreak )
{
	var Lookup="<!-- ITEM "+idTitle+" -->";
	if( htmlString != null && htmlString.indexOf(Lookup) != -1 )
	{
		alert(idParent+" already exist");
		return;
	}
	var menuTitle="";
	menuTitle += "\n<!-- ITEM "+idTitle+" -->\n";
	if( n )
	{
		menuTitle += "<ilayer name="+idTitle+">";
		menuTitle += "<a href='.' class='clsMenuItemNS' onmouseover=\"displaySubMenu('"+idTitle+"')\" onclick=\"return false;\">";
		menuTitle += "&nbsp;";
		menuTitle += text;
		menuTitle += "</a>";
		menuTitle += "</ilayer>";
	}
	if( ie||ns6 )
	{
		menuTitle += "<td>\n";
		menuTitle += "<div id='"+idTitle+"' style='position:relative; font:"+this.menuFont+";'>\n";
		menuTitle += "<a ";
		menuTitle += "class=clsMenuItemIE ";
//		menuTitle += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.fontColor+"; cursor: hand;' ";
		if( hint != null )
			menuTitle += "title='"+hint+"' ";
		if( location != null )
		{
		    menuTitle += "href='"+location+"' ";
			menuTitle += "onmouseover=\"hideAll()\" ";
		}
		else
		{
			if( altLocation != null )
				menuTitle += "href='"+altLocation+"' ";
			else
				menuTitle += "href='.' ";
			menuTitle += "onmouseover=\"displaySubMenu('"+idTitle+"')\" ";
			menuTitle += "onclick=\"return false;\" "
		}
		menuTitle += ">";
		menuTitle += "&nbsp;\n";
		menuTitle += text;
		menuTitle += "</a>\n";
		menuTitle += "</div>\n";
		menuTitle += "</td>\n";
	}
	menuTitle += "<!-- END OF ITEM "+idTitle+" -->\n\n";
	menuTitle += "<!-- MAIN_MENU -->\n";

	htmlString=htmlString.replace("<!-- MAIN_MENU -->\n", menuTitle);
}
function addBreak()
{
    document.writeln("<br /><br />");
}
function addItem( idParent, text, hint, location, target )
{
	var menuItem="";
	Lookup="<!-- ITEM "+idParent+" -->";
	if( htmlString.indexOf(Lookup) == -1)
	{
		alert(idParent+" not found");
		return;
	}
	Lookup="<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
	if( htmlString != null && htmlString.indexOf(Lookup) == -1 )
	{
		if( n )
		{
			menuItem += "\n";
			menuItem += "<layer id='"+idParent+"submenu' visibility='hide' bgcolor='"+this.bgColorItem+"'>\n";
			menuItem += "<table class='subPanePanel' bgcolor='"+ this.bgColorItem+"' width="+this.subMenuPaneWidth+">\n";
			menuItem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
			menuItem += "</table>\n";
			menuItem += "</layer>\n";
			menuItem += "\n";
		}
		if( ie||ns6 )
		{
			menuItem += "\n";
			menuItem += "<div id='"+idParent+"submenu' onmouseout=operahide(); style='position:absolute; visibility:hidden; z-index:100; width: "+
			    this.subMenuPaneWidth+"; font: "+this.menuFont+"; top:-300;  left:0;'>\n";
			menuItem += "<span class='submMenuPaneBorder'>";
			menuItem += "<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColorItem+"' width="+this.subMenuPaneWidth+">\n";
			//menuItem += "<table class='subMenuPaneBorder' bgcolor='"+this.bgColorItem+"' width="+this.subMenuPaneWidth+">\n";
			menuItem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
			menuItem += "</table>\n";
			menuItem += "</span>";
			menuItem += "</div>\n";
			menuItem += "\n";
		}
		menuItem += "<!-- SUB_MENU -->\n";
		htmlString=htmlString.replace("<!-- SUB_MENU -->\n", menuItem);
	}

	Lookup="<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
	if( n )  
	{
	    if( target != null )
	        menuItem="<tr><td><a class='clsMenuItemNS' title='"+hint+"' href='"+location+"' target='"+target+"'>"+text+"</a><br /></td></tr>\n";
	    else
	        menuItem="<tr><td><a class='clsMenuItemNS' title='"+hint+"' href='"+location+"'>"+text+"</a><br /></td></tr>\n";
	}
	if( ie||ns6 ) 
	{
	    if( target != null )
	        menuItem="<tr><td><a class='clsMenuItemIE' title='"+hint+"' href='"+location+"' target='"+target+"'>"+text+"</a><br /></td></tr>\n";
	    else
	        menuItem="<tr><td><a class='clsMenuItemIE' title='"+hint+"' href='"+location+"'>"+text+"</a><br /></td></tr>\n";
	}
	menuItem += Lookup;
	htmlString=htmlString.replace(Lookup, menuItem);
}
function showMenu()
{
	document.writeln(htmlString);
}
// Private declaration
function displaySubMenu( idMainMenu )
{
	var menu;
	var submenu;
	if( n )
	{
		submenu=document.layers[idMainMenu+"submenu"];
		if( lastMenu != null && lastMenu != submenu ) 
		    hideAll();
		submenu.left=document.layers[idMainMenu].pageX;
		submenu.top=document.layers[idMainMenu].pageY+15;
		leftX =document.layers[idMainMenu+"submenu"].left;
		rightX=leftX+document.layers[idMainMenu+"submenu"].clip.width;
		leftY=document.layers[idMainMenu+"submenu"].top+
			document.layers[idMainMenu+"submenu"].clip.height;
		rightY=leftY;
	} else if( ie ) {
	    sElement=document.getElementById(idMainMenu+"submenu");
		menu=eval(idMainMenu);
		submenu=eval(idMainMenu+"submenu.style");
		submenu.left=calculateSumOffset(menu, 'offsetLeft');
//		submenu.top=calculateSumOffset(menu, 'offsetTop')+30;
		submenu.top=menu.style.top+23;
		if( lastMenu != null && lastMenu != submenu ) 
		    hideAll();
		leftX=document.all[idMainMenu+"submenu"].style.posLeft;
		rightX=leftX+document.all[idMainMenu+"submenu"].offsetWidth;
		leftY=document.all[idMainMenu+"submenu"].style.posTop+
			document.all[idMainMenu+"submenu"].offsetHeight;
		rightY=leftY;
	}
	else if( ns6 ) 
	{
	    sElement=document.getElementById(idMainMenu+"submenu");
		menu=document.getElementById(idMainMenu);
		submenu=sElement.style;
		var nleft=calculateSumOffset(menu, 'offsetLeft');
    	submenu.left=nleft+"px";
		submenu.top=calculateSumOffset(menu, 'offsetTop')+16+"px";
		if( lastMenu != null && lastMenu != submenu ) 
		    hideAll();
		leftX=parseInt(submenu.left);
		rightX=leftX+parseInt(sElement.offsetWidth);
		leftY=parseInt(sElement.style.top)+parseInt(sElement.offsetHeight);
		rightY=leftY;
	}
	submenu.visibility=fShow;
	lastMenu=submenu;
}
function hideAll()
{
	if( lastMenu != null ) 
	{
	    lastMenu.visibility=fHide;
	    lastMenu.left=0;
	}
}
function calculateSumOffset( idTitle, offsetName )
// idTitle is a html div element
{
	var totalOffset=0;
	var item=eval('idTitle');
	do	{
		totalOffset += eval('item.'+offsetName);
		item=eval('item.offsetParent');
	} while( item != null );
	return totalOffset;
}
function updateIt( evt )
{
	if( ie&&!opr6 )
	{
		var x=window.event.clientX;
		var y=window.event.clientY;
		if( x > rightX || x < leftX ) 
		    hideAll();
		else if( y > rightY ) 
		    hideAll();
	}
	if( n||ns6 )
	{
		var x=evt.pageX;
		var y=evt.pageY;
		if( x > rightX || x < leftX ) 
		    hideAll();
		else if( y > rightY ) 
		    hideAll();
	}
}
function operahide()
{
    if( opr6 )
    {
        if( !MainTable.contains(event.toElement) )
            hideAll();
    }
    if( ie||ns6 )
    {
    	document.body.onclick=hideAll;
    	document.body.onscroll=hideAll;
    	document.body.onmousemove=updateIt;
    }
    if( document.layers )
    {
    	window.captureEvents(Event.MOUSEMOVE);
    	window.captureEvents(Event.CLICK);
    	window.onmousemove=updateIt;
    	window.onclick=hideAll;
    }
}
function showHeader()
{
    hdrString="<div id='header'>";
    hdrString += "<a href='./index.htm'>";
    hdrString += "<img src='./images/drBethLogo.gif' width='130' height='53' border='0' alt='Dr. Beth Home' /></a>";
    hdrString += "</div>";
    document.writeln(hdrString);
}
function showHeader2()
{
    hdrString="<div id='header'>";
    hdrString += "<a href='../index.htm'>";
    hdrString += "<img src='../images/drBethLogo.gif' width='130' height='53' border='0' alt='Dr. Beth Home' /></a>";
    hdrString += "</div>";
    document.writeln(hdrString);
}
// from MacroMedia preloads images from the server to the cache so they can be quickly 
// displayed with rollover effects
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_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_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_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];
    }
}

// <<< End of File >>>
