
/********************************************************************************
Extranet menu 4 level version:- 

Edited 02/07/02 for Mozilla fixes NB is no longer working for NS4x
Edited 11/01/03 to change the menu setting
Edited April 03 to allow more flexibility in frontend
********************************************************************************/
// Initialise some global variables
var substrg = "";
var subsubstrg = "";
var subsub2strg = "";
var prevLink = "";
var prevNum = "";
var prevSubnum = "";
var prevSubsubnum = "";
var prevSubsub2num = "";

var num = -1;
var subnum = -1;
var subsubnum = -1;
var subsub2num = -1;


//Default browsercheck, added to all scripts!
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; this.ns4=(document.layers && !this.dom)?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera4)
	return this
}

var bw=new checkBrowser()
//Ie var
var explorerev='';

/********************************************************************************
Object constructor and object functions
********************************************************************************/
function makePageCoords(){	
	this.x=0;this.x2=(bw.ns4 || bw.ns6)?innerWidth:document.body.offsetWidth-20;
	this.y=0;this.y2=(bw.ns4 || bw.ns6)?innerHeight:document.body.offsetHeight-5;
	this.x50=this.x2/2; this.y50=this.y2/2;
	
	return this;
}
function makeMenu(parent,obj,nest,type,num,subnum,subsubnum,subsub2num){
	nest=(!nest) ? '':'document.'+nest+'.'
	this.css=bw.dom? document.getElementById(obj).style:(bw.ie4 || bw.ie5 || bw.ie6)?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;     
	this.evnt=bw.dom? document.getElementById(obj):(bw.ie4 || bw.ie5 || bw.ie6)?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;  
	this.height=bw.ns4?this.css.document.height:this.evnt.offsetHeight
	this.width=bw.ns4?this.css.document.width:this.evnt.offsetWidth
	this.moveIt=b_moveIt; this.bgChange=b_bgChange; 
	this.clipTo=b_clipTo;
	this.parent=parent;
	this.active=0;
	this.nssubover=0
	if(type==0){
	  	this.evnt.onmouseover=new Function("mmover("+num+","+this.parent.name+")");
		this.evnt.onmouseout=new Function("mmout("+num+","+this.parent.name+")");
	}else if(type==1){
	this.clipIn=b_clipIn;
	this.clipOut=b_clipOut;
	this.clipy=0
	if((bw.ns6 || bw.ns4) && this.parent.menueventoff=="mouse"){
	 	this.evnt.onmouseout=new Function("setTimeout('if(!"+this.parent.name+"["+num+"].nssubover)"+this.parent.name+".hideactive("+num+");',100)")
	 	this.evnt.onmouseover=new Function(this.parent.name+"["+num+"].nssubover=true")
  	}
 	}else if(type==2){
 	 this.evnt.onmouseover=new Function("submmover("+num+","+subnum+","+this.parent.name+")");
 	 this.evnt.onmouseout=new Function("submmout("+num+","+subnum+","+this.parent.name+")");
 	}else if(type==3){
 	 this.evnt.onmouseover=new Function("subsubmmover("+num+","+subnum+","+subsubnum+","+this.parent.name+")");
 	 this.evnt.onmouseout=new Function("subsubmmout("+num+","+subnum+","+subsubnum+","+this.parent.name+")");
 	}else if(type==4){
 	 this.evnt.onmouseover=new Function("subsub2mmover("+num+","+subnum+","+subsubnum+","+subsub2num+","+this.parent.name+")");
 	 this.evnt.onmouseout=new Function("subsub2mmout("+num+","+subnum+","+subsubnum+","+subsub2num+","+this.parent.name+")");
 	}
 	this.tim=100
 	this.obj = obj + "Object";  eval(this.obj + "=this") 
 	return this
}

function b_clipTo(t,r,b,l,h){if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r
	this.css.clip.bottom=b;this.css.clip.left=l; this.clipx=r;
	}else{this.css.clip="rect("+t+","+r+","+b+","+l+")"; this.clipx=r;;
	if(h){ if(!bw.ns4){ this.css.height=b; this.css.width=r}}}} //CHANGE DONE FOR NETSCAPE 6
	
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y;}

function b_bgChange(color){
	if(bw.dom || bw.ie4 || bw.ie5 || bw.ie6) this.css.backgroundColor=color;
	else if(bw.ns4) this.css.bgColor=color
}

function b_clipIn(speed){
	if(this.clipy>-speed){ //CHANGE DONE FOR NETSCAPE 6 ---------------------------------------------------------------------------
	 this.clipy-=speed
	 if(this.clipy<0) this.clipy=0
 	this.clipTo(0,this.clipx,this.clipy,0,1)
 	this.tim=setTimeout(this.obj+".clipIn("+speed+")",10)
	}else{this.clipy=0; this.clipTo(0,this.clipx,this.clipy,0,1)} 
}

function b_clipOut(speed){
	if(this.clipy<this.clipheight){
	 	this.clipy+=speed
	 	this.clipTo(0,this.clipx,this.clipy,0,1)
 		this.tim=setTimeout(this.obj+".clipOut("+speed+")",10)
	}else{this.clipy=this.clipheight; this.clipTo(0,this.clipx,this.clipy,0,1)}
}

//Page variable, holds the width and height of the document.
var page=new makePageCoords()

/********************************************************************************
Checking if the values are % or not.
********************************************************************************/
function checkp(num,lefttop){
	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
}

/********************************************************************************
Menu object, constructing menu ++
********************************************************************************/

function menuObj(name){
	this.makeStyle=makeStyle;
	this.makeMain=makeMain;
	this.makeSub=makeSub;
	this.makeSubSub=makeSubSub
	this.makeSubSub2=makeSubSub2
	this.mainmenus=0; 
	this.submenus=new Array()
	this.subsubmenus=new Array()
	this.subsub2menus= new Array()
	this.construct=constructMenu;
	this.checkp=checkp;
	this.name=name;
	this.menumain=menumain;
	this.hidemain=hidemain;
	this.hideactive=hideactive;
	this.menusub=menusub;
	this.menusub2=menusub2; 
	this.hidesubs=hidesubs;
}
function constructMenu(){
	bw=new checkBrowser()
	page=new makePageCoords()
	//Checking numbers for %
	this.mainwidth=checkp(this.mainwidth,0)
	this.mainheight=checkp(this.mainheight,1)
	this.subplacement=checkp(this.subplacement,1)
	this.subwidth=checkp(this.subwidth,0)
	this.subheight=checkp(this.subheight,1)
	this.subsubwidth=checkp(this.subsubwidth,0)
	this.subsubheight=checkp(this.subsubheight,1)
	this.subsubXplacement=checkp(this.subsubXplacement,1)
	this.subsubYplacement=checkp(this.subsubYplacement,1)
	this.subsub2width=checkp(this.subsub2width,0)
	this.subsub2height=checkp(this.subsub2height,1)
	this.subsub2Xplacement=checkp(this.subsub2Xplacement,1)
	this.subsub2Yplacement=checkp(this.subsub2Yplacement,1)
	/********************************************************************************
	if(this.backgroundbar){ //Backgroundbar part
		this.oBackgroundbar=new makeMenu(this,'div'+this.name+'Backgroundbar','',-1)
		this.oBackgroundbar.moveIt(this.checkp(this.backgroundbarfromleft,0
		),this.checkp(this.backgroundbarfromtop,1))
		if(this.menurows) 
			this.oBackgroundbar.clipTo(0,this.checkp(this.backgroundbarsize),this.mainheight,0,1)
		else this.oBackgroundbar.clipTo(0,this.mainwidth,this.checkp(this.backgroundbarsize),0,1)
		this.oBackgroundbar.bgChange(this.backgroundbarcolor)
	}
	********************************************************************************/
	this.x=this.checkp(this.fromleft,0); this.y=this.checkp(this.fromtop,1);
	for(i=0;i<this.mainmenus;i++){
	 	this[i]=new makeMenu(this,'div'+this.name+'Main'+i,'',0,i)
	 	this[i].clipTo(0,this.mainwidth,this.mainheight,0,1)
	 	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].bgChange(this.mainbgcoloroff)
 	if(!this.menurows) this.y+=this.mainheight+this.checkp(this.pxbetween)
 	else this.x+=this.mainwidth+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.subplacement+this[i].x,this[i].y)
 	 else this[i].subs.moveIt(this[i].x,this[i].y+this.subplacement)
  	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].clipTo(0,this.subwidth,this.subheight,0,1)
  	 this[i].sub[j].moveIt(0,this.suby)
  	 this[i].sub[j].bgChange(this.subbgcoloroff)
  	 this.suby+=this.subheight
  	if(this.submenus[i]["submenus"][j]>0){
   	 this.subsuby=0
   	 this[i].sub[j].subs=new makeMenu(this,'div'+this.name+'Sub'+i+'_'+j+'_sub','',1,i,j)
   	 this[i].sub[j].subs.moveIt(this[i].subs.x+this.subsubXplacement,this[i].subs.y+this[i].sub[j].y+this.subsubYplacement)
   	 this[i].sub[j].sub=new Array()
   	 for(a=0;a<this.submenus[i]["submenus"][j];a++){
   	  this[i].sub[j].sub[a]=new makeMenu(this,'div'+this.name+'Sub'+i+'_'+j+'_sub'+a,'div'+this.name+'Sub'+i+'_'+j+'_sub',3,i,j,a)
   	  this[i].sub[j].sub[a].clipTo(0,this.subsubwidth,this.subsubheight,0,1)
     	this[i].sub[j].sub[a].moveIt(0,this.subsuby)
     	this[i].sub[j].sub[a].bgChange(this.subsubbgcoloroff)
     	this.subsuby+=this.subsubheight
     	if(this.subsubmenus[i][j][a]>0){
     	 this.subsub2y=0;
     	 this[i].sub[j].sub[a].subs=new makeMenu(this,'div'+this.name+'Sub'+i+'_'+j+'_'+a+'_sub','',1,i,j,a)
     	 this[i].sub[j].sub[a].subs.moveIt(this[i].sub[j].subs.x+this.subsub2Xplacement,this[i].sub[j].subs.y+this[i].sub[j].sub[a].y+this.subsub2Yplacement)
     	 this[i].sub[j].sub[a].sub= new Array()
      for(b=0;b<this.subsubmenus[i][j][a];b++){
       this[i].sub[j].sub[a].sub[b]= new makeMenu(this,'div'+this.name+'Sub'+i+'_'+j+'_'+a+'_sub'+b,'div'+this.name+'Sub'+i+'_'+j+'_'+a+'_sub',4,i,j,a,b)
       this[i].sub[j].sub[a].sub[b].clipTo(0,this.subsub2width,this.subsub2height,0,1)
       this[i].sub[j].sub[a].sub[b].moveIt(0,this.subsub2y)
       this[i].sub[j].sub[a].sub[b].bgChange(this.subsub2bgcoloroff)
       this.subsub2y+=this.subsub2height;
      }
      this[i].sub[j].sub[a].subs.clipTo(0,this.subsub2width,0,0,1)
      this[i].sub[j].sub[a].subs.clipheight=this.subsub2y;
     }else this[i].sub[j].sub[a].subs=0
    }
    this[i].sub[j].subs.clipTo(0,this.subsubwidth,0,0,1)
    this[i].sub[j].subs.clipheight=this.subsuby
   }else this[i].sub[j].subs=0
  }
  this[i].subs.clipTo(0,this.subwidth,0,0,1)
  this[i].subs.clipheight=this.suby
 }else this[i].subs=0
}
setTimeout("window.onresize=resized;",500)
if(this.menueventoff=="mouse"){
 if(!bw.ns6 && !bw.ns4){explorerev+=this.name+".hidemain(-1);" //CHANGE NETSCAPE 6 -------------------------------
 document.onmouseover=new Function(explorerev)}//CHANGE NETSCAPE 6 --------------------------------------------------------------
}
}

function resized(){
 page2=new makePageCoords()
 if(page2.x2!=page.x2 || page.y2!=page2.y2) location.reload()
}

/*********************************************************************************************
Mouseevents (name==this (as in made object, not the event "this"))
*********************************************************************************************/
// SB: The hideselect and showselectboxes functions are new and are used to hide the SELECT elements 
// when the menu is hovered over them.
function hideselectboxes(name, num, subnum, subsubnum) {
   var xStart,yStart,xcoor,ycoor,miWidth,miHeight,wdth,hght;
	
   // Setup variables - they are stored in MenuGlobalConfigV3.jsp in the theme dir
   topmiWidth = mainwidth;
   miWidth = subwidth;   
   miHeight = subheight;   
   xStart = fromleft;
   yStart = fromtop;

   // Determine whether there are any sub, subsub or sub2 menus on current selection
   var hasSubs = name[num].sub ? true : false;    
   var hasSubSubs = hasSubs && subnum!="none" && name[num].sub[subnum].sub != null;   
   var hasSub2Subs = hasSubSubs && subsubnum!="none" && name[num].sub[subnum].sub[subsubnum].sub != null;
   
   // Adjust the x coordinate and width according to where we are in the menu hierarchy   
   xcoor = xStart+(num*topmiWidth); //Start of the menu plus 'num' number of buttons to right
   if (hasSubs) {wdth = miWidth}   
   if (hasSubSubs) {wdth += .70 * miWidth}   
   if (hasSub2Subs) {wdth += .70 * miWidth}   
   
   // Adjust the y coordinate and height according to where we are in the menu hierarchy   
   // If there are submenus, increase the catchment area with their total length
   ycoor = yStart + miHeight;   
   
   var hghtTemp1=0;
   var hghtTemp2=0; 
   var hghtTemp3=0;
   if (hasSubs) {hghtTemp1 = name[num].sub.length*miHeight};
   if (hasSubSubs) {hghtTemp2 = (subnum*miHeight) + name[num].sub[subnum].sub.length*miHeight};
   if (hasSub2Subs) {hghtTemp3 = (subnum*miHeight) + (subsubnum*miHeight) + name[num].sub[subnum].sub[subsubnum].sub.length*miHeight};
   hght = Math.max(hghtTemp1,hghtTemp2);
   hght = Math.max(hght,hghtTemp3);   
   
   //var iframeWin = document.getElementById('PSRefreshIF');
   var iframeWin = document.getElementById('PSIFrame');
   //var iframeWin = window.frames['PSIFrame'];   
   
   if (iframeWin) {
   		var sel = iframeWin.Document.getElementsByTagName("SELECT");      	
   } else {
   		var sel = document.getElementsByTagName("SELECT");
   }      
   
   for(i=0;i<sel.length;i++){
 	selx=0; sely=0; var selp;
 	if(sel[i].offsetParent) {
 		selp=sel[i]; 
 		while(selp.offsetParent) {
 			selp=selp.offsetParent; 
 			selx+=selp.offsetLeft;
 			sely+=selp.offsetTop;
 		}
 	}
 	selx+=sel[i].offsetLeft; 
 	sely+=sel[i].offsetTop
 	selw=sel[i].offsetWidth; 
 	selh=sel[i].offsetHeight			
	//alert("x"+selx);	
	//alert("y"+sely);
	//alert("w"+selw);
	//alert("h"+selh);
	
 	if(selx+selw>xcoor && selx<xcoor+wdth && sely+selh>ycoor && sely<ycoor+hght) {			
 		sel[i].style.visibility="hidden";
 	}
   }
}

function showselectboxes() {
    var i;
    var iframeWin = document.getElementById('PSIFrame');	
	   
	if (iframeWin) {
	   	var sel = iframeWin.Document.getElementsByTagName("SELECT");	      		
	} else {
	   	var sel = document.getElementsByTagName("SELECT");
    }
    
    for(i=0;i<sel.length;i++){
		sel[i].style.visibility="visible";
    }
}


function cancelEv(){
	if(bw.ie4 || bw.ie5 || bw.ie6) window.event.cancelBubble=true
}
function mmover(num,name){
	hideselectboxes(name, num, "none", "none");	
	if(name.menueventon=="mouse") name.menumain(num,1)
	name[num].nssubover=true
	cancelEv()
}	

function mmout(num,name){
	showselectboxes();
	if(!isNaN(num)){
 	 	if(name[num].subs==0 || !name.stayoncolor || !name[num].active)
  		name[num].bgChange(name.mainbgcoloroff); 
  		name[num].nssubover=false
  	if(name.menueventoff=="mouse") if(bw.ns4) setTimeout("if(!"+name.name+"["+num+"].nssubover) "+name.name+".hideactive("+num+")",100)
 	} 
 	cancelEv()
}

function submmover(num,subnum,name){
	hideselectboxes(name, num, subnum, "none");	
	name[num].sub[subnum].bgChange(name.subbgcoloron)
	if(name.menueventon=="mouse") {name.menusub(num,subnum,1)}
	name[num].nssubover=true
	cancelEv()
	}
function submmout(num,subnum,name){
	showselectboxes();
	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].bgChange(name.subbgcoloroff)
 	}
 	cancelEv()
}

function subsubmmover(num,subnum,subsubnum,name){
	hideselectboxes(name, num, subnum, subsubnum);	
	if(!isNaN(subnum)){
	  	name[num].sub[subnum].sub[subsubnum].bgChange(name.subsubbgcoloron); 
	        if(name.menueventon=="mouse") {name.menusub2(num,subnum,subsubnum,1)}
  		name[num].nssubover=true
 	}
	cancelEv()
}

function subsubmmout(num,subnum,subsubnum,name){
	showselectboxes();
 	if(!isNaN(subnum)){
 		name[num].nssubover=false
 		if(!name.stayoncolor || !name[num].sub[subnum].sub[subsubnum].active || name[num].sub[subnum].sub[subsubnum].subs==0) name[num].sub[subnum].sub[subsubnum].bgChange(name.subsubbgcoloroff)
 	}
 cancelEv()
}
function subsub2mmover(num,subnum,subsubnum,subsub2num,name){
	hideselectboxes(name, num, subnum, subsubnum);	
	cancelEv()
}
function subsub2mmout(num,subnum,subsubnum,subsub2num,name){
	showselectboxes();
	cancelEv()
}


/*********************************************************************************************
Showing submenus
*********************************************************************************************/
function menumain(num,mouse){
	if(this[num].subs!=0){
		clearTimeout(this[num].subs.tim)
		if(this[num].subs.clipy==0 || mouse){
			this.hidemain(num); this[num].subs.clipOut(this.menuspeed); this[num].active=1
		}else{
	 		this.hidemain(-1); this[num].active=0
		}
	}else{
  		this.hidemain(-1);
  	this[num].bgChange(this.mainbgcoloron,this.mainHilite)
 	}
}

/*********************************************************************************************
Showing subsubmenus
*********************************************************************************************/
function menusub(num,sub,mouse){
 this.hidesubs(num,sub,100,100)
 if(this[num].sub[sub].subs!=0){
  if(this[num].sub[sub].subs.clipy==0 || mouse){
   this[num].sub[sub].active=1
   this[num].sub[sub].subs.clipOut(this.menusubspeed)
  }else{
   this[num].sub[sub].active=0
   this[num].sub[sub].subs.clipIn(this.menusubspeed)
  }
 }
}
function menusub2(num,sub,sub2,mouse){
 this.hidesubs(num,sub,sub2,100);
 if(this[num].sub[sub].sub[sub2].subs!=0){
  if(this[num].sub[sub].sub[sub2].subs.clipy==0 || mouse){
   this[num].sub[sub].sub[sub2].active=1
   this[num].sub[sub].sub[sub2].subs.clipOut(this.menusubspeed)
  }else{
   this[num].sub[sub].sub[sub2].active=0
   this[num].sub[sub].sub[sub2].subs.clipIn(this.menusubspeed)
  }
 }
}

/*********************************************************************************************
Hides the other sub menuitems if any are shown. Also calls the hidesubs to hide any showing
submenus.
*********************************************************************************************/
function hidemain(num){
 for(i=0;i<this.mainmenus;i++){
  if(this[i].subs!=0){
   if(this[i].subs.clipy<=this[i].subs.clipheight){
    this.hidesubs(i,100,100,100)
    if(i!=num){
     clearTimeout(this[i].subs.tim)
     this[i].active=0
     this[i].bgChange(this.mainbgcoloroff)
     if(this.menurows)this[i].subs.clipIn(this.menuspeed)
     else{this[i].subs.clipy=0; this[i].subs.clipTo(0,this[i].subs.clipx,this[i].subs.clipy,0,1)}
    }
   }
  }else this[i].bgChange(this.mainbgcoloroff)
 }
}
/*********************************************************************************************
Hides the active submenuitems
*********************************************************************************************/
function hideactive(num){
 if(this[num].subs!=0){
  this.hidesubs(num,100,100,100)
  clearTimeout(this[num].subs.tim)
  this[num].active=0
  this[num].bgChange(this.mainbgcoloroff)
  if(this.menurows)this[num].subs.clipIn(this.menuspeed)
  else{this[num].subs.clipy=0; this[num].subs.clipTo(0,this[num].subs.clipx,this[num].subs.clipy,0,1)}
 }
}
/*********************************************************************************************
Hides the other subsub menuitems if any are shown.
*********************************************************************************************/
function hidesubs(num,sub,sub2){
 for(j=0;j<this[num].sub.length;j++){

  if(this[num].sub[j].subs!=0){
   if(j!=sub){
    if(this[num].sub[j].subs.clipy<=this[num].sub[j].subs.clipy || this[num].subs.clipy<this[num].subs.clipheight){
     clearTimeout(this[num].sub[j].subs.tim)
     this[num].sub[j].active=0
     this[num].sub[j].bgChange(this.subbgcoloroff)
     this[num].sub[j].subs.clipy=0
     this[num].sub[j].subs.clipTo(0,this[num].sub[j].subs.clipx,this[num].sub[j].subs.clipy,0,1)
    }
   }
   for(k=0;k<this[num].sub[j].sub.length;k++){
    if(this[num].sub[j].sub[k].subs!=0){
     if(k!=sub2){
      clearTimeout(this[num].sub[j].sub[k].subs.tim);
      this[num].sub[j].sub[k].active=0
      this[num].sub[j].sub[k].bgChange(this.subsubbgcoloroff)
      this[num].sub[j].sub[k].subs.clipy=0
      this[num].sub[j].sub[k].subs.clipTo(0,this[num].sub[j].sub[k].subs.clipx,this[num].sub[j].sub[k].subs.clipy,0,1)
     }
    }
   }
  }
 }
}
/*********************************************************************************************
These are the functions that writes the style and menus to the page. 
*********************************************************************************************/
function makeStyle(){
	str='\n<style type="text/css">\n'
	str+='\tDIV.siteMap{background-image:url('+this.menuGif+'); background-repeat:no-repeat; width:'+(this.mainwidth-10)+'; '+this.clMain+'}\n'
	str+='\tDIV.cl'+this.name+'Main{position:absolute; z-index:51; clip:rect(0,0,0,0); cursor: hand; overflow:hidden; background-image:url('+this.menuGif+'); background-repeat:no-repeat; width:'+(this.mainwidth-10)+'; '+this.clMain+'}\n'
	str+='\tDIV.cl'+this.name+'Sub{position:absolute; z-index:52; clip:rect(0,0,0,0); cursor: hand; overflow:hidden; border-top: solid black 1px ; border-right: outset black 1px ; width:'+(this.subwidth-10)+'; '+this.clSub+'}\n'
	str+='\tDIV.cl'+this.name+'SubSub{position:absolute; z-index:54; clip:rect(0,0,0,0); cursor: hand; border-top: solid black 1px ;border-right: outset black 1px ; width:'+(this.subsubwidth-10)+'; '+this.clSubSub+'}\n'
	str+='\tDIV.cl'+this.name+'SubSub2{position:absolute; z-index:54; clip:rect(0,0,0,0); cursor: hand; border-top: solid black 1px ;border-right: outset black 1px ; width:'+(this.subsub2width-10)+'; '+this.clSubSub2+'}\n'
	str+='\tDIV.cl'+this.name+'Subs{position:absolute; z-index:53; clip:rect(0,0,0,0); cursor: hand; overflow:hidden}\n'
	str+='\t#div'+this.name+'Backgroundbar{position:absolute; z-index:50; clip:rect(0,0,0,0); overflow:hidden}\n'
	str+='\tTD.siteMap{'+this.clMain+'}\n'
	str+='\tTD.clA'+this.name+'Main{'+this.clMain+'}\n'
	str+='\tTD.clA'+this.name+'Main:link{'+this.clMain+'}\n'
	str+='\tTD.clA'+this.name+'Main:visited{'+this.clMain+'}\n'
	str+='\tTD.clA'+this.name+'Main:active{'+this.clMain+'}\n'
	str+='\tTD.clA'+this.name+'Main:hover{'+this.clMain+'}\n'
	str+='\tA.clA'+this.name+'Main{'+this.clAMain+'}\n'
	str+='\tA.clA'+this.name+'Main:link{'+this.clAMain+'}\n'
	str+='\tA.clA'+this.name+'Main:visited{'+this.clAMain+'}\n'
	str+='\tA.clA'+this.name+'Main:active{'+this.clAMain+'}\n'
	str+='\tA.clA'+this.name+'Main:hover{'+this.clAMain+'}\n'
	str+='\tA.clA'+this.name+'Sub{'+this.clASub+'}\n'
	str+='\tA.clA'+this.name+'Sub:link{'+this.clASub+'}\n'
	str+='\tA.clA'+this.name+'Sub:visited{'+this.clASub+'}\n'
	str+='\tA.clA'+this.name+'Sub:active{'+this.clASub+'}\n'
	str+='\tA.clA'+this.name+'Sub:hover{'+this.clASub+'}\n'
	str+='\tA.clA'+this.name+'SubSub{'+this.clASubSub+'}\n'
	str+='\tA.clA'+this.name+'SubSub:link{'+this.clASubSub+'}\n'
	str+='\tA.clA'+this.name+'SubSub:active{'+this.clASubSub+'}\n'
	str+='\tA.clA'+this.name+'SubSub:visited{'+this.clASubSub+'}\n'
	str+='\tA.clA'+this.name+'SubSub:hover{'+this.clASubSub+'}\n'
	str+='\tA.clA'+this.name+'SubSub2{'+this.clASubSub2+'}\n'
	str+='\tA.clA'+this.name+'SubSub2:link{'+this.clASubSub2+'}\n'
	str+='\tA.clA'+this.name+'SubSub2:active{'+this.clASubSub2+'}\n'
	str+='\tA.clA'+this.name+'SubSub2:visited{'+this.clASubSub2+'}\n'
	str+='\tA.clA'+this.name+'SubSub2:hover{'+this.clASubSub2+'}\n'
	str+='</style>\n\n'
	document.write(str)
}

function setPrevLink(prvLink,prvNum,prvSubnum,prvSubsubnum,prvSubsub2num) {
	prevLink = 	 prvLink;
	prevNum = 	 prvNum;
  	prevSubnum = 	 prvSubnum;
   	prevSubsubnum =  prvSubsubnum;
  	prevSubsub2num = prvSubsub2num;
}

function makeMain(text,link,target){
	num++;
	
 	if(num>0) {checkPrevLink(this,"main")};
  	  	 	
 	//print the subs of the previous menus
 	if((num>0) && substrg!="") {document.write(substrg);};
  	if((num>0) && subsubstrg!="") {document.write(subsubstrg);};
 	if((num>0) && subsub2strg!="") {document.write(subsub2strg);};
 	substrg="";
  	subsubstrg="";
 	subsub2strg="";

	if (text=='##end##') {
 		 // Do nothing
	} else {
   	  	str=""
    		var HTMLLink='';
   		if(target!='New Window') {
   		 HTMLLink='window.location=\''+link+'\''
    	  	}else{
   		 HTMLLink='window.open(\''+link+'\', \'NewWindow\', \'width=800, height=600, scrollbars=1, resizable=1, toolbar=1, menubar=1\')'
   	  	}
    		
   		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+=' onclick="'+HTMLLink+';"';
    		//Bits remmed out are actually not necessary. 
    		//Removing the lines prevent code crashing if a menu item with children hasn't got a 0 in the link
     		//this.submenus[num]='nosub';
    	  	}
		
   	  	//Initialise stuff here now
    		//if(link==0)
   		//{
      		this.submenus[num]=new Array();
       	  	this.subsubmenus[num] = new Array();
      		this.subsub2menus[num] = new Array();
      	  	this.submenus[num]["submenus"]=new Array()
       		//}
		
      		str+='>'
       	  	str+='<table width="100%" height="100%"><tr>'
      		str+='<td valign="middle" align="center" class="clA'+this.name+'Main">'+this.offSet
   	  	str+=text+'</td></tr></table></div>\n'
   		this.mainmenus++;  
   		document.write(str);
   		   		   		
   	  	setPrevLink("main",num,"","","");   	  	
	}
}

function makeSub(text,link,target){
	if(prevLink=="main") {
		subnum=0
	} else {
		subnum++;			
	}
	
  	checkPrevLink(this,"sub");
   	
  	var HTMLLink='';
  	if(target!='New Window') {
   		HTMLLink='window.location=\''+link+'\''
  	}else{
  		HTMLLink='window.open(\''+link+'\', \'NewWindow\', \'width=800, height=600, scrollbars=1, resizable=1, toolbar=1, menubar=1\')'
   	}
  	  	  	
  	if(prevLink=="main") substrg='<div id="div'+this.name+'Sub'+num+'" class="cl'+this.name+'Subs">\n'
	substrg+='\t<div id="div'+this.name+'Sub'+num+'_'+subnum+'" class="cl'+this.name+'Sub"'
  	
 	if(link)
    	{substrg+=' onclick="'+HTMLLink+'"'}
     	substrg+='>';
    	
    	if(link) substrg+='<img src="'+this.dashGif+'" border=0>&nbsp;'+text+'</div>\n'; else substrg+='<img src="'+this.arrowGif+'" border=0>&nbsp;'+text+'</div>\n'
    	
	setPrevLink("sub",num,subnum,"","");
}

function makeSubSub(text,link,target){

	checkPrevLink(this,"subsub");

	if(prevLink=="sub") {
		subsubnum=0
	} else {
		subsubnum++;			
	}
	   	
	var HTMLLink='';
 	if(target!='New Window') {
   	 HTMLLink='window.location=\''+link+'\''
 	}else{
   	 HTMLLink='window.open(\''+link+'\', \'NewWindow\', \'width=800, height=600, scrollbars=1, resizable=1, toolbar=1, menubar=1\')'
 	}
	 	
	if(prevLink=='sub') subsubstrg+='<div id="div'+this.name+'Sub'+num+'_'+subnum+'_sub" class="cl'+this.name+'Subs">\n'
	subsubstrg+='\t<div id="div'+this.name+'Sub'+num+'_'+subnum+'_sub'+subsubnum+'" class="cl'+this.name+'SubSub"'
	
	
   	if(link)
 	{subsubstrg+=' onclick="'+HTMLLink+'"'}
 	subsubstrg+='>'
	
   	if(link) subsubstrg+='<img src="'+this.dashGif+'" border=0>&nbsp;'+text+'</div>\n'; else subsubstrg+='<img src="'+this.arrowGif+'" border=0>&nbsp;'+text+'</div>\n'
	
   	if(prevLink=="sub") {
 	 this.subsubmenus[num][subnum]= new Array();
 	 this.subsub2menus[num][subnum]=new Array();      
 	}
   	 	
	setPrevLink("subsub",num,subnum,subsubnum,"");
}

function makeSubSub2(text,link,target){
	if(prevLink=="subsub") {
		subsub2num=0
	} else {
		subsub2num++;			
	}
	
	this.subsubmenus[num][subnum][subsubnum]=subsub2num+1;
	
  	var HTMLLink='';
	if(target!='New Window') {
	 HTMLLink='window.location=\''+link+'\''
	}else{
  	 HTMLLink='window.open(\''+link+'\', \'NewWindow\', \'width=800, height=600, scrollbars=1, resizable=1, toolbar=1, menubar=1\')'
	}
	
	if(prevLink=="subsub") subsub2strg+='<div id="div'+this.name+'Sub'+num+'_'+subnum+'_'+subsubnum+'_sub" class="cl'+this.name+'Subs">\n'
	subsub2strg+='\t<div id="div'+this.name+'Sub'+num+'_'+subnum+'_'+subsubnum+'_sub'+subsub2num+'" class="cl'+this.name+'SubSub2"'
	
 	subsub2strg+=' onclick="'+HTMLLink+'"'
   	subsub2strg+='>'
 	
   	if(link) subsub2strg+='<img src="'+this.dashGif+'" border=0>&nbsp;'+text+'</div>\n'; else subsub2strg+='<img src="'+this.arrowGif+'" border=0>&nbsp;'+text+'</div>\n'
 	
 	if(prevLink=="subsub"){
   	 this.subsub2menus[num][subnum][subsubnum]= new Array()
 	}   
   	
	setPrevLink("subsub2",num,subnum,subsubnum,subsub2num);   

 }

function checkPrevLink(menuobject,curLink) {
	if      (curLink=="main")   {cur=3;}
  	else if (curLink=="sub")    {cur=2;}
	else if (curLink=="subsub") {cur=1;}
	else if (curLink=="subsub2") {cur=0;}
  	else   			    {cur=0;} //error
    	
  	if      (prevLink=="main")   {prev=3;}
  	else if (prevLink=="sub")    {prev=2;}
    	else if (prevLink=="subsub") {prev=1;}
  	else if (prevLink=="subsub2"){prev=0;}
  	else			     {prev=4;} //error
    	
    	// Prevent menu crashing if there is a main link being 0 without children
    	if(curLink=="main" && prevLink=="main") {
    		menuobject.submenus[prevNum]='nosub';
    	}
    	
    	var diffLevel = cur - prev;	
    	
  	if (prev<cur) {
		if (prevLink=='sub'){
   			substrg+='</div>\n'; 
     			menuobject.submenus[prevNum]["main"]=prevSubnum+1;
   		}
   	  	else if (prevLink=='subsub'){
			subsubstrg+='</div>\n'; 
    			menuobject.submenus[prevNum]["submenus"][prevSubnum]=prevSubsubnum+1;
   		}  
   	  	else if (prevLink=='subsub2'){
   	  		subsub2strg+='</div>\n';
     		} 


		if (diffLevel>=2) {
			if (prevLink=="subsub2"){prevLink="subsub";}
			else if (prevLink=="subsub"){prevLink="sub";}
			else{prevLink="stop";} 
			   		
			if (prevLink!="stop") {
				checkPrevLink(menuobject,curLink)
			}

		}
  	}
}

/*********************************************************************************************
END Menu script
*********************************************************************************************/
