// designed by EUROTEL GmbH NewMedia, Herrenberg, Germany 2000 			 				  //
// modified for www.hafele.com.au by 36-400 Consulting Pty Ltd, Melbourne, Australia 2001 //

// Copyright 2000 by Roman Pohl, Eurotel NewMedia GmbH          						  //
// All rights reserved. The duplication of this Script          						  //
// in any form is strictly prohibited for private and           						  //
// commercial use.                                              						  //

var iscreated = false;
var debug = 1;
function sae(){
	return true;
}
//window.onerror=sae;

var ns4=(document.layers)? true:false
var ie4=(document.all)? true:false
var ns6=(document.getElementById && !document.all)? true:false

// For NS
var ns_posX1024=150;   // resolution 1024 x 768
var ns_posX800=642;  // resolution 800 x 600

// For N6
var n6_posX1024=138;   // resolution 1024 x 768
var n6_posX800=642;  // resolution 800 x 600

//For IE
var ie_posX1024=138; // resolution 1024 x 768
var ie_posX800=642;  // resolution 800 x 600

//Font-characteristics
var fntfamily="Arial";
var fntsize="8pt";
var fntweightmain="bold";
var fntweightsub="normal";
var fntoutright="#ffffff";
var fntoverright="#ffffff";
var fntoutleft="#000000";
var fntoverleft="#ffffff";

var mainpaddingTop=-2;
var mainpaddingLeft=0; //initial value is 0
var subpaddingTop=-2;
//var subpaddingLeft=10;
var subpaddingLeft=8;

//Frame+Background-Colours
var outcolorright="#636363";
var overcolorright="#CC0000";
var outcolorleft="#CCCCCC";
var overcolorleft="#CC0000";
var bordercolormain="#000000";
var bordercolorsub="#ffffff";

//Menu
var menu_Width=0;
var menu_Height=15;

var submenu_Width_right=91;
var submenu_Width_left=140;

//sub menus wider if NS4
if (ns4) submenu_Width_left=155;

var menu=new Array();
var  x=0;

// MainMenu (top right)
menu[x   ]=new Array("1","http://www.hafele.com/au","Home","right");

//menu[x+=1]=new Array("2_1","/navigation/sitemap.htm","Sitemap","right");
//menu[x+=1]=new Array("2_2","/navigation/imprint.asp","Imprint","right");
//menu[x+=1]=new Array("2",null,"Navigation","right");

// MainMenu (left main)
//menu[x+=1]=new Array("3_1","/about/portrait.htm","Brief Portrait","left",0,58);
//menu[x+=1]=new Array("3_2","/about/story.htm","Story","left");
//menu[x+=1]=new Array("3_3","/about/facts.htm","Facts and Figures","left");
//menu[x+=1]=new Array("3",null,"About Us","left");

//menu[x+=1]=new Array("5_1","/service/advice.asp","Expert Advice","left");
//menu[x+=1]=new Array("5_2","/service/project.htm","Project Consultancy","left");
//menu[x+=1]=new Array("5_3","/service/logistics.asp","Logistics","left");
//menu[x+=1]=new Array("5",null,"Service","left");

//menu[x+=1]=new Array("6_1","/production/develop.htm","Development","left");
//menu[x+=1]=new Array("6_2","/production/production.htm","Production","left");
//menu[x+=1]=new Array("6",null,"Production","left");

//menu[x+=1]=new Array("7_1_1","/contacts/australia/victoria.asp","Victoria","left");
//menu[x+=1]=new Array("7_1_2","/contacts/australia/nsw.asp","New South Wales","left");
//menu[x+=1]=new Array("7_1_3","/contacts/australia/wa.asp","Western Australia","left");
//menu[x+=1]=new Array("7_1_4","/contacts/australia/queensland.asp","Queensland","left");
//menu[x+=1]=new Array("7_1_5","/contacts/australia/sa.asp","South Australia","left");
//menu[x+=1]=new Array("7_1_6","/contacts/australia/act.asp","Australian Capital Territory","left");
//menu[x+=1]=new Array("7_1_7","/contacts/australia/nt.asp","Northern Territory","left");
//menu[x+=1]=new Array("7_1_8","/contacts/australia/tasmania.asp","Tasmania","left");
/**
menu[x+=1]=new Array("7_2_1","/contacts/newzealand/auckland.htm","Auckland","left");
menu[x+=1]=new Array("7_2_2","/contacts/newzealand/christchurch.htm","Christchurch","left");
menu[x+=1]=new Array("7_2_3","/contacts/newzealand/wellington.htm","Wellington","left");

menu[x+=1]=new Array("7_3_1","/contacts/worldwide/europe.htm","Europe","left");
menu[x+=1]=new Array("7_3_2","/contacts/worldwide/africa.htm","Africa","left");
menu[x+=1]=new Array("7_3_3","/contacts/worldwide/america.htm","America","left");
menu[x+=1]=new Array("7_3_4","/contacts/worldwide/asia.htm","Asia","left");

menu[x+=1]=new Array("7_1","/contacts/australia/australia.htm","Australia","left");
menu[x+=1]=new Array("7_2","/contacts/newzealand/newzealand.htm","New Zealand","left");
menu[x+=1]=new Array("7_3","/contacts/worldwide/default.htm","Häfele worldwide","left");
menu[x+=1]=new Array("7",null,"Contacts","left");

menu[x+=1]=new Array("8_1","/isapi/news/news/","News","left");
menu[x+=1]=new Array("8_2","/isapi/news/newproducts/","New Products","left");
menu[x+=1]=new Array("8",null,"News","left");

menu[x+=1]=new Array("9_1","/catalogues/catalogues.htm","Catalogue Overview","left");
menu[x+=1]=new Array("9_2","/catalogues/c_furniture.htm","&nbsp;- Furniture Fittings","left");
menu[x+=1]=new Array("9_3","/catalogues/c_hardware.htm","&nbsp;- Sliding & Folding Door H/W","left");
menu[x+=1]=new Array("9_4","/catalogues/c_dialock.htm","&nbsp;- Dialock","left");
menu[x+=1]=new Array("9_5","/catalogues/c_outofsight.htm","&nbsp;- Out Of Sight","left");
menu[x+=1]=new Array("9_6","/isapi/online/catalogues.asp","Online Catalogues","left");
menu[x+=1]=new Array("9",null,"Catalogues","left");

menu[x+=1]=new Array("10","/isapi/online/default.asp","Häfele Online","left");
*/

// DO NOT EDIT CODE BEYOND THIS POINT !!!!

var winW, winH;
var ref_layer=new Array();
var parent_array=new Array();
var subContainer_array=new Array();

var mainContainer_Width;
var factor_menubroad=7;
var factor_constant=20;

var startmainPosY=0;
var mainPosY=0;

var DistanceY=menu_Height+1;
var subPosY=menu_Height;

var subContainerCounter=0;
var itemcounter;

var hideTimer=null;
var sleepTime=35;
var colorflag=null;

//alert("this is the enterance");

if(ns6){
//alert("Your Browser is Netscape 6+");
}
//alert("Pass NS6");
if(ns4){
//alert("This in the Netscape 4 Ver");
	document.write('<LINK REL=STYLESHEET href="/styles/style_4.css" TYPE="text/css">');
	var visible="show", hidden="hidden";
	var startWidth, startHeight;
	var txtLyr;
	var dummyLyr;
	
	sleepTime=350;
	DistanceY=menu_Height-1;

	if(fntweightmain=="bold"){ 
		fntweightmainstart="<b>";
		fntweightmainend="</b>";
	}else{
		fntweightmainstart="";
		fntweightmainend="";
	}
	if(fntweightsub=="bold"){ 
		fntweightsubstart="<b>";
		fntweightsubend="</b>";
	}else{
		fntweightsubstart="";
		fntweightsubend="";
	}

	//var fntsize_sub = fntsize;
	if(parseInt(fntsize) < 9) fntsize=parseInt(fntsize)+1;
	var fntsize_sub = fntsize;
}
//alert("Pass NS4");
//alert("before IE4");
if(ie4){
//alert("Get Into the IE Part"+(document.all)? true:false);
	var visible="visible", hidden="hidden";
	var backup_startmainPosX=0;
	var isresized=false;
	var diffPosX=0;
	var subContainer_left=new Array();
	var subContainer_right=new Array();
	var subContainerCounter_left=0;
	var subContainerCounter_right=0;

	with(document){
	clear();
	write('<STYLE TYPE="text/css">');
	write('.Container{position:absolute; width:0;height:0;background-color:#ff0000; z-index:99;');
	write('font-family:'+fntfamily+';');
	write('font-size:'+fntsize+';');
	write('text-decoration:none;');
	write('cursor:default;}');
	write('</STYLE>');
	close();
}
//alert("Pass IE4");

}

var path=window.location.href;
var pathName=path.toLowerCase();
var colorflag=null;

for (i=0; i < menu.length;i++){
	if(menu[i][0].indexOf("_") < 0){
		var menuText=menu[i][2].toLowerCase();
		if(menuText.indexOf(" ")!=-1) menuText=menuText.substring(0,menuText.indexOf(" "))
		if(menuText.indexOf("ä")!=-1) menuText=menuText.substring(0,menuText.indexOf("ä"))+"ae"+menuText.substring(menuText.indexOf("ä")+1, menuText.length)
		if(menuText.indexOf("ö")!=-1) menuText=menuText.substring(0,menuText.indexOf("ö"))+"oe"+menuText.substring(menuText.indexOf("ö")+1, menuText.length)
		if(menuText.indexOf("ü")!=-1) menuText=menuText.substring(0,menuText.indexOf("ü"))+"ue"+menuText.substring(menuText.indexOf("ü")+1, menuText.length)
		//alert(pathName + "     " + menuText)
		if(pathName.indexOf(menuText)!=-1){
			colorflag=i;
			//break;
		}
	}
}

function createmainContainer(){
	mainContainer_Width=0;
	mainContainer_id="mainContainer"+whichmenu;

	if(ns4){
		for (i=0; i < menu.length; i++){
			if(menu[i][3]==whichmenu){
				if(menu[i][0].indexOf("_")==-1){ // mainMenus
					nstext=menu[i][2];
					//menu_Width=parseInt(nstext.length) * 8+(2*subpaddingLeft);
					//menu_Width=parseInt(nstext.length) * factor_menubroad + (2*subpaddingLeft);
					menu_Width=parseInt(nstext.length) * factor_menubroad + (factor_constant);
					mainContainer_Width=parseInt(mainContainer_Width+menu_Width);
				}
			}
		}
		mainContainer_Width=mainContainer_Width - AnzmainMenu + 1;

	//alert(AnzmainMenu + "  " + mainContainer_Width)
		var mainContainer_Height=menu_Height+2;
		if(startmainPosY!=0) startmainPosY+=1;
		mainContainer_id.make_Obj=make_Obj(null,mainContainer_id,null,null,mainPosX,startmainPosY,mainContainer_Width,mainContainer_Height,null,'#000000',hidden,0);
		mainPosX=1;
		mainPosY=1;

		// SubContainer Height
		var item_Height=menu_Height-2;
		for (var i=0; i < menu.length; i++){
			if(menu[i][3]==whichmenu){
				var itemcounter=1;
				for (var k=i+1; k < menu.length; k++){

					if(menu[i][0].indexOf("_")!=-1 && menu[i][0].substring(0,menu[i][0].lastIndexOf("_")) == menu[k][0].substring(0,menu[k][0].lastIndexOf("_"))){
						itemcounter++;
						subContainer_Height[i]=(itemcounter * item_Height+itemcounter+1)+2;
					}	
					else{
						if(itemcounter==1) subContainer_Height[i]=menu_Height+2;
						itemcounter=1;
						break;
					}
				}
			}
		}
	}
	if(ie4){
		HTML_Code="<DIV ID="+mainContainer_id+" CLASS='Container'></DIV>";
		window.document.body.insertAdjacentHTML("BeforeEnd", HTML_Code);
		mainContainer_id.make_Obj=make_Obj(null,mainContainer_id,null,null,mainPosX,startmainPosY,null,null,null,'#ff0000',visible,0);
		mainPosX=0;
	}
	if(ns6){
//if (debug=1) alert("Line 283:")
			HTML_Code="<DIV ID="+mainContainer_id+" CLASS='Container'></DIV>";
//if (debug=1) alert("Line 285")
			window.document.body.insertAdjacentHTML("BeforeEnd", HTML_Code);
//if (debug=1) alert("Line 287:")
			mainContainer_id.make_Obj=make_Obj(null,mainContainer_id,null,null,mainPosX,startmainPosY,null,null,null,'#ff0000',visible,0);
			mainPosX=0;
	}
}

var subContainer_Height=new Array();
var child_menu=new Array();
var AnzmainMenu=0;
var counter=0
var initcounter=1;
var whichmenu;

function init(){
	if(initcounter==1){
		whichmenu="right";
		submenu_Width=submenu_Width_right;

		if(ns4){
			var winW = window.innerWidth; //-16;
			var winH = window.innerHeight;
			startWidth = winW;
			startHeight= winH;
			if(winW >= 797) startmainPosX = winW - ns_posX1024;
			if(winW <  797) startmainPosX = ns_posX800;
			outcolor=outcolorright,overcolor=overcolorright,fntcolor=fntoutright,fntout=fntoutright,fntover=fntoverright;
		}
		if(ie4){
			winW = document.body.offsetWidth-20;
			winH = document.body.offsetHeight;
			if(winW >= 781) startmainPosX = winW - ie_posX1024;
			if(winW <  781) startmainPosX = ie_posX800;
		}
		if(ns6){
			winW = document.body.offsetWidth-20;
			winH = document.body.offsetHeight;
			if(winW >= 781) startmainPosX = winW - n6_posX1024;
			if(winW <  781) startmainPosX = n6_posX800;
		}
		mainPosX=startmainPosX + 75; //initial=startmainPosX
		backup_startmainPosX=startmainPosX;
	}
//if (debug=1)alert("Line 320:");
	if(initcounter==2){
		whichmenu="left";
		submenu_Width=submenu_Width_left;
		if(ns4){outcolor=outcolorleft,overcolor=overcolorleft,fntcolor=fntoutleft,fntout=fntoutleft,fntover=fntoverleft;}
	}

	AnzmainMenu=0;
	var diff_k=0;
//if (debug=1)alert("Line 329:");
	for (var i=0; i < menu.length; i++){
		if(menu[i][3]==whichmenu){
			if(whichmenu=="left") if(eval(menu[i][4])) mainPosX=menu[i][4];
			if(eval(menu[i][5])) mainPosY=startmainPosY=menu[i][5];

			subContainer_Height[i]=0;
			menuIndex=menu[i][0];
			if(menuIndex.indexOf("_")==-1) AnzmainMenu++;
		}
	}
	createmainContainer();

	for (i=0; i < menu.length; i++){
		if(menu[i][3]==whichmenu){
			menuIndex=menu[i][0];
			for (var j=0; j < menuIndex.length; j++){

				if(menuIndex.indexOf("_")==-1){ // mainMenus
					menu_id="menu"+menuIndex+"Parent";
					menu_link=menu[i][1];
					nstext=menu[i][2];
					//menu_Width=parseInt(nstext.length) * 8+(2*subpaddingLeft);
					//menu_Width=parseInt(nstext.length) * factor_menubroad + (2*subpaddingLeft);
					menu_Width=parseInt(nstext.length) * factor_menubroad + (factor_constant);
					if(ie4){
						HTML_Code="<DIV ID="+menu_id+" CLASS='Container'><CENTER>"+menu[i][2]+"</CENTER></DIV>";
						window.document.all[mainContainer_id].insertAdjacentHTML("BeforeEnd", HTML_Code);
						menu_id.make_Obj=make_Obj(i,menu_id,mainContainer_id,menu_link,mainPosX,0,menu_Width,menu_Height,null,null,visible,0,whichmenu);
					}
					if(ns6){
						HTML_Code="<DIV ID="+menu_id+" CLASS='Container'><CENTER>"+menu[i][2]+"</CENTER></DIV>";
						window.document.getElementById(mainContainer_id).insertAdjacentHTML("BeforeEnd", HTML_Code);
						menu_id.make_Obj=make_Obj(i,menu_id,mainContainer_id,menu_link,mainPosX,0,menu_Width,menu_Height,null,null,visible,0,whichmenu);
					}					
					if(ns4)	menu_id.make_Obj=make_Obj(i,menu_id,mainContainer_id,menu_link,mainPosX,mainPosY,menu_Width-2,menu_Height,nstext,outcolor,visible,0);

					mainPosX=mainPosX+menu_Width-1;
					break;
				}
				else{
					if(whichmenu=="left") counter++;
					subPosY=startmainPosY+DistanceY+1;

					for(var j=0; j < menuIndex.length; j++)
						for(var k=i; k >=0; k--){
							if(menu[k][0].indexOf("_1") == parseInt(menu[k][0].length-2)){
								subContainer_id="subContainer"+menu[k][0];
								if(counter==1) diff_k=menu[k][0].substring(0,parseInt(menu[k][0].indexOf("_")))-1;
								subPosX=startmainPosX;
								k=0;
							}
						}
	
					if(ns4){
						if(subContainer_id!=null && !document.layers[subContainer_id]){
							itemPosX=1;
							itemPosY=1;
							menu_id.make_Obj=make_Obj(i,subContainer_id,null,null,subPosX,subPosY,submenu_Width,subContainer_Height[i],nstext,bordercolorsub,hidden,0);
						}
						menu_id="menu"+menuIndex+"Child";
						menu_link=menu[i][1];
						nstext=menu[i][2];
						menu_id.make_Obj=make_Obj(i,menu_id,subContainer_id,menu_link,itemPosX,itemPosY,submenu_Width-2,menu_Height,nstext,outcolor,"inherit",10)
						itemPosY=itemPosY+DistanceY;
					}
					if(ie4){
						if(!document.all[subContainer_id]){
							itemPosY=-1;
							HTML_Code="<DIV ID="+subContainer_id+" CLASS='Container'></DIV>";
							window.document.body.insertAdjacentHTML("BeforeEnd", HTML_Code);
							menu_id.make_Obj=make_Obj(i,subContainer_id,null,null,subPosX,subPosY,submenu_Width,0,null,null,hidden,0,whichmenu);
						}
				
						menu_id="menu"+menuIndex+"Child";
						menu_link=menu[i][1];
						HTML_Code="<DIV ID="+menu_id+" CLASS='Container'>"+menu[i][2]+"</DIV>";
						document.all[subContainer_id].insertAdjacentHTML("BeforeEnd", HTML_Code);
						menu_id.make_Obj=make_Obj(i,menu_id,subContainer_id,menu_link,0,itemPosY,submenu_Width,menu_Height,null,null,"inherit",10,whichmenu);
						itemPosY=itemPosY+DistanceY-1;
					}
					if(ns6){
						if(!document.getElementById[subContainer_id]){
							itemPosY=-1;
							HTML_Code="<DIV ID="+subContainer_id+" CLASS='Container'></DIV>";
							window.document.body.insertAdjacentHTML("BeforeEnd", HTML_Code);
							menu_id.make_Obj=make_Obj(i,subContainer_id,null,null,subPosX,subPosY,submenu_Width,0,null,null,hidden,0,whichmenu);
						}
				
						menu_id="menu"+menuIndex+"Child";
						menu_link=menu[i][1];
						HTML_Code="<DIV ID="+menu_id+" CLASS='Container'>"+menu[i][2]+"</DIV>";
						document.all[subContainer_id].insertAdjacentHTML("BeforeEnd", HTML_Code);
						menu_id.make_Obj=make_Obj(i,menu_id,subContainer_id,menu_link,0,itemPosY,submenu_Width,menu_Height,null,null,"inherit",10,whichmenu);
						itemPosY=itemPosY+DistanceY-1;
					}					
				}
			}
		}
	}
//if (debug=1) alert("Line 429:");	
	mainPosX=startmainPosX=0;
	mainPosY=startmainPosY=0;
	subPosX=0;
	subPosY=0;

	if(initcounter==1){
		initcounter++;
		init();
		setsubmenusPos();
	}
	else{
		if(ns4){
			Mainmenuleft.visibility=visible;
			Mainmenuright.visibility=visible;
		}
		iscreated = true;
		status="Popup-Menus ready";
	}
}

function setsubmenusPos(){
	for (i=menu.length-1; i >=0; i--){
		if(menu[i][3]=="right") submenu_Width=submenu_Width_right;
		if(menu[i][3]=="left") submenu_Width=submenu_Width_left;

		menuIndex=menu[i][0];
		if(menuIndex.length >=3 && ref_layer[i].child){
			var str_id="subContainer"+menu[i][0].substring(0,menu[i][0].length-1)+"1";
			if(ns4){
				ref_layer[i].child.left=document.layers[str_id].left+submenu_Width-1;
				if(menu[i][0].length >=5) ref_layer[i].child.top=parseInt(document.layers[str_id].top)+parseInt(ref_layer[i].top)-1;
			}
			if(ie4){
				ref_layer[i].child.style.left=parseInt(document.all[str_id].style.left)+parseInt(submenu_Width-1)+"px";
				if(menu[i][0].length >=5) ref_layer[i].child.style.top=parseInt(document.all[str_id].style.top)+parseInt(ref_layer[i].style.top)+1+"px";
			}
			if(ns6){
			//alert("get in here?");
				ref_layer[i].child.style.left=parseInt(document.all[str_id].style.left)+parseInt(submenu_Width-1)+"px";
				if(menu[i][0].length >=5) ref_layer[i].child.style.top=parseInt(document.all[str_id].style.top)+parseInt(ref_layer[i].style.top)+1+"px";
			}		}
	}
}

function make_Obj(arraycounter,id,nestref,link,left,top,width,height,content,bgColor,visibility,zIndex,menuleftright){
	//status="Popup-Menus ready"+arraycounter;
	if(ns4){
		if(nestref){
			ref_layer[arraycounter]=eval("document."+nestref+".document."+id+"=new Layer(width, document."+nestref+")");
		}
		else{
			ref_layer[arraycounter]=document.layers[id]=new Layer(width);
			eval("document."+id+"=ref_layer[arraycounter]");
		}
		ref_layer[arraycounter].name=id;

		ref_layer[arraycounter].left=left;
		ref_layer[arraycounter].top=top;

		ref_layer[arraycounter].clip.top=0;
		ref_layer[arraycounter].clip.right=width;
		ref_layer[arraycounter].clip.bottom=height-2;
		ref_layer[arraycounter].clip.left=0;

		if(id=="mainContainerright") Mainmenuright=ref_layer[arraycounter];
		if(id=="mainContainerleft")	Mainmenuleft=ref_layer[arraycounter];

		ref_layer[arraycounter].bgColor=bgColor;
		ref_layer[arraycounter].visibility=visibility;

		if(nestref){
			if(id.indexOf("Parent")!=-1){

			for (var p=arraycounter-1; p >= 0; p--){
				if(menu[p][0].length-parseInt(id.length-10)==2){
					if(id.substring(4,id.lastIndexOf("Parent"))-1 == menu[p][0].substring(0,menu[p][0].lastIndexOf("_"))-1 && (menu[p][0].lastIndexOf("1") == menu[p][0].length-1)){						
						ref_layer[arraycounter].child=subContainer_array[p];
						if(whichmenu=="right")
							ref_layer[arraycounter].child.left=startmainPosX+left-1;
						else
							ref_layer[arraycounter].child.left=left-1;
						p=0;
						break;
					}	
				}
			}			
			ref_layer[arraycounter].container=document.layers[nestref];
			txtLyr=new Layer(width,ref_layer[arraycounter]);

			txtLyr.top=mainpaddingTop;
			txtLyr.left=mainpaddingLeft;

			txtLyr.clip.top=0;
			txtLyr.clip.right=width;
			txtLyr.clip.bottom=height;
			txtLyr.clip.left=0;
			
			txtLyr.disptext=nstext;
			txtLyr.visibility="inherit";

			txtLyr.document.open();
			if(arraycounter==colorflag){
				txtLyr.document.write('<center><font face='+fntfamily+' point-size='+fntsize+' color='+fntover+'><nobr>'+fntweightmainstart+content+fntweightmainend+'<nobr></font></center>');
			}
			else{
				txtLyr.document.write('<center><font face='+fntfamily+' point-size='+fntsize+' color='+fntout+'><nobr>'+fntweightmainstart+content+fntweightmainend+'<nobr></font></center>');
			}
			txtLyr.document.close();

			dummyLyr=new Layer(width,ref_layer[arraycounter]);

			dummyLyr.clip.top=ref_layer[arraycounter].clip.top;
			dummyLyr.clip.right=ref_layer[arraycounter].clip.right;
			dummyLyr.clip.bottom=ref_layer[arraycounter].clip.bottom;
			dummyLyr.clip.left=ref_layer[arraycounter].clip.left;
			dummyLyr.visibility=visible;

			dummyLyr.item=txtLyr;
			dummyLyr.bgLyr=ref_layer[arraycounter];
			
			dummyLyr.bgcolor=bgColor;
			dummyLyr.fntout=fntout;
			dummyLyr.child=ref_layer[arraycounter].child;
			dummyLyr.link=link;

			dummyLyr.colorflag=false;

			if(arraycounter==colorflag){
				ref_layer[arraycounter].bgColor=overcolor;
				dummyLyr.colorflag=true;
			}
			dummyLyr.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE);
				
			dummyLyr.onmouseover=overMainmenu;
			dummyLyr.onmouseout=outMainmenu;
			dummyLyr.onmouseup=downmenuItem;
			}
			else if(id.indexOf("Child")!=-1){
				for(var c=arraycounter-1; c >= 0; c--){
					var id_str=id.substring(4,id.length);					// 1_1Child
					id_str=id_str.substring(0,id_str.lastIndexOf("Child"));	// 1_1

					if(menu[c][0].lastIndexOf(id_str)==0){
						if(menu[c][0].lastIndexOf("_1") == parseInt(menu[c][0].length-2)){
							ref_layer[arraycounter].child=subContainer_array[c];
							ref_layer[arraycounter].child.top=parseInt(document.layers[nestref].top)+parseInt(ref_layer[arraycounter].top)-1;
							ref_layer[arraycounter].parent=parent_array[c];
							c=0;
							break;
						}
					}
				}
				ref_layer[arraycounter].container=document.layers[nestref];
				txtLyr=new Layer(width,ref_layer[arraycounter]);

				txtLyr.top=subpaddingTop;
				txtLyr.left=subpaddingLeft;

				txtLyr.clip.top=ref_layer[arraycounter].clip.top;
				txtLyr.clip.right=ref_layer[arraycounter].clip.right;
				txtLyr.clip.bottom=ref_layer[arraycounter].clip.bottom+2;
				txtLyr.clip.left=ref_layer[arraycounter].clip.left;

				txtLyr.disptext=nstext;
				txtLyr.visibility="inherit";

				txtLyr.document.open();
				txtLyr.document.write('<font face='+fntfamily+' point-size='+fntsize_sub+' color='+fntout+'>'+fntweightsubstart+content+fntweightsubend+'</font>');
				txtLyr.document.close();

				dummyLyr=new Layer(width,ref_layer[arraycounter]);

				dummyLyr.clip.top=ref_layer[arraycounter].clip.top;
				dummyLyr.clip.right=ref_layer[arraycounter].clip.right;
				dummyLyr.clip.bottom=ref_layer[arraycounter].clip.bottom;
				dummyLyr.clip.left=ref_layer[arraycounter].clip.left;

				dummyLyr.visibility="inherit";

				dummyLyr.bgcolor=bgColor;
				dummyLyr.fntout=fntout;

				dummyLyr.item=txtLyr;
				dummyLyr.bgLyr=ref_layer[arraycounter];
				dummyLyr.container=ref_layer[arraycounter].container;
				dummyLyr.child=ref_layer[arraycounter].child;
				dummyLyr.link=link;

				dummyLyr.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE);

				dummyLyr.onmouseover=overSubItem;
				dummyLyr.onmouseout=outSubItem;
				dummyLyr.onmouseup=downmenuItem;
			}
		}
		if(id.indexOf("subContainer")!=-1){
			subContainer_array[arraycounter]=ref_layer[arraycounter];
			subContainerCounter++;
		}
	}

	if(ie4){
		ref_layer[arraycounter]=this.document.all[id];

		if(id=="mainContainerright") Mainmenuright=ref_layer[arraycounter];
		if(id=="mainContainerleft")	Mainmenuleft=ref_layer[arraycounter];

		ref_layer[arraycounter].style.left=left;
		ref_layer[arraycounter].style.top=top;
		ref_layer[arraycounter].style.width=width;
		ref_layer[arraycounter].style.height=height;
		ref_layer[arraycounter].style.visibility=visibility;

		ref_layer[arraycounter].link=link;
		ref_layer[arraycounter].container=document.all[nestref];

		if(id.lastIndexOf("Parent")!=-1){
			for (var p=arraycounter-1; p >= 0; p--){
				if(menu[p][0].length-parseInt(id.length-10)==2){
					if(id.substring(4,id.lastIndexOf("Parent"))-1 == menu[p][0].substring(0,menu[p][0].lastIndexOf("_"))-1 && (menu[p][0].lastIndexOf("1") == menu[p][0].length-1)){						
						ref_layer[arraycounter].child=subContainer_array[p];
						ref_layer[arraycounter].child.style.left=startmainPosX + parseInt(ref_layer[arraycounter].style.left);
						p=0;
						break;
					}	
				}
			}			
		 	ref_layer[arraycounter].style.borderStyle="solid";
		 	ref_layer[arraycounter].style.borderWidth=1;
		 	ref_layer[arraycounter].style.borderColor=bordercolormain;
		 	ref_layer[arraycounter].style.fontWeight=fntweightmain;

			ref_layer[arraycounter].colorflag=false;
						
			if(menuleftright=="right"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorright;
			 	ref_layer[arraycounter].style.color=fntoutright;
			 	ref_layer[arraycounter].out=outcolorright;
				ref_layer[arraycounter].over=overcolorright;
		 		ref_layer[arraycounter].fntout=fntoutright;
				ref_layer[arraycounter].fntover=fntoverright;
				if(arraycounter==colorflag){
				 	ref_layer[arraycounter].style.backgroundColor=overcolorright;
					ref_layer[arraycounter].style.color=fntoverright;
					ref_layer[arraycounter].colorflag=true;
				}
			}

			if(menuleftright=="left"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorleft;
			 	ref_layer[arraycounter].style.color=fntoutleft;
			 	ref_layer[arraycounter].out=outcolorleft;
				ref_layer[arraycounter].over=overcolorleft;
		 		ref_layer[arraycounter].fntout=fntoutleft;
				ref_layer[arraycounter].fntover=fntoverleft;
				if(arraycounter==colorflag){
				 	ref_layer[arraycounter].style.backgroundColor=overcolorleft;
					ref_layer[arraycounter].style.color=fntoverleft;
					ref_layer[arraycounter].colorflag=true;
				}
			}

			ref_layer[arraycounter].onmouseover=overMainmenu;
			ref_layer[arraycounter].onmouseout=outMainmenu;
			ref_layer[arraycounter].onmousedown=downmenuItem;
		}
		else if(id.lastIndexOf("Child")!=-1){
			for(var c=arraycounter-1; c >= 0; c--){
				var id_str=id.substring(4,id.length);
				id_str=id_str.substring(0,id_str.lastIndexOf("Child"));

				if(menu[c][0].lastIndexOf(id_str)==0){
					if(menu[c][0].lastIndexOf("_1") == parseInt(menu[c][0].length-2)){
						ref_layer[arraycounter].child=subContainer_array[c];
						ref_layer[arraycounter].child.style.top=parseInt(document.all[nestref].style.top)+parseInt(ref_layer[arraycounter].style.top)+1;
						c=0;
						break;
					}	
				}			
			}
			ref_layer[arraycounter].container=document.all[nestref];
		 	ref_layer[arraycounter].style.borderStyle="solid";
	 		ref_layer[arraycounter].style.borderWidth=1;
		 	ref_layer[arraycounter].style.borderColor=bordercolorsub;
		 	ref_layer[arraycounter].style.fontWeight=fntweightsub;
			ref_layer[arraycounter].style.paddingLeft = subpaddingLeft;

			if(menuleftright=="right"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorright;
			 	ref_layer[arraycounter].style.color=fntoutright;
		 		ref_layer[arraycounter].out=outcolorright;
				ref_layer[arraycounter].over=overcolorright;
		 		ref_layer[arraycounter].fntout=fntoutright;
				ref_layer[arraycounter].fntover=fntoverright;
			}

			if(menuleftright=="left"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorleft;
			 	ref_layer[arraycounter].style.color=fntoutleft;
		 		ref_layer[arraycounter].out=outcolorleft;
				ref_layer[arraycounter].over=overcolorleft;
		 		ref_layer[arraycounter].fntout=fntoutleft;
				ref_layer[arraycounter].fntover=fntoverleft;
			}
			ref_layer[arraycounter].onmouseover=overSubItem;
			ref_layer[arraycounter].onmouseout=outSubItem;
			ref_layer[arraycounter].onmousedown=downmenuItem;
		}
		else if(id.lastIndexOf("subContainer")!=-1){
			subContainer_array[arraycounter]=ref_layer[arraycounter];
			subContainerCounter++;
			if(menuleftright=="right"){
				subContainer_right[subContainerCounter_right]=ref_layer[arraycounter];
				subContainerCounter_right++;
			}
			if(menuleftright=="left"){
				subContainer_left[subContainerCounter_left]=ref_layer[arraycounter];
				subContainerCounter_left++;
			}
		}
	}
	if(ns6){
	//alert("get in ref_layer"+this.document.getElementById[id]);
		ref_layer[arraycounter]=this.document.getElementById[id];

		if(id=="mainContainerright") Mainmenuright=ref_layer[arraycounter];
		if(id=="mainContainerleft")	Mainmenuleft=ref_layer[arraycounter];

		ref_layer[arraycounter].style.left=left;
		ref_layer[arraycounter].style.top=top;
		ref_layer[arraycounter].style.width=width;
		ref_layer[arraycounter].style.height=height;
		ref_layer[arraycounter].style.visibility=visibility;

		ref_layer[arraycounter].link=link;
		ref_layer[arraycounter].container=document.getElementById[nestref];

		if(id.lastIndexOf("Parent")!=-1){
			for (var p=arraycounter-1; p >= 0; p--){
				if(menu[p][0].length-parseInt(id.length-10)==2){
					if(id.substring(4,id.lastIndexOf("Parent"))-1 == menu[p][0].substring(0,menu[p][0].lastIndexOf("_"))-1 && (menu[p][0].lastIndexOf("1") == menu[p][0].length-1)){						
						ref_layer[arraycounter].child=subContainer_array[p];
						ref_layer[arraycounter].child.style.left=startmainPosX + parseInt(ref_layer[arraycounter].style.left);
						p=0;
						break;
					}	
				}
			}			
		 	ref_layer[arraycounter].style.borderStyle="solid";
		 	ref_layer[arraycounter].style.borderWidth=1;
		 	ref_layer[arraycounter].style.borderColor=bordercolormain;
		 	ref_layer[arraycounter].style.fontWeight=fntweightmain;

			ref_layer[arraycounter].colorflag=false;
						
			if(menuleftright=="right"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorright;
			 	ref_layer[arraycounter].style.color=fntoutright;
			 	ref_layer[arraycounter].out=outcolorright;
				ref_layer[arraycounter].over=overcolorright;
		 		ref_layer[arraycounter].fntout=fntoutright;
				ref_layer[arraycounter].fntover=fntoverright;
				if(arraycounter==colorflag){
				 	ref_layer[arraycounter].style.backgroundColor=overcolorright;
					ref_layer[arraycounter].style.color=fntoverright;
					ref_layer[arraycounter].colorflag=true;
				}
			}

			if(menuleftright=="left"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorleft;
			 	ref_layer[arraycounter].style.color=fntoutleft;
			 	ref_layer[arraycounter].out=outcolorleft;
				ref_layer[arraycounter].over=overcolorleft;
		 		ref_layer[arraycounter].fntout=fntoutleft;
				ref_layer[arraycounter].fntover=fntoverleft;
				if(arraycounter==colorflag){
				 	ref_layer[arraycounter].style.backgroundColor=overcolorleft;
					ref_layer[arraycounter].style.color=fntoverleft;
					ref_layer[arraycounter].colorflag=true;
				}
			}

			ref_layer[arraycounter].onmouseover=overMainmenu;
			ref_layer[arraycounter].onmouseout=outMainmenu;
			ref_layer[arraycounter].onmousedown=downmenuItem;
		}
		else if(id.lastIndexOf("Child")!=-1){
			for(var c=arraycounter-1; c >= 0; c--){
				var id_str=id.substring(4,id.length);
				id_str=id_str.substring(0,id_str.lastIndexOf("Child"));

				if(menu[c][0].lastIndexOf(id_str)==0){
					if(menu[c][0].lastIndexOf("_1") == parseInt(menu[c][0].length-2)){
						ref_layer[arraycounter].child=subContainer_array[c];
						ref_layer[arraycounter].child.style.top=parseInt(document.getElementById[nestref].style.top)+parseInt(ref_layer[arraycounter].style.top)+1;
						c=0;
						break;
					}	
				}			
			}
			ref_layer[arraycounter].container=document.getElementById[nestref];
		 	ref_layer[arraycounter].style.borderStyle="solid";
	 		ref_layer[arraycounter].style.borderWidth=1;
		 	ref_layer[arraycounter].style.borderColor=bordercolorsub;
		 	ref_layer[arraycounter].style.fontWeight=fntweightsub;
			ref_layer[arraycounter].style.paddingLeft = subpaddingLeft;

			if(menuleftright=="right"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorright;
			 	ref_layer[arraycounter].style.color=fntoutright;
		 		ref_layer[arraycounter].out=outcolorright;
				ref_layer[arraycounter].over=overcolorright;
		 		ref_layer[arraycounter].fntout=fntoutright;
				ref_layer[arraycounter].fntover=fntoverright;
			}

			if(menuleftright=="left"){
			 	ref_layer[arraycounter].style.backgroundColor=outcolorleft;
			 	ref_layer[arraycounter].style.color=fntoutleft;
		 		ref_layer[arraycounter].out=outcolorleft;
				ref_layer[arraycounter].over=overcolorleft;
		 		ref_layer[arraycounter].fntout=fntoutleft;
				ref_layer[arraycounter].fntover=fntoverleft;
			}
			ref_layer[arraycounter].onmouseover=overSubItem;
			ref_layer[arraycounter].onmouseout=outSubItem;
			ref_layer[arraycounter].onmousedown=downmenuItem;
		}
		else if(id.lastIndexOf("subContainer")!=-1){
			subContainer_array[arraycounter]=ref_layer[arraycounter];
			subContainerCounter++;
			if(menuleftright=="right"){
				subContainer_right[subContainerCounter_right]=ref_layer[arraycounter];
				subContainerCounter_right++;
			}
			if(menuleftright=="left"){
				subContainer_left[subContainerCounter_left]=ref_layer[arraycounter];
				subContainerCounter_left++;
			}
		}
	}	
}

function changemainLayer(id_bgLyr,id_txtLyr,text,bgcolor,fntcolor){
	id_bgLyr.document.bgColor=bgcolor;
	ref=id_txtLyr.document;

	ref.open();
	ref.write('<center><font face='+fntfamily+' point-size='+fntsize+' color='+fntcolor+'><nobr>'+fntweightmainstart+text+fntweightmainend+'<nobr></font></center>');
	ref.close();
}

function changesubLayer(id_bgLyr,id_txtLyr,text,bgcolor,fntcolor){
	id_bgLyr.document.bgColor=bgcolor;
	ref=id_txtLyr.document;

	ref.open();
	ref.write('<font face='+fntfamily+' point-size='+ fntsize_sub +' color='+fntcolor+'><nobr>'+fntweightsubstart+text+fntweightsubend+'</nobr></font>');
	ref.close();
}

var backupchild="";
function hideallsubmenu(){
	clearTimeout(hideTimer);
	for(var i=0; i < subContainer_array.length; i++){
		if(subContainer_array[i]){
			if(ns4) subContainer_array[i].visibility=hidden;
			if(ie4) subContainer_array[i].style.visibility=hidden;
		}
	}
}	

function hidesubmenu(){
	if(backupchild){
		if(ns4) backupchild.visibility=hidden; 
		if(ie4) backupchild.style.visibility=hidden; 
	}
	if(ns4) submenu.visibility=visible;
	if(ie4) submenu.style.visibility=visible;
}	

function overMainmenu(){
//if(!popupmenu_active) return;
	if(ns4) changemainLayer(this.bgLyr,this.item,this.item.disptext,overcolor,fntover);
	if(ie4){
		this.style.backgroundColor=this.over;
		this.style.color=this.fntover;
	}
	hideallsubmenu();

	if(this.child){
		if(ns4)	this.child.visibility=visible;
		if(ie4)	this.child.style.visibility=visible;
	}
}

function outMainmenu(){
//if(!popupmenu_active) return;
	if(!this.colorflag){
		if(ns4) changemainLayer(this.bgLyr,this.item,this.item.disptext,this.bgcolor,this.fntout);
		if(ie4){
			this.style.backgroundColor=this.out;
			this.style.color=this.fntout;
		}
	}	
	hideTimer=setTimeout("hideallsubmenu()",sleepTime);
}

function overSubItem(){
//if(!popupmenu_active) return;
	clearTimeout(hideTimer);
	submenu=this.container;
	hidesubmenu();
	
	if(ns4){
		changesubLayer(this.bgLyr,this.item,this.item.disptext,overcolor,fntover);
		this.container.visibility=visible;
	}
	if(ie4){
		this.style.backgroundColor=this.over;
		this.style.color=this.fntover;
		this.container.style.visibility=visible;
	}
	if(this.child){
		backupchild=this.child;
		if(ns4) this.child.visibility=visible;
		if(ie4)	this.child.style.visibility=visible;
	}
}

function outSubItem(){
//if(!popupmenu_active) return;
	clearTimeout(hideTimer);
	if(ns4) changesubLayer(this.bgLyr,this.item,this.item.disptext,this.bgcolor,this.fntout);
	if(ie4){
		this.style.backgroundColor=this.out;
		this.style.color=this.fntout;
	}
	hideTimer=setTimeout("hideallsubmenu()",sleepTime);
}

function downmenuItem(){
	if(this.link) window.location.href=this.link;
}

function newLoad(){
   	if(ns4){
		if(startWidth==null || startHeight==null) return;
		if(startWidth!=innerWidth || startHeight!=innerHeight) location.reload();
	}	
	if(ie4){
		if(!isresized){
		    winW=document.body.clientWidth;
			winH=document.body.clientHeight;
			if(winW >= 780) startmainPosX = winW - ie_posX1024;
			if(winW <  780) startmainPosX = ie_posX800;
			diffPosX = startmainPosX - backup_startmainPosX;
			setnewPos();
			backup_startmainPosX = startmainPosX;
		}
		if(isresized) isresized=false
		else isresized=true;
	}
}

function setnewPos(){
	Mainmenuright.style.left=startmainPosX;
	for(i=0; i < subContainerCounter_right; i++){
		subContainer_right[i].style.left=parseInt(subContainer_right[i].style.left) + diffPosX;
	}
}
onresize=newLoad