// dynamic browser checking (using objects)
	function BrowserCheck() {
		var browser = navigator.appName
		// browsers defined are netscape and ie only
		if (browser=="Netscape") this.browser = "ns"
		else if (browser=="Microsoft Internet Explorer") this.browser = "ie"
		else this.browser = browser
		if (navigator.appVersion.indexOf("Mac") != -1) this.platform = "mac";  
	    else  this.platform = "pc"; 	
		this.mac = (this.platform=="mac")
		this.pc = (this.platform=="pc")
		// version tell the exact version
		this.vers = parseInt(navigator.appVersion)
		// ns/4/5 ie/4/5 are 4 plus browsers
		this.ns = (this.browser=="ns" && this.vers>=4)
		this.ns4 = (this.browser=="ns" && this.vers==4)
		this.ns5 = (this.browser=="ns" && this.vers==5)
		this.ie = (this.browser=="ie" && this.vers>=4)
		this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
		this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
		if (this.ie5) this.vers = 5
	}
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	
	// automatically create the "is" object
	var winW = 0;
	var winH = 0;
	is = new BrowserCheck()
	// globals - used by page event handler
	mousex =0;
	mousey = 0;
	global_menu_active = 0; 
	global_menu_check = 0; 
	
		if (is.pc){
			if (is.ns && is.vers < 5){
				document.write("<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" 	HREF=\"../styles/doro_ns4.css\">")
				}
			else {
				document.write("<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" 	HREF=\"../styles/doro_ie4.css\">")
				}
		}
		
		
		if (is.mac){
			if (is.ns){
				document.write("<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" 	HREF=\"../styles/doro_ns4_mac.css\">")
				}
			else {
				document.write("<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" 	HREF=\"../styles/doro_ie4_mac.css\">")
				}
		}
	
	// finds netscape only position of layer in internal layer array
	function findlayer_ns(id){
		if (is.ns){
	        ind = null;
	        for (i=0; i<document.layers.length; i++) {
	                whichEl = document.layers[i];
	                if (whichEl.id.indexOf(id) >= 0 ) {
	                        ind = i;
	                        break;
	                }
	        }
	        return ind;	
		}
		else return null;
	}
	
	function page_event_handle(){
			if (is.ns && is.vers < 5) {
				document.captureEvents( Event.MOUSEMOVE );
		        document.onmousemove = PagemoveHandler;		  
			}
			if (is.ie) {
	        	document.onmousemove = PagemoveHandler;
			}
			if (is.ns5 && is.vers > 4 ) {
				document.onmousemove = PagemoveHandler;
			}
	}
	
	function makeevent_layer(id, menuid){
			if (is.ns && is.vers < 5) {
				idno = findlayer_ns(id);
				document.layers[idno].captureEvents(Event.MOUSEOUT | Event.MOUSEOVER)
		        document.layers[idno].onmouseout =  new Function ("LayeroutHandler('" + menuid + "')");
		        document.layers[idno].onmouseover =  new Function ("LayeroverHandler('" + menuid + "')");
			}
			if (is.ie) {
	        	document.all[id].onmouseout = new Function ("LayeroutHandler('"  + menuid + "')");
	        	document.all[id].onmouseover = new Function ("LayeroverHandler('" + menuid + "')");
			}
			if (is.ns && is.vers > 4) {
				document.getElementById(id).onmouseout = new Function ("LayeroutHandler('"  + menuid + "')");
	        	document.getElementById(id).onmouseover = new Function ("LayeroverHandler('" + menuid + "')");
			}
	}
	
	function LayeroutHandler(id){	
		global_menu_check = id; 
	}
	
	function  PagemoveHandler(e){
	         mousex = (is.ns)? e.pageX : event.x+document.body.scrollLeft
	         mousey = (is.ns)? e.pageY : event.y+document.body.scrollTop		 
	
			 if ( global_menu_check > 0 && global_menu_check <= menu.length){
			 			if  ( mousex < Menuxpos ) {
								 menuhide(null);
								 global_menu_check = 0;
						}					
						else if ( mousey < Dropdownypos && mousex > totalxwidth ) {
								menuhide(null);
								global_menu_check = 0;
						}
			 			else if  ( mousey > menu[global_menu_check][7] ) {
								menuhide(null);
								global_menu_check = 0;
						}
						else if ( mousey > Dropdownypos && mousex < menu[global_menu_check][8] ){
							menuhide(null);
							global_menu_check = 0;				
						}
						else if ( mousey > Dropdownypos && mousex > menu[global_menu_check][8] + 200 ){
							menuhide(null);
							global_menu_check = 0;				
						}
	
			 } 
	}
	
	function LayeroverHandler(id){
		menuhide(menu[id][0]);	
	}
		
	function moveTo(id,x,y) {
		id.xpos = x
		id.left = id.xpos
		id.ypos = y
		id.top = id.ypos
	}
	
	function alter_bg(id,color) {
		if (is.ns && is.vers < 5) document.layers[id].bgColor = color;
	    else if (is.ie) document.all[id].style.backgroundColor = color;
		else if (is.ns && is.vers > 4) document.getElementById(id).style.backgroundColor = color;
	}
	
	function show(id) {
	        if (is.ns && is.vers < 5 ) document.layers[id].visibility = "show";
			else if (is.ns && is.vers > 4) document.getElementById(id).style.visibility = "visible";
	        else if (is.ie) document.all[id].style.visibility = "visible";
	}
	
	function hide(id) {
	        if (is.ns && is.vers < 5) document.layers[id].visibility = "hide"
			else if (is.ns && is.vers > 4) document.getElementById(id).style.visibility = "hidden"
	        else if (is.ie) document.all[id].style.visibility = "hidden"
	}
	
	function clipTo(obj,t,r,b,l) {
	        if (is.ns) {
	                obj.clip.top = t
	                obj.clip.right = r
	                obj.clip.bottom = b
	                obj.clip.left = l
	        }
	        else if (is.ie) obj.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
	}
	
	// hide drop downs of other menus, alter other menus background colour to off and 
	// alter background of selected menu to on
	function menuhide(id){
		if ( global_menu_check > 0 && menu[global_menu_check][0] ){	   
			// based on the fact that all menu items are called MenuItemX
			//and the image in the menu items are imageX
			 var layerid = menu[global_menu_check][0];
			 var imagename = "image" + layerid.substring(8,9);
			 if (is.ie || (is.ns && is.vers > 4 )) var imgtemp = eval('document.' + imagename + '.src');
			 else {		     
				 var imgtemp = eval('document.' + layerid + '.document.' + imagename + '.src');
			 }
			 if ( imgtemp.length > 1 && imgtemp.indexOf('_on') > 0 ) {
				 imgtemp =  imgtemp.substring(imgtemp.indexOf('../images/'),imgtemp.indexOf('_on')) + '_off.gif';			 				 
				 imageSwap(imagename, imgtemp);			 
			 }
		}
		if ( id != null ){
			var imagename = "image" + id.substring(8,9);	
			if (is.ie || (is.ns && is.vers > 4 )) var imgtemp = eval('document.' + imagename + '.src');
			else var imgtemp = eval('document.' + id + '.document.' + imagename + '.src');
			if ( imgtemp.length > 1 && imgtemp.indexOf('_off') > 0 ) {		 
				imgtemp =  imgtemp.substring(imgtemp.indexOf('../images/'),imgtemp.indexOf('_off')) + '_on.gif';			 				 
				imageSwap(imagename, imgtemp);			 
			}
		}
		
		for (i=1; i< menu.length; i++ )	{
			// if menu is not to be left on turn background to OFF 
		    if (menu[i][6] == 0) alter_bg(menu[i][0],menu[i][4])
			// if not active menu turn OFF 
			if ( id != menu[i][0] ){	
				// if this menu has some drop downs hide them!
				if ( menu[i][5] > 0 ){
					for (n=1; n<=menu[i][5]; n++)	{
						hide(menu[i][0] + 'Option' + n )		  					
					}
				}
			}
			else{
			 //Turn ON
		     alter_bg(menu[i][0],menu[i][1])
			 // if this menu has some drop downs show them!
				if ( menu[i][5] > 0 ){
					for (n=1; n<=menu[i][5]; n++)	{
						show(menu[i][0] + 'Option' + n )		  
					}
				}		
			}
		}
	}

	//Global Variables - Menu Colours
	// web colours
	white = "#FFFFFF"
	black = "#000000"
	menu = new Array();
	// menu layers
	menu[1] = new Array();
	menu[1][0] = 'MenuItem1'; // name of the menu
	menu[1][1] = black; // on colour
	//menu[1][2] = "#EAE3CB"; // on colour (drop down) #F5F1E3
	//menu[1][3] = "#EAE3CB"; // off colour
	menu[1][2] = "#F2EDDC"; // on colour (drop down) 
	menu[1][3] = "#F2EDDC"; // off colour
	menu[1][4] = black; // off colour (for top menu)
	menu[1][5] = m1Items;
	menu[1][6] = 0 // 0 if not current page
	menu[1][7] = 0 // height of layers in drop down
	menu[1][8] = 0 // x position of dropdown layer

	menu[2] = new Array();
	menu[2][0] = 'MenuItem2';
	menu[2][1] = black; // On colour
	menu[2][2] = "#F2EDDC"; // on colour (drop down)
	menu[2][3] = "#F2EDDC"; // Off colour
	menu[2][4] = black; // Off colour (for top menu)
	menu[2][5] = m2Items;
	menu[2][6] = 0 // 0 if not current page
	menu[2][7] = 0 // height of layers in drop down
	menu[2][8] = 0 // x position of dropdown layer

	menu[3] = new Array();
	menu[3][0] = 'MenuItem3';
	menu[3][1] = black; // On colour
	menu[3][2] = "#F2EDDC"; // On colour (dropdown)
	menu[3][3] = "#F2EDDC"; // Off colour
	menu[3][4] = black; // Off colour (for top menu)
	menu[3][5] = m3Items;
	menu[3][6] = 0 // 0 if not current page
	menu[3][7] = 0 // height of layers in drop down
	menu[3][8] = 0 // x position of dropdown layer

	function init(){ 
		// 	Variable presets for positioning
		winW = (is.ns)? window.innerWidth : document.body.offsetWidth-20
		winH = (is.ns)? window.innerHeight : document.body.offsetHeight-4
	    var dropdownspacer = 0;
		Menuxpos = 60;
		Menuypos = 8;
		Dropdownxpos = 300;
		Dropdownypos = 35;	
		totalxwidth = 0;
		// initialise the layers
		page_event_handle();
	    if (is.ns && is.vers <5) {	  	  
		  // loop through top menus and position them
		  var incrementalxpos = Menuxpos;
		  for (var i=1; i<menu.length; i++){	  		  		
		  	  menu_name = eval ('document.' + menu[i][0] );		  
	   	  	  if (i > 1) incrementalxpos += eval ('document.' + menu[i-1][0] + '.document.width' );
			  moveTo(menu_name, incrementalxpos, Menuypos);
			  show(menu[i][0]);		
			  makeevent_layer(menu[i][0], i);
			  if ( menu[i][5] > 0) {			  	  
			  		  //loop through drop down options for each menu and position them
					  for (var n=1; n<=menu[i][5]; n++){	  				  	
						  option_name = eval ('document.' + menu[i][0] + 'Option' + n);				  							 
						  if ( n > 1 ){
							  prevn = n - 1;
							  previous_name = eval ('document.' + menu[i][0] + 'Option' +  prevn);				
						  	  incrementalypos += previous_name.document.height + dropdownspacer;				
						  }
	 					  else incrementalypos = Dropdownypos;	  
						  moveTo(option_name, incrementalxpos , incrementalypos);					  					  
	  					  option_id = menu[i][0] + 'Option' + n;				  		
	   					  alter_bg(option_id, menu[i][3]);					  
						  //only needed for NS. IE uses the styles width
						  clipTo(option_name,0,200,option_name.document.height+dropdownspacer,0);
					  }      		  	
					  incrementalypos += option_name.document.height;				
					  menu[i][7] = incrementalypos;
					  menu[i][8] = incrementalxpos;				  
			  }
		  }      	  	  
		  incrementalxpos += eval ('document.' + menu[i-1][0] + '.document.width' ) ;  	
		  totalxwidth = incrementalxpos;
	    }
			
		if (is.ns && is.vers >  4) {
		  // loop through top menus and position them
		  var incrementalxpos = Menuxpos;
		  var incrementalypos =0;
		  for (var i=1; i<menu.length; i++) {
	   	  	if (i > 1) incrementalxpos += parseInt(document.getElementById(menu[i-1][0]).style.width);
			moveTo(document.getElementById(menu[i][0]).style, incrementalxpos, Menuypos);
			show(menu[i][0]);
	 		makeevent_layer(menu[i][0], i);
			if ( menu[i][5] > 0 ) {			  	  
				//loop through drop down options for each menu and position them
				for (var n=1; n<=menu[i][5]; n++){
					if (n > 1) previous_option_name = menu[i][0] + 'Option' + (n-1);				  		
					option_name = menu[i][0] + 'Option' + n;
	 				alter_bg(option_name,menu[i][3]);
					if (n > 1) {
						incrementalypos += parseInt(document.getElementById(previous_option_name).offsetHeight) + dropdownspacer;
					}
					else incrementalypos = Dropdownypos;					  
					moveTo(document.getElementById(option_name).style, incrementalxpos , incrementalypos);						
				}      		  					  
				incrementalypos += parseInt(document.getElementById(option_name).offsetHeight);				
	  			menu[i][7] = incrementalypos;
				menu[i][8] = incrementalxpos;				  				  
			}
		  }
		  incrementalxpos += document.getElementById(menu[i-1][0]).style.width;	  
		  totalxwidth = incrementalxpos;
		}
	
	    if (is.ie) {
		  // loop through top menus and position them
		  var incrementalxpos = Menuxpos;
		  for (var i=1; i<menu.length; i++){	  	
	   	  	  if (i > 1) incrementalxpos += document.all[menu[i-1][0]].scrollWidth;
			  moveTo(document.all[menu[i][0]].style, incrementalxpos, Menuypos);
			  show(menu[i][0]);					  
			  makeevent_layer(menu[i][0], i);
			  if ( menu[i][5] > 0 ) {			  	  
			  		  //loop through drop down options for each menu and position them
					  for (var n=1; n<=menu[i][5]; n++){
					  	  if (n > 1) previous_option_name = menu[i][0] + 'Option' + (n-1);				  		
						  option_name = menu[i][0] + 'Option' + n;				  							  
						  clipTo(document.all[option_name].style,0,200,350,0);					  
	  					  alter_bg(option_name,menu[i][3]);
						  makeevent_layer(option_name, i);					  
					  	  if (n > 1) incrementalypos += document.all[previous_option_name].scrollHeight + dropdownspacer;				
						  else incrementalypos = Dropdownypos;	  
						  moveTo(document.all[option_name].style, incrementalxpos , incrementalypos);						
					  }      		  					  
					  incrementalypos += document.all[option_name].scrollHeight;				
	  				  menu[i][7] = incrementalypos;
					  menu[i][8] = incrementalxpos;				  				  
			  }
		  }      
		  incrementalxpos += document.all[menu[i-1][0]].scrollWidth;	  
		  totalxwidth = incrementalxpos;	 
	    }
	}
	
	
	function localimageSwap(Image, Src){
	  var objStr,obj;
	  if(document.images){
	     if (typeof(Image) == 'string') {
	      objStr = 'document.' + Image;
	      obj = eval(objStr);
	      obj.src = Src;
	    } else if ((typeof(Image) == 'object') && Image && Image.src) {
	      Image.src = Src;
	    }
	  }
	}
	
	
	//image swap for main navigation
	function imageSwap(Image, Src){
		if (is.ns && is.vers <  5 ) {
			var objStr,obj;		
			var layername = 'MenuItem' + Image.substring(5,6);
			var layerimage = eval('document.' + layername + '.document')
			if(layerimage.images){
				if (typeof(Image) == 'string') {	
					objStr = 'document.' + layername + '.document.' + Image;
					obj = eval(objStr);
					obj.src = Src;
				} 
			}
		}
		else {
			var objStr,obj;
			if(document.images){
				if (typeof(Image) == 'string') {
					objStr = 'document.' + Image;
					obj = eval(objStr);
					obj.src = Src;
				} else if ((typeof(Image) == 'object') && Image && Image.src) {
					Image.src = Src;
				}
			}
		}
	}
	
	
	// just makes sure the screen reloads on changing the screen size
	function reallocate(){
		if ((is.ns && (winW!=window.innerWidth || winH!=window.innerHeight)) || is.ie)
		history.go(0)
	}
