// Author: Vince Reid, vince@virtualred.net
// Copyright: Internet Business Solutions S.L.
// http://www.ibswebdesign.com
// PopOutTextMenu: v1.2
 	
var ie,ns6,ns,opera,ismac; 
var menuid,d6,c2ref; 
var c1,c2,c3; 
var globalsdefined=false;

/* NOTICE:  Use STYLE="padding-left:18px;background-image: url(http://www.droark.com/images/homeYM.gif);position:relative; font-size:10pt; color:#CC6600; to change font colors/size for the menu and submenu. Look for
 STYLE=
for glowing links, use background: rgb(218,165,32);
Change font color for sub-menu in all.css
 */

/* NOTICE: To change bgcolor as desired, chg below and go to 
var mainbgcolor="#ff6666";
var subbgcolor="#ff6666";
Notice: Original background color for menu is #ff6666
*/

/* Start - These are the variables to adjust vertical position of s-u-b-menus */
var chgSubMenuVerticalpos=97;
var chgSubMenupos2Main=-2;
/* var chgSubMenupos2Main=-40; End - These are the variables to adjust vertical position of s-u-b-menus */

/* To change left-hand starting point for main menu, change 
margin-left: 0px;
*/

/* Start - These are the variables to adjust for placing m-a-i-n menu */
var chgLeftImgMain=0;
var chgRightImgMain=0;
var chgTopImgMain=0;
var chgBottomImgMain=0;

var chgTLeftCornerMain=0;
var chgTRightCornerMain=0;
var chgBLeftCornerMain=0;
var chgBRightCornerMain=0;
/* End - These are the variables to adjust for placing m-a-i-n menu */


var chgTLverticalpos=0;
var chgTRverticalpos=0;
var chgBLverticalpos=0;
var chgBRverticalpos=0;
var mtextadj=0;
var mainhgtadj=0;
var mainwidthadj=0;
var subhgtadj=0;
var subwidthadj=0;
var valuecolsp=3;


var debugstr=""; 
var debug=false; 

function addtodebug(str){ debugstr += str+'\n'; }; 

function showdebug(){ alert(debugstr+'\n'); debugstr=""; }; 

function d3(ginfref,top,c4,sub,c9){ this.d4=ginfref; this.d5=top; this.c4=c4; this.submenu=0; this.sub=sub; this.c9=c9; this.d1=0; this.d2=0; this.b1=0; this.a8=0; this.a9=0; }; 

function a0(){ this.b2=0; this.b3=0; this.b4=0; this.b5=0; this.b8=0; this.b9=0; this.b7=0; this.b6=0; }; 

function defineglobals(){ if(globalsdefined==true) return; ie=(document.all != (void 0)); ns6=(document.getElementById&&!document.all); ns=(document.layers != (void 0)); ismac=(navigator.appVersion.indexOf("Mac") != -1); opera=false; if(ie){ var agent=navigator.userAgent.toLowerCase(); opera=(agent.indexOf("opera") != -1); }; c1=new Array(); c3=new Array(); c2 = new Array(); menuid=1; d6=1; c2ref=1; }; 

function showrootmenu(c8){ if(ie){ mnn=eval('vrsub'+c8); mnn.style.visibility="visible"; } else if(ns6){ mnn=document.getElementById('vrsub'+c8); mnn.style.visibility="visible"; } else if(ns){ mnn=eval('document.layers.vrsub'+c8); mnn.visibility="show"; }; }; 

function c6(c8, whichmenu){ c8=c3[c8].sub; while(c8 != 0){ if(c3[c8].c4 == whichmenu) return true; c8=c3[c8].sub; }; return false; }; 

function c7(c8, whichitem){ while(whichitem != 0){ if(whichitem == c8) return true; whichitem=c3[whichitem].d5; }; return false; }; 

function c5(c8){ var loindex=65535, hiindex=0, tm = new Array(), thetop, ii; for(ii=c2[c3[c8].d4].b8;ii <= c2[c3[c8].d4].b9;ii++){ if(c3[ii].c4 < loindex) loindex=c3[ii].c4; if(c3[ii].c4 > hiindex) hiindex=c3[ii].c4; if(c3[ii].d5 == 0) thetop = ii; if(c7(ii, c2[c3[c8].d4].b5)){ tm[c3[ii].c4]=true; } else if(c2[c3[c8].d4].b4 != 0 && c3[ii].c4 == c3[c2[c3[c8].d4].b5].submenu) tm[c3[ii].c4]=true; }; tm[c2[c3[c8].d4].b4]=true; for(ii=loindex;ii <= hiindex;ii++){ if(tm[ii]==true){ mnn=eval('document.layers.vrsub' +ii); if(mnn.visibility != "show") mnn.visibility="show"; } else{ if(ii != c3[thetop].c4){ mnn=eval('document.layers.vrsub' +ii); if(mnn.visibility != "hide") mnn.visibility="hide"; }; }; }; };

function a6(c8){ c2[c3[c8].d4].b4=c3[c8].c4; if(ns){ c5(c8); } else{ while(c3[c8].d5 != 0){ if(ie){ mnn=eval('vrsub'+c3[c8].c4); mnn.style.visibility="visible"; } else if(ns6){ mnn=document.getElementById('vrsub'+c3[c8].c4); if(mnn.style.visibility!="visible") mnn.style.visibility="visible"; } c8=c3[c8].d5; } }; }; 

function a5(c8){ while(c3[c8].d5 != 0){ if(c3[c8].c4 != c2[c3[c8].d4].b4){ if(ie){ mnn=eval('vrsub'+c3[c8].c4); mnn.style.visibility="hidden"; } else if(ns6){ mnn=document.getElementById('vrsub'+c3[c8].c4); if(mnn.style.visibility!="hidden") mnn.style.visibility="hidden"; } else if(ns){ mnn=eval('document.layers.vrsub'+c3[c8].c4);
mnn.visibility="hide"; } } else break; c8=c3[c8].d5; }; }; 

function a4(c8){ var tmi=c8; c2[c3[c8].d4].b5=c8; if(c3[c8].sub != 0){ if(ie){ var mnp=eval('vrsub'+c3[c8].c4); var offsetleft=0, offsettop=0; if(ismac){ offsettop=mnp.style.pixelTop; offsetleft=mnp.style.pixelLeft; } else{ do{ offsetleft += mnp.offsetLeft; offsettop += mnp.offsetTop; mnp=mnp.offsetParent; } while (mnp != null); } mnn=eval('vrsub'+c3[c3[c8].sub].c4); mnn.style.pixelTop=offsettop+(c3[c8].c9*c3[c8].d1)+c2[c3[c8].d4].b3; mnn.style.pixelLeft=offsetleft+c3[c8].d2+c3[c8].a9-c2[c3[c8].d4].b2; mnn.style.visibility="visible"; } else if(ns){ mnn=eval('document.layers.vrsub'+c3[c3[c8].sub].c4); mnp=eval('document.layers.vrsub'+c3[c8].c4); mnn.top=mnp.pageY+(c3[c8].c9*c3[c8].d1)+c2[c3[c8].d4].b3; mnn.left=mnp.pageX + mnp.clip.right-c2[c3[c8].d4].b2-c3[c8].a8; mnn.visibility="show"; for(ii=c2[c3[c8].d4].b8;ii <= c2[c3[c8].d4].b9;ii++){ if(c3[ii].sub!=0&&c3[c8].c4==c3[ii].c4&&ii!=c8){ mnn=eval('document.layers.vrsub'+c3[c3[ii].sub].c4); mnn.visibility="hide"; } } } else if(ns6){ mnn=document.getElementById('vrsub'+c3[c3[c8].sub].c4); mnp=document.getElementById('vrsub'+c3[c8].c4); mnn.style.top=mnp.offsetTop+(c3[c8].c9*c3[c8].d1)+c2[c3[c8].d4].b3; mnn.style.left=mnp.offsetLeft+c3[c8].d2+c3[c8].a9-c2[c3[c8].d4].b2; mnn.style.visibility="visible"; } }; }; 

function a7(c8){ if(c3[c8].sub != 0){ if(ie){ mnn=eval('vrsub'+c3[c3[c8].sub].c4); mnn.style.visibility="hidden"; } else if(ns){ mnn=eval('document.layers.vrsub'+c3[c3[c8].sub].c4); mnn.visibility="hide"; } else if(ns6){ mnn=document.getElementById('vrsub'+c3[c3[c8].sub].c4); mnn.style.visibility="hidden"; c2[c3[c8].d4].b5=0; }; }; }; 

function POTMenu(){ POTMenu.prototype.addMenu=function(mid,mtext,mlink){ if(c1[mid]) alert('Menu id '+mid+' is already defined.'); if(c0==true) alert('You have to define all the main menus before defining the sub menus'); d6++; c3[d6]=new d3(this.f3,0,menuid,0,this.nomenus); c3[d6].d1=this.g1+this.mainspacery; c3[d6].d2=this.g3; c3[d6].b1=this.imgheight; c3[d6].a8=this.f9; c3[d6].a9=this.f8; c1[mid]=d6; this.nomenus++; if(d6>this.firstmenuitem&&this.mainspacery>0){ this.d8 += '<tr><td width="'+this.g3+'" height="'+this.mainspacery+'">'; this.d8 += '<img border="0" src="'+this.mainspacer+'" width="'+this.g3+'" height="'+this.mainspacery+'">'; this.d8 += '</td></tr>'; }; if(ie){ this.d8 += '<tr><td width="'+this.g3+'" height="'+this.g1+'" bgcolor="'+this.maincbgcolor+'">'; this.d8 += '<div class=menu id="imx'+d6+'" onMouseover="a4('+d6+')" onMouseout="a7('+d6+')" STYLE="padding-left:18px;background-image: url(http://www.droark.com/images/1peatred18x126.gif);position:relative; font-size:8pt; color:#660000; margin-left: 0px; width:'+this.g3+'; z-index: 6">'; this.d8 += '<img align="absmiddle" border="0" src="'+this.mainpreim+'" width="'+this.mainpreimx+'" height="'+this.mainpreimy+'">'; if(mlink != "") this.d8 += '<a class=menu href="'+mlink+'">'; this.d8 += mtext; if(mlink != "") this.d8 += '</a>'; this.d8 += '</div></td></tr>'; } else if(ns){ this.d8 += '<tr><td valign="center" class=menu width="'+this.g3+'" height="'+this.g1+'" bgcolor="'+this.maincbgcolor+'">'; this.d8 += '<ilayer visibility="show"><layer width="'+this.g3+'" height="'+this.g1+'" onmouseover="a4('+d6+');" onMouseout="c2[c3['+d6+'].d4].b6=setTimeout(\'a7('+d6+')\',100);">'; if(this.nnmainheight > 0) this.d8 += '<img align="textbottom" border="0" src="'+this.mainpreim+'" width="'+this.g3+'" height="'+this.nnmainheight+'"><! br>'; this.d8 += '&nbsp;'; if(mlink != "") this.d8 += '<a class=menu href="'+mlink+'">'; this.d8 += mtext; if(mlink != "") this.d8 += '</a>'; this.d8 += '</layer></ilayer></td></tr>'; } else if(ns6){ this.d8 += '<tr><td valign="top" width="'+this.g3+'" height="'+this.g1+'" bgcolor="'+this.maincbgcolor+'">'; this.d8 += '<div class=menu id="noimx'+d6+'" onMouseover="a4('+d6+')" onMouseout="a7('+d6+')" STYLE="position:relative; font-size:10pt; color:#CC6600; margin-left: 0px; visibility: visible">'; this.d8 += '<img name="imx'+d6+'" align="absmiddle" border="0" src="'+this.mainpreim+'" width="'+this.mainpreimx+'" height="'+this.mainpreimy+'">'; 
				if(mlink != "") this.d8 += '<a class=menu href="'+mlink+'">'; 

				this.d8 += mtext; if(mlink != "") this.d8 += '</a>'; 
				this.d8 += '</div></td></tr>'; 
			}; 
	};

POTMenu.prototype.addSubMenu=function(mid, submid, mtext, murl)
	{ 
		if(!c1[mid]) alert('No menu named '+mid+' has been defined.'); 
		
		d6++; 
		if(this.g4 != mid)
			{ 
				if(this.g4!=null)
					{ 
						var d1=((27));
						if(ns) this.d7 += '</layer>'; 
						else this.d7 += '</div>'; 
					} 
				menuid++; 
				this.g4=mid; 
				if(ie) this.d7 += '<div class=menu id="vrsub'+menuid+'" onMouseover="a6('+d6+')" onMouseout="c2[c3['+d6+'].d4].b4=0;a5('+d6+')" style="height:27;position:absolute; font-size:10pt; color:#CC6600; z-index:2; visibility: hidden;">';
				else if(ns6) this.d7 += '<div class=menu id="vrsub'+menuid+'" onMouseover="a6('+d6+')" onMouseout="c2[c3['+d6+'].d4].b4=0;a5('+d6+')>'; 
				else if(ns) this.d7 += '<layer id="vrsub'+menuid+'" onMouseover="clearTimeout(c2[c3['+d6+'].d4].b6);clearTimeout(c2[c3['+d6+'].d4].b7);a6('+d6+')" onMouseout="c2[c3['+d6+'].d4].b4=0;c2[c3['+d6+'].d4].b7=setTimeout(\'a5('+d6+')\',100)" visibility="hide">'; 
			} 
			if(ie)
				{ 
					this.d7 += '<div class=menu id="imx'+d6+'" onMouseover="a4('+d6+')" onMouseout="a7('+d6+')">'; 
					if(murl != "") this.d7 += '<a class=menu href="'+murl+'">'; 

					this.d7 += mtext; 
					if(murl != "") this.d7 += '</a>'; 

					this.d7 += '</div>'; 
				} 
			else if(ns6)
				{ 
					this.d7 += '<div class=menu id="noimx'+d6+'" onMouseover="a4('+d6+')" onMouseout="a7('+d6+')">'; 
					if(murl != "") this.d7 += '<a class=menu href="'+murl+'">'; 

					this.d7 += mtext; 
					if(murl != "") this.d7 += '</a>'; 

					this.d7 += '</div>'; 
				} 
			else
				{ 
					this.d7 += '<ilayer id="imx'+d6+'"><layer class=menu onMouseover="a4('+d6+')" onMouseout="c2[c3['+d6+'].d4].b6=setTimeout(\'a7('+d6+')\',100)">'; 
					if(murl != "") this.d7 += '<a class=menu href="'+murl+'">'+mtext+'</a>'; 
					else this.d7 += mtext;

					this.d7 += '</layer></ilayer>'; 
				}; 
			c3[d6]=new d3(this.f3,c1[mid],menuid,0,this.nomenus); 
			c3[c1[mid]].sub=d6; 
			this.nomenus++; 
	};

POTMenu.prototype.startMenu=function(){ defineglobals(); c2[c2ref]=new a0(); this.f3=c2ref; c2ref++; menuid++; c2[this.f3].b2=this.b2; c2[this.f3].b3=this.b3; this.rootmenu=menuid; this.firstmenuitem=d6+1; c2[this.f3].b8=this.firstmenuitem; if(opera) this.d8 += '<div id="vrsub'+menuid+'" STYLE="position:relative; font-size:10pt; color:#CC6600;  margin-left: 0px;">'; else if(ie){ if(ismac) this.d8 += '<div id="theroot" STYLE="position:absolute; font-size:10pt; color:#CC6600;  visibility: hidden;">'; this.d8 += '<div id="vrsub'+menuid+'" STYLE="position:absolute; font-size:10pt; color:#CC6600;  margin-left: 0px; visibility: hidden;">'; } else if(ns6){ this.d8 += '<div id="vrsub'+menuid+'" STYLE="position:absolute; font-size:10pt; color:#CC6600;  margin-left: 0px; visibility: hidden;">'; } else if(ns){ this.d8 += '<ilayer id="vrsub'+menuid+'" visibility="show"><layer>'; }; this.d8 += '<table border="0" cellspacing="0" cellpadding="0"><tr><td colspan=3-valuecolsp>'; this.d8 += '<img src="'+this.f7+'" border="0" width="'+this.imgcornerleft+'" height="'+this.imgheight+'">'; this.d8 += '<img src="'+this.imgtop+'" border="0" width="'+(this.g3-this.mainba)+'" height="'+this.imgheight+'">'; this.d8 += '<img src="'+this.f6+'" border="0" width="'+this.imgcornerright+'" height="'+this.imgheight+'"></td></tr><tr><td>'; this.d8 += '<img src="'+this.imgleft+'" border="0" width="'+this.f8+'" height="imgplaceholder">'; this.d8 += '</td><td><table border="0" cellspacing="0" cellpadding="0">'; }; 

POTMenu.prototype.showMainMenu=function(){ var d1=((this.nomenus-1)*this.mainspacery)+this.nomenus*this.g1; this.d8 += '</table></td><td><img src="'+this.imgright+'" border="0" width="'+this.f9+'" height="'+d1+'"></td></tr>'; this.d8 += '<tr><td colspan=3-valuecolsp showMainMenu><img src="'+this.f5+'" border="0" width="'+this.imgcornerleft+'" height="'+this.imgheight+'">'; this.d8 += '<img src="'+this.imgbottom+'" border="0" width="'+(this.g3-this.mainba)+'" height="'+this.imgheight+'">'; this.d8 += '<img src="'+this.f4+'" border="0" width="'+this.imgcornerright+'" height="'+this.imgheight+'"></td></tr></table>'; if(ie||ns6) this.d8 += '</div>'; else if(ns) this.d8 += '</layer></ilayer>'; document.write(this.d8.replace("imgplaceholder", d1)); this.nomenus=0; }; 

POTMenu.prototype.showMenu=function()
	{ 
		var d1=((this.nomenus-1)*this.subspacery)+this.nomenus*this.subcheight; 
		if(ie)
			{ 
				this.d7 += '</div>'; 
				if(ismac) this.d7 += '</div>'; 
			} 
		else if(ns6)
			{ 
				this.d7 += '</div>'; 
			} 
		else if(ns) this.d7 += '</layer>'; 

		document.write(this.d7.replace("", ""));
		c2[this.f3].b9=d6; 
		c1=new Array(); 
		showrootmenu(this.rootmenu); 
	}; 

POTMenu.prototype.mainmenuitemsize=function(width,height){ this.g3=width-mainwidthadj; this.g1=height-mainhgtadj; this.mainpreimy=height-mainhgtadj; };

POTMenu.prototype.submenuitemsize=function(width,height)
	{ 
		this.subcwidth=0; 
		this.subcheight=0; 
		this.subpreimy=0;
	};
 
//This is the location to adjust placing of s-u-b-menus
//Adjust placing the subs here ...
POTMenu.prototype.submenuplacing=function(b2,b3)
	{ 
		this.b2=Math.abs(b2-chgSubMenupos2Main); 
		this.b3=b3-chgSubMenuVerticalpos;
	}; 

POTMenu.prototype.mainborderimages=function(left,right,top,bottom){ this.imgleft=left -chgLeftImgMain; this.imgright=right -chgRightImgMain; this.imgtop=top -chgTopImgMain; this.imgbottom=bottom -chgBottomImgMain; }; 

POTMenu.prototype.mainbordercorners=function(topleft,topright,bottomleft,bottomright){ this.f7=topleft -chgTLeftCornerMain; this.f6=topright -chgTRightCornerMain; this.f5=bottomleft -chgBLeftCornerMain; this.f4=bottomright -chgBRightCornerMain; }; 

POTMenu.prototype.mainborderdimensions=function(leftwidth,rightwidth,height)
	{ 
		this.imgcornerleft=this.f8=0; 
		this.imgcornerright=this.f9=0; 
		this.imgheight=0;
		this.mainba=0;
	}; 

POTMenu.prototype.subborderimages=function(left,right,top,bottom)
	{ 
		this.h9=0; 
		this.f10=0; 
		this.h6=0; 
		this.h5=0;
	}; 

POTMenu.prototype.subbordercorners=function(topleft,topright,bottomleft,bottomright)
	{ 
		this.h4=0; 
		this.h3=0; 
		this.h2=0; 
		this.h1=0;
	}; 

POTMenu.prototype.subborderdimensions=function(leftwidth,rightwidth,height)
	{ 
		this.a2=this.h8=0; 
		this.a1=this.f1width=0; 
		this.g2=0;
		this.subba=0; 
	}; 

POTMenu.prototype.definejoin=function(join,joinheight)
	{ 
		this.f2=0; 
		this.d9=0;
	}; 

POTMenu.prototype.maincornerwidths=function(leftwidth,rightwidth){ this.imgcornerleft=leftwidth; this.imgcornerright=rightwidth; this.mainba=(leftwidth+rightwidth)-(this.f8+this.f9); };

POTMenu.prototype.subcornerwidths=function(leftwidth,rightwidth)
	{ 
		this.a2=0; 
		this.a1=0; 
		this.subba=0;
	}; 

// Change bgcolor to mainbgcolor and subbgcolor respectively for the following main and sub functions.
POTMenu.prototype.mainmenucolor = function(bgcolor){ this.maincalign = "left"; this.maincbgcolor = bgcolor; };

POTMenu.prototype.submenucolor = function(bgcolor){ this.subcalign = "left"; this.subcbgcolor = bgcolor; };

POTMenu.prototype.mainpreimage = function(pim,pio,pix,piy){ this.mainpreim = 0; this.mainpreimov = 0; this.mainpreimx = 0; this.mainpreimy = 0; }; 

POTMenu.prototype.subpreimage = function(pim,pio,pix,piy)
	{ 
		this.subpreim = 0; 
		this.subpreimov = 0; 
		this.subpreimx = 0; 
		this.subpreimy = 0;
	}; 

POTMenu.prototype.definemainspacer = function(name,height){ this.mainspacer = name; this.mainspacery = height-mainhgtadj; };

POTMenu.prototype.definesubspacer = function(name,height)
	{ 
		this.subspacer = 0; 
		this.subspacery = 0;
	}; 

POTMenu.prototype.netscapeadjust = function(main,sub)
	{ 
		this.nnmainheight = main; 
		this.nnsubheight = sub; 
	}; 
	this.mainmenuitemsize(157,27); 
	this.submenuitemsize(157,27); 
	this.submenuplacing(00,0); 
	this.mainborderdimensions(1,1,1); 
	this.subborderdimensions(1,1,1); 

this.mainborderimages("clearpixel.gif","clearpixel.gif","clearpixel.gif","clearpixel.gif"); 

this.mainbordercorners("clearpixel.gif","clearpixel.gif","clearpixel.gif","clearpixel.gif"); 

this.subborderimages("clearpixel.gif","clearpixel.gif","clearpixel.gif","clearpixel.gif"); 

this.subbordercorners("clearpixel.gif","clearpixel.gif","clearpixel.gif","clearpixel.gif"); 

this.definejoin("",0); 

this.mainpreimage("clearpixel.gif","clearpixel.gif",5,27); 

this.subpreimage("clearpixel.gif","clearpixel.gif",5,27); 

this.definemainspacer("",0); 

this.definesubspacer("",0); 

this.g4=null; 

this.d8=""; 

this.d7=""; 

this.nomenus=0; 

this.netscapeadjust(0,0); 

c0=false; 

} 