 
function checkBrowser()
{
	this.ver = navigator.appVersion;
	this.dom = document.getElementById?1:0;
//	this.ie5 = ((this.ver.indexOf("MSIE 5")>-1 && this.dom)||(this.ver.indexOf("MSIE 6")>-1 && this.dom))?1:0;
	
	this.ie5 = this.dom && (this.ver.indexOf("MSIE 5")>-1||this.ver.indexOf("MSIE 6")>-1||this.ver.indexOf("MSIE 7")>-1||this.ver.indexOf("MSIE 8")>-1)?1:0;
	
	
	this.ie4 = (document.all && !this.dom)?1:0;
	this.ns5 = (this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4 = (document.layers && !this.dom)?1:0;

	return this;
}

function makePageCoords()
{
	this.x=0;
	this.y=0;
	this.x2=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth-20;
	this.y2=(bw.ns4 || bw.ns5)?innerHeight:document.body.offsetHeight-5;

	return this;
}

function resized()
{
	page2 = new makePageCoords();

	if (page2.x2!=page.x2 || page.y2!=page2.y2) 
		location.reload();
}

var bw   = new checkBrowser();
var page = new makePageCoords(); //Page variable, holds the width and height of the document. (see documentsize tutorial on bratta.com/dhtml)

var explorerev='';


function menuObj(name)
{
// private members
	this.name       = name;
	this.mainmenus  = 0; 
	this.submenus   = new Array();
// private methods
	this.checkp     = checkp;
	this.menumain   = menumain;
	this.hidemain   = hidemain;
	this.hideactive = hideactive;
// public members
	this.clMain ='padding:2px; font-family:verdana; font-size:10px; font-weight:bold;' ; //The style for the main menus
	this.clSub  ='padding:2px; font-family:verdana; font-size:10px; font-weight:bold;' ; //The style for the submenus
	this.clAMain='text-decoration:none; color:White;' ;   //The style for the main links
	this.clASub ='text-decoration:none; color:White;' ;    //The style for the sub links

	this.backgroundbar         = 1;     // Set to 0 if no backgroundbar
	this.backgroundbarfromleft = 0;     // The left placement of the backgroundbar in pixel or %
	this.backgroundbarfromtop  = 0;     // The top placement of the backgroundbar  in pixel or %
	this.backgroundbarsize     = "100%";// The size of the bar in pixel or %
	this.backgroundbarcolor    = "navy";// The backgroundcolor of the bar

	this.mainheight=18;                 // The height of the main menuitems in pixel or %
	this.mainwidth=110;                 // The width of the main menuitems  in pixel or %

	this.subwidth=120; // this.mainwidth;       // The width of the submenus
	this.subheight=18;                  // The height if the subitems in pixel or % 

	this.subplacement=this.mainheight;  // Relative to the main item

	this.mainbgcoloroff = 'green';	// The backgroundcolor of the main menuitems   #6699CC
	this.mainbgcoloron  = 'red';	// The backgroundcolor on mouseover of the main menuitems	#996699
	this.subbgcoloroff  = 'lightgreen';	// The backgroundcolor of the sub menuitems					   #006699
	this.subbgcoloron   = 'lightseagreen';	// The backgroundcolor on mouseover of the sub menuitems  #9966cc
	this.stayoncolor    = 0;            // Do you want the menus to stay on the mouseovered color when clicked?  [1]

	this.menuspeed=10;					// The speed of the clipping in px

	this.menurows=1;					// Set to 0 if you want rows and to 1 if you want columns

	this.menueventon="mouse";			// Set this to "mouse" if you want the menus to appear onmouseover, set it to "click" if you want it to appear onclick
	this.menueventoff="mouse";			// Set this to "mouse" if you them to disappear onmouseout, if not set it to "click"

//Example in %:
//this.menuplacement=new Array("20%","40%","60%","50%","65%") //Remember to make the arrays contain as many values as you have main menuitems
//Example in px: (remember to use the ' ' around the numbers)
//this.menuplacement=new Array(10,200,300,400,500)
//Example right beside eachother (only adding the pxbetween variable)
	this.menuplacement=0;

	this.pxbetween=2;	// in pixel or % [2] If you use the "right beside eachother" you cant how many pixel there should be between each here
	this.fromleft=0;	// in pixel or % And you can set where it should start from the left here
	this.fromtop=0;		// in pixel or % This is how much from the top the menu should be.
// public methods
	this.makeStyle = makeStyle;
	this.makeMain  = makeMain;
	this.makeSub   = makeSub;
	this.construct = constructMenu;
}

function constructMenu()
{
	this.mainwidth    = checkp(this.mainwidth);
	this.mainheight   = checkp(this.mainheight);
	this.subplacement = checkp(this.subplacement);
	this.subwidth     = checkp(this.subwidth);
	this.subheight    = checkp(this.subheight);

	if (this.backgroundbar)
	{ 
		this.oBackgroundbar = new makeMenu(this,'div'+this.name+'Backgroundbar','',-1);
		this.oBackgroundbar.moveIt(this.checkp(this.backgroundbarfromleft),this.checkp(this.backgroundbarfromtop));
		if (this.menurows) 
		{
			this.oBackgroundbar.PaintSize(this.mainheight,this.checkp(this.backgroundbarsize));
		}
		else 
		{
			this.oBackgroundbar.PaintSize(this.checkp(this.backgroundbarsize,this.mainwidth));
		}
		this.oBackgroundbar.SetBkColor(this.backgroundbarcolor);
	}

	this.x=this.checkp(this.fromleft); 
	this.y=this.checkp(this.fromtop);
	
	for (i=0;i<this.mainmenus;i++)
	{
		this[i] = new makeMenu(this,'div'+this.name+'Main'+i,'',0,i);
		this[i].PaintSize(this.mainheight,this.mainwidth);

		if (this.menuplacement!=0)
		{
			if (this.menurows) 
				this.x=this.checkp(this.menuplacement[i]);
			else 
				this.y=this.checkp(this.menuplacement[i]);
		}
		
		this[i].moveIt(this.x,this.y);
		this[i].SetBkColor(this.mainbgcoloroff);
		
		if (this.menurows) 
			this.x+=this.mainwidth+this.checkp(this.pxbetween);
		else 
			this.y+=this.mainheight+this.checkp(this.pxbetween);
		
		if (this.submenus[i]!='nosub')
		{
			this[i].subs = new makeMenu(this,'div'+this.name+'Sub'+i,'',1,i,-1);
		
			if (this.menurows) 
				this[i].subs.moveIt(this[i].x,this[i].y+this.subplacement);
			else 
				this[i].subs.moveIt(this.subplacement+this[i].x,this[i].y);
		
			this.suby = 0;
			this[i].sub = new Array();
	 		
			for (j=0;j<this.submenus[i]["main"];j++)
			{
				this[i].sub[j] = new makeMenu(this,'div'+this.name+'Sub'+i+'_'+j,'div'+this.name+'Sub'+i,2,i,j);
				this[i].sub[j].PaintSize(this.subheight,this.subwidth);
				this[i].sub[j].moveIt(0,this.suby);
				this[i].sub[j].SetBkColor(this.subbgcoloroff);
				this.suby+=this.subheight;
				this[i].sub[j].subs = 0;
			}
			this[i].subs.PaintSize(0,this.subwidth);
			this[i].subs.clipheight=this.suby;
		}
		else
		{
			this[i].subs = 0; 
		}
	}
	
	setTimeout("window.onresize=resized;",500);
	if (this.menueventoff=="mouse")
	{
		if (!bw.ns5 && !bw.ns4)
		{
			explorerev+=this.name+".hidemain(-1);"; 
			document.onmouseover = new Function(explorerev);
		}
	}
}

function makeMenu(parent,obj,nest,type,num,subnum)
{
    nest            = (!nest) ? '':'document.'+nest+'.';
   	this.css        = bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;					
	this.Element    = bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;		
	this.height     = bw.ns4?this.css.document.height:this.Element.offsetHeight;
	this.width      = bw.ns4?this.css.document.width:this.Element.offsetWidth;
	this.moveIt     = m_moveIt; 
	this.SetBkColor = m_SetBkColor;	
	this.PaintSize  = m_PaintSize;
	this.parent     = parent;
	this.active     = 0;
	this.nssubover  = 0;
	if (type==0)
	{
		this.Element.onmouseover = new Function("MouseOver("+num+","+this.parent.name+")");
		this.Element.onmouseout  = new Function("MouseExit("+num+","+this.parent.name+")");
	}
	else if (type==1)
	{
		this.PaintHide     = m_PaintHide;
		this.PaintShow     = m_PaintShow;
		this.PaintControls = m_PaintControls;
		this.clip_y=0;

		if ((bw.ns5 || bw.ns4) && this.parent.menueventoff=="mouse")
		{ 
			this.Element.onmouseover = new Function(this.parent.name+"["+num+"].nssubover=true");
			this.Element.onmouseout  = new Function("setTimeout('if(!"+this.parent.name+"["+num+"].nssubover)"+this.parent.name+".hideactive("+num+");',100)");
		}
	}
	else if (type==2)
	{
		this.Element.onmouseover = new Function("MouseOver_sub("+num+","+subnum+","+this.parent.name+")");
		this.Element.onmouseout  = new Function("MouseExit_sub("+num+","+subnum+","+this.parent.name+")");
	}

	this.time_out=100;
    this.obj = obj + "Object"; 	eval(this.obj + "=this");	
	
	return this;
}

function makeMain(num,text,link,target)
{
	str="";
	if (this.backgroundbar && num==0)
	{
		str+='\n<div id="div'+this.name+'Backgroundbar"></div>\n';
	}
	str+='<div id="div'+this.name+'Main'+num+'" class="cl'+this.name+'Main">';
	if (link)
	{ 
		str+='<a href="'+link+'"'; this.submenus[num]='nosub';
	}
	else 
		str+='<a href="#" onclick="'+this.name+'.menumain('+num+'); return false"';
	if (target) 
		str+=' target="'+target+'" ';
	str+=' class="clA'+this.name+'Main">'+text+'</a></div>\n';
	this.mainmenus++; 
	
	document.write(str);
}
		  
function makeSub(num,subnum,text,link,total,target)
{
	str="";
	if (subnum==0) 
		str='<div id="div'+this.name+'Sub'+num+'" class="cl'+this.name+'Subs">\n';
	str+='\t<div id="div'+this.name+'Sub'+num+'_'+subnum+'" class="cl'+this.name+'Sub">';
	if (link) str+='<a href="'+link+'"'; 
	if (target) str+=' target="'+target+'" ';
	str+=' class="clA'+this.name+'Sub">'+text+'</a></div>\n';
	if (subnum==total-1)
	{
		str+='</div>\n'; 
		this.submenus[num] = new Array();
		this.submenus[num]["main"]=total; 
		this.submenus[num]["submenus"] = new Array();
	}
	
	document.write(str);
}

function makeStyle()
{
	str='\n<style type="text/css">\n';
	str+='\tDIV.cl'+this.name+'Main{position:absolute; z-index:51; clip:rect(0,0,0,0); overflow:hidden; width:'+(this.mainwidth-10)+'; '+this.clMain+'}\n';
	str+='\tDIV.cl'+this.name+'Sub{position:absolute; z-index:52; clip:rect(0,0,0,0); overflow:hidden; width:'+(this.subwidth-10)+'; '+this.clSub+'}\n';
	str+='\tDIV.cl'+this.name+'Subs{position:absolute; z-index:53; clip:rect(0,0,0,0); overflow:hidden}\n';
	str+='\t#div'+this.name+'Backgroundbar{position:absolute; z-index:50; clip:rect(0,0,0,0); overflow:hidden}\n';
	str+='\tA.clA'+this.name+'Main{'+this.clAMain+'}\n';
	str+='\tA.clA'+this.name+'Sub{'+this.clASub+'}\n';
	str+='</style>\n\n';

	document.write(str);
}

function checkp(num)
{
	if (num)
	{
		if (num.toString().indexOf("%")!=-1)
		{
			if (this.menurows)
				num=(page.x2*parseFloat(num)/100);
			else 
				num=(page.y2*parseFloat(num)/100);
		}
		else
		{ 
			num=parseFloat(num);
		}
	}
	else
	{ 
		num=0;
	}

	return num;
}

function m_SetBkColor(color)
{
	if (bw.dom || bw.ie4) 
		this.css.backgroundColor=color;
	else if (bw.ns4) 
		this.css.bgColor=color;
}

function m_moveIt(x,y)
{
	this.x=x; 
	this.y=y; 
	this.css.left=this.x;
	this.css.top=this.y;
}

/*
	The Microsoft Explorer DOM supports 'style' with their widgets the Netscape DOM does not.
	This means in Netscape Widgets need to be nested inside a SPAN
	Once nested this allows the DOM to be searched for LAYERS
	It is rather a Hack that the caller	has to name the SPAN specifically with 'Block' in its ID
	If this is not enough as Danny Goodman (ISBN 1-56592-494-0) pointed out to me
	Netscape SELECT Widgets do not fire unless you double nest the SPAN around the FORM.
 */

function m_PaintControls(show)
{
	var Obj;
	var f;
	var j;

	if ( bw.ie4 || bw.ie5 || bw.ns5 )
	{
		for (f=0;f<document.forms.length;f++)
		{
			for (j=0;j<document.forms[f].elements.length;j++)
			{
				if (document.forms[f].elements[j].type.indexOf("select")!=-1) 
				{
					Obj = document.forms[f].elements[j];
					if (show) 
					{
						Obj.style.visibility = "visible" ;
					}
					else
					{
						objLeft   = Obj.offsetLeft;
						objTop    = Obj.offsetTop;
						objParent = Obj.offsetParent;
						while (objParent.tagName.toUpperCase() != "BODY")
						{
							objLeft  += objParent.offsetLeft;
							objTop   += objParent.offsetTop;
							objParent = objParent.offsetParent;
						}
						objTop = objTop - this.parent.mainheight;
						if (this.clipheight>objTop && 
						    this.x<objLeft+Obj.offsetWidth && 
							this.x+parseFloat(this.css.width)>objLeft)
						{
							Obj.style.visibility = "hidden";
						}
					}
				}									
			}
		}
	}
	else
	{	
		for (f=0;f<document.layers.length;f++)
		{
			Obj = document.layers[f];
			if (Obj.name.indexOf("Block")>0)
			{
				if (show) 
				{
					Obj.visibility = "visible" ;
				}
				else
				{
					if (this.clipheight>Obj.pageY && this.x<Obj.pageX+Obj.clip.width && this.x+this.css.clip.right>Obj.pageX)
					{
						Obj.visibility = "hidden";
					}
				}
				/* 
					In Order For Netscape To Fire A Select Widget Double Nesting Is Needed 
				*/
				var k ;
				for (k=0;k<document.layers[f].document.layers.length;k++)
				{
					Obj = document.layers[f].document.layers[k];
					if (show) 
					{
						Obj.visibility = "visible" ;
					}
					else
					{
						if (this.clipheight>Obj.pageY && this.x<Obj.pageX+Obj.clip.width && this.x+this.css.clip.right>Obj.pageX)
						{	
							Obj.visibility = "hidden";
						}
					}
				}

			}		
		}		
	}
}

function m_PaintSize(b,r)
{
	t=0;
	l=0;
	this.clip_x=r;
	if (bw.ns4)
	{
		this.css.clip.top    = t;
		this.css.clip.left   = l; 
		this.css.clip.bottom = b;
		this.css.clip.right  = r
	}
	else
	{
		this.css.clip="rect("+t+","+r+","+b+","+l+")"; 
		this.css.height= b; 
		this.css.width = r;
	}
} 

function m_PaintHide(speed)
{
	if (this.clip_y>-speed)
	{ 
		this.clip_y-=speed;
		if (this.clip_y<0) this.clip_y=0;
		this.PaintSize(this.clip_y,this.clip_x);
		/* == Set The Recursion To Call This Method Function Again == */
		this.time_out=setTimeout(this.obj+".PaintHide("+speed+")",10);
	}
	else
	{
		this.clip_y=0; 
		this.PaintSize(this.clip_y,this.clip_x);
	}	
}

function m_PaintShow(speed)
{
	if (this.clip_y<this.clipheight+10)
	{ 
		this.clip_y+=speed;
		this.PaintSize(this.clip_y,this.clip_x);
		/* == Set The Recursion To Call This Method Function Again == */
		this.time_out=setTimeout(this.obj+".PaintShow("+speed+")",10);
	}
	else
	{
		this.PaintControls(0);	/* Sliding Into The Menu, Hide Widgets. */
		this.clip_y=this.clipheight+10; 
		this.PaintSize(this.clip_y,this.clip_x);
	}
}

/*****************************************************************
Mouseevents (name==this (as in made object, not the event "this"))
*****************************************************************/

function ActionCancel()
{
	if (bw.ie4 || bw.ie5) window.event.cancelBubble=true;
}

function MouseOver(num,name)
{
	name[num].SetBkColor(name.mainbgcoloron);
	if (name.menueventon=="mouse") name.menumain(num,1);
	name[num].nssubover=true;
	ActionCancel();
}

function MouseExit(num,name)
{
	if (!isNaN(num))
	{
		if (name[num].subs==0 || !name.stayoncolor || !name[num].active)
		{
			name[num].SetBkColor(name.mainbgcoloroff); 
		}
		name[num].nssubover=false;
		if (bw.ns4 && name.menueventoff=="mouse") 
		{
			setTimeout("if(!"+name.name+"["+num+"].nssubover) "+name.name+".hideactive("+num+")",100);
		}
	} 
	ActionCancel();
}

function MouseOver_sub(num,subnum,name)
{
	name[num].sub[subnum].SetBkColor(name.subbgcoloron);
	name[num].nssubover=true;
	ActionCancel();
}

function MouseExit_sub(num,subnum,name)
{
	if (!isNaN(subnum))
	{
		name[num].nssubover=false;
		if (!name.stayoncolor || !name[num].sub[subnum].active || name[num].sub[subnum].subs==0)
		{
			name[num].sub[subnum].SetBkColor(name.subbgcoloroff);
		}
	}
	ActionCancel();
}

function menumain(num,mouse)
{
	if (this[num].subs!=0)
	{
		clearTimeout(this[num].subs.time_out);
		if (this[num].subs.clip_y==0 || mouse)
		{
			this.hidemain(num); 
			this[num].subs.PaintShow(this.menuspeed);/* Display */ 
			this[num].active=1;
			this[num].subs.PaintControls(0); /* Hide Widgets */
		}
		else
		{
			this.hidemain(-1); 
			this[num].active=0;
			this[num].subs.PaintControls(1); /* Show Widgets */
		}
	}
}

function hidemain(num)
{
	for (i=0;i<this.mainmenus;i++)
	{
		if (this[i].subs!=0)
		{
			if (this[i].subs.clip_y<=this[i].subs.clipheight+10)
			{
				if (i!=num)
				{
					clearTimeout(this[i].subs.time_out);
					this[i].active=0;
					this[i].SetBkColor(this.mainbgcoloroff);
					if (this.menurows)
					{
						this[i].subs.PaintHide(this.menuspeed);
						this[i].subs.PaintControls(1);
					}
					else
					{
						this[i].subs.clip_y=0; 
						this[i].subs.PaintSize(this[i].subs.clip_y,this[i].subs.clip_x);
					}
				}
			}
		}
		else
		{ 
			this[i].SetBkColor(this.mainbgcoloroff);
		}
	}
}

function hideactive(num)
{
	/* === Netscape Only Method === */
	if (this[num].subs!=0)
	{
		clearTimeout(this[num].subs.time_out);
		this[num].active=0;
		this[num].SetBkColor(this.mainbgcoloroff);
		if (this.menurows)
		{
			this[num].subs.PaintHide(this.menuspeed);
			this[num].subs.PaintControls(1);
		}
		else
		{
			this[num].subs.clip_y=0; 
			this[num].subs.PaintSize(this[num].subs.clip_y,this[num].subs.clip_x);
		}
	}
}


