var stayFoldedLocal = true;
var foldselectedLocal = -1;

//FoldNumberLocal = 2;
foldImgLocal = 0;
mainOffsetYLocal = 1;

//This are the default images
var unImg=new Image();
unImg.src="/global/img/foldout/1x1.gif";
var exImg=new Image();
exImg.src="/global/img/foldout/1x1.gif";								

//Opera 5 resize fix
if(bw.op5){
	scrX= innerWidth; scrY= innerHeight;
	document.onmousemove= function(){
		if(scrX<innerWidth-10 || scrY<innerHeight-10 || scrX>innerWidth+10 || scrY>innerHeight+10){
			scrX = innerWidth;
			scrY = innerHeight;
			initFoldoutLocal();
		}
	};
}

//Object constructor Local
function makeLocal(obj,nest){
	nest= (!nest)?"":'document.'+nest+'.';
	
	this.el= bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getElementById(obj);	
  this.css= bw.ns4?this.el:this.el.style;
	this.ref= bw.ns4?this.el.document:document;		
	
	this.x= (bw.ns4||bw.op5)?this.css.left:this.el.offsetLeft;
	this.y= (bw.ns4||bw.op5)?this.css.top:this.el.offsetTop;
	this.h= (bw.ie||bw.op6||bw.op7||bw.ns6)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op5?this.css.pixelHeight:0;
	
	this.vis= b_vis;
	this.hideIt= b_hideIt;
	this.showIt= b_showIt;
	this.moveIt= b_moveIt;
	
	return this
}

//Object methods
function b_showIt(){this.css.visibility='visible'}
function b_hideIt(){this.css.visibility='hidden'}
function b_vis(){if(this.css.visibility=='hidden' || this.css.visibility=='HIDDEN' || this.css.visibility=='hide') return true;}

//Object methods for Local			
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x+bw.px; this.css.top=this.y+bw.px}			
function b_selectIt(num){if(foldselectedLocal==num){foldselectedLocal=-1;}else{foldselectedLocal=num;} menuLocal(num);}
function b_refreshIt(){menuLocal(foldselectedLocal);}

//Object methods for MastHead

//This is the function that changes the sub menus to folded or unfolded state.
function menuLocal(num){
	if(bw.bw){
		if (!stayFoldedLocal){
			for (var i=0; i<oSub.length; i++){
				if (i!=num && i!=foldselectedLocal){
					oSub[i].hideIt();
					if (foldImgLocal){oTop[i].ref["imgA"+i].src = unImg.src}
				}
			}
			for(var i=1; i<oTop.length; i++){
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h);
			}
		}

		if (foldselectedLocal!=num) {
			if (oSub[num].vis()){
				oSub[num].showIt();
				if (foldImgLocal){oTop[num].ref["imgA"+num].src = exImg.src}
			}else{
				oSub[num].hideIt();
				if(foldImgLocal){oTop[num].ref["imgA"+num].src = unImg.src}
			}
		}
		
		for(var i=1; i<oTop.length; i++){ 
			if (!oSub[i-1].vis()) {oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h+oSub[i-1].h+mainOffsetYLocal)}
			else {oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h+mainOffsetYLocal)}
		}
	}
}

//The init function for Local
function initFoldoutLocal(){
	oTop = new Array()
	oSub = new Array()
	
	//Making the objects and hiding the subs...
	for (var i=0; i<FoldNumberLocal; i++){
		oTop[i] = new makeLocal('divTop'+i,'divContLocal')
		oSub[i] = new makeLocal('divSub'+i,'divContLocal.document.divTop'+i)
		oSub[i].hideIt()
	}
	
	//Positioning the top objects...
	oTop[0].moveIt(0,0)
	for (var i=1; i<oTop.length; i++){
		oTop[i].moveIt(0, oTop[i-1].y+oTop[i-1].h+mainOffsetYLocal);
	}
	
	//Making the containing menu object and showing it...
	oCont = new makeLocal('divContLocal');
	oCont.showIt();
}

//General init function
function Init_Navi() {
	//alert('XYZ');
	initFoldoutLocal();
}
