
//Arrays for each submenu
var JButton_oBg = new Array();
var JButton_oMenu = new Array();

/********************************************************************************
********************************************************************************/
//Default browsercheck, added to all scripts!
function JButton_checkBrowser(){
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?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;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	return this;
}
JButton_bw=new JButton_checkBrowser();
/**************************************************************************
Variables to set.
***************************************************************************/
//Updated: Added left and top variables.
//sLeft=0; //The left placement of the menu
//sTop=0; //The top placement of the menu

//The height of the menu
JButton_sMenuheight=30;

//Scroll speed: (in milliseconds, change this one and the next variable to change the speed)
JButton_sScrollspeed=20;

//Pixels to scroll per timeout.
JButton_sScrollPx=2;

/**************************************************************************
Scrolling functions
***************************************************************************/
var JButton_tim=0;
var JButton_noScroll=true;
function JButton_moveTop(index)
{
	if(!JButton_noScroll && parseInt(JButton_oMenu[index].y)<0)
	{
		JButton_oMenu[index].moveBy(0,JButton_sScrollPx);
		JButton_tim=setTimeout("JButton_moveTop('"+index+"')",JButton_sScrollspeed);
	}
}
function JButton_moveBottom(index)
{
	if(!JButton_noScroll && parseInt(JButton_oMenu[index].y)>-(JButton_oMenu[index].scrollheight-(JButton_oMenu[index].pageHeight)))
	{
		JButton_oMenu[index].moveBy(0,-JButton_sScrollPx);
		JButton_tim=setTimeout("JButton_moveBottom('"+index+"')",JButton_sScrollspeed);
	}
}
function JButton_noMove(){clearTimeout(JButton_tim); JButton_noScroll=true;}
/**************************************************************************
Object part
***************************************************************************/
function JButton_makeObj(obj,nest,menu)
{
	nest=(!nest) ? '':'document.'+nest+'.';
   	this.css=JButton_bw.dom? document.getElementById(obj).style:JButton_bw.ie4?document.all[obj].style:JButton_bw.ns4?eval(nest+"document.layers." +obj):0;
	this.evnt=JButton_bw.dom? document.getElementById(obj):JButton_bw.ie4?document.all[obj]:JButton_bw.ns4?eval(nest+"document.layers." +obj):0;

	this.scrollheight=JButton_bw.ns4?this.css.document.height:this.evnt.offsetHeight;
	this.x=(JButton_bw.ns4 || JButton_bw.ns5)? this.css.left:this.css.pixelLeft;
	this.y=(JButton_bw.ns4 || JButton_bw.ns5)? this.css.top:this.css.pixelTop;
	this.moveBy=JButton_moveBy; this.moveIt=JButton_moveIt;
	this.showIt=JButton_showIt; this.clipTo=JButton_clipTo;
	this.pageHeight = pageHeight;
	return this;
}
function JButton_moveBy(x,y)
{
	this.x=parseInt(this.x)+x; this.y=parseInt(this.y)+y;
	this.css.left=parseInt(this.x);	this.css.top=parseInt(this.y);
}
function JButton_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y;}
function JButton_clipTo(t,r,b,l)
{
	if(JButton_bw.ns4){this.css.clip.top=t; this.css.clip.right=r; this.css.clip.bottom=b; this.css.clip.left=l;
	}else this.css.clip="rect("+t+","+r+","+b+","+l+")";
}
function JButton_showIt(){this.css.visibility="visible";}
/**************************************************************************
Object part end
***************************************************************************/

/**************************************************************************
Init function. Set the placements of the objects here.
***************************************************************************/

function JButton_scrollInit( index, pHeight )
{
	//Height of the menu
	pageHeight=pHeight;
JButton_sMenuheight=pHeight;
	
	var bMenuExists=JButton_bw.dom? document.getElementById("JButton_divContentScroll_" + index):JButton_bw.ie4?document.all["JButton_divContentScroll_" + index]:JButton_bw.ns4?eval(nest+"document.layers.JButton_divContentScroll_" + index):0;
	
	if (bMenuExists) {
		JButton_oBg[index]=new JButton_makeObj('JButton_divContentScroll_' + index);
		JButton_oMenu[index]=new JButton_makeObj('JButton_divScroll_' + index,'JButton_divContentScroll_' + index,1);
		//Placement
		if(JButton_bw.dom || JButton_bw.ie4){JButton_oBg[index].css.overflow="hidden";}
		JButton_oBg[index].clipTo(0,JButton_sMenuheight,pageHeight,0);
	}
	
}


