//var doc_url='0123456789abcdef';

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_preloadImages_launcher() {
	arg='';
	for (x=1;x<menu_design.length; x++) {
		arg+="'"+menu_design[x][7]+"TopLeft.gif',";
		arg+="'"+menu_design[x][7]+"TopRight.gif',";
		arg+="'"+menu_design[x][7]+"BotttomLeft.gif',";
		arg+="'"+menu_design[x][7]+"BotttomRight.gif',";
		arg+="'"+menu_design[x][8]+"'";
		if (x<menu_design.length-1) { arg+=','; }}
	MM_preloadImages(arg);
}

if ( menu_design[0][12]==1 ) {
	//doc_url=document.location.href;
	//doc_url=doc_url.substring(doc_url.indexOf(menu_design[0][13])+menu_design[0][13].length, doc_url.length);
	if (doc_url.indexOf('?lang=')>-1) {doc_url=doc_url.substring(0,doc_url.indexOf('?lang='))+doc_url.substring(doc_url.indexOf('?lang=')+8,doc_url.length);}
	if (doc_url.indexOf('&lang=')>-1) {doc_url=doc_url.substring(0,doc_url.indexOf('&lang='))+doc_url.substring(doc_url.indexOf('&lang=')+8,doc_url.length);}
	if (doc_url=='') {doc_url='0123456789abcdef';}
	
	//SPECIAL FEATURE FOR ANSELL CORP
	if (doc_url.indexOf('catalogue=!')>-1) {
		if (doc_url.indexOf('catalogue=!0')<0) {
		temp_url=doc_url.substring((doc_url.indexOf('catalogue=!')+11),doc_url.length);
		temp_url=temp_url.substring(temp_url.indexOf('!'),temp_url.length);
		doc_url=doc_url.substring(0,(doc_url.indexOf('catalogue=!')+11))+'0'+temp_url;
		}
	}
	if (doc_url.indexOf('&I=')>-1) {
		doc_url=doc_url.substring(0,doc_url.indexOf('&I='));
	}	
}
var number_of_lvl=1; //MAX 4
function create_menu() {
	for (x=1; x<menu.length;x++) {
		
		for (n=1; n<trad.length; n++) {if (trad[n][0]==menu[x][0]) { menu[x][0]=trad[n][1]; break;}}
		if (menu[x][1]==doc_url) { menu[x][2]=1; }
		if (menu[x][3]!=0) {
			if (number_of_lvl<2) { number_of_lvl=2; }
			tmp=new Array();
			tmp=tmp.concat(eval('menu_'+x));
			menu[x][3]=tmp;
		}
		for (y=1; y<menu[x][3].length; y++) {
		
			for (n=1; n<trad.length; n++) {if (trad[n][0]==menu[x][3][y][0]) { menu[x][3][y][0]=trad[n][1]; break;}}
			if (menu[x][3][y][1]==doc_url) { 
				menu[x][2]=1;menu[x][3][y][2]=1;}
			if (menu[x][3][y][3]!=0) {
				if (number_of_lvl<3) { number_of_lvl=3; }
				tmp=new Array();
				tmp=tmp.concat(eval('menu_'+x+'_'+y));
				menu[x][3][y][3]=tmp;
			}
			for (z=1; z<menu[x][3][y][3].length; z++) {
				
				for (n=1; n<trad.length; n++) {if (trad[n][0]==menu[x][3][y][3][z][0]) { menu[x][3][y][3][z][0]=trad[n][1]; break;}}
				if (menu[x][3][y][3][z][1]==doc_url) { 
					menu[x][2]=1;menu[x][3][y][2]=1;menu[x][3][y][3][z][2]=1;}
				if (menu[x][3][y][3][z][3]!=0) {
					if (number_of_lvl<4) { number_of_lvl=4; }
					tmp=new Array();
					tmp=tmp.concat(eval('menu_'+x+'_'+y+'_'+z));
					menu[x][3][y][3][z][3]=tmp;				
				}
				for (z2=1; z2<menu[x][3][y][3][z][3].length; z2++) {
					for (n=1; n<trad.length; n++) {if (trad[n][0]==menu[x][3][y][3][z][3][z2][0]) { menu[x][3][y][3][z][3][z2][0]=trad[n][1]; break;}}
					if (menu[x][3][y][3][z][3][z2][1]==doc_url) { 
						menu[x][2]=1; menu[x][3][y][2]=1; menu[x][3][y][3][z][2]=1; menu[x][3][y][3][z][3][z2][2]=1; }
				}
			}		
		}
	}
}

function create_containers() {
	html='<div style="position:absolute; top:'+menu_design[0][0]+'px; left:'+menu_design[0][1]+'px; width:100%; z-index:100">';
	html+='<table width="'+menu_design[0][10]+'" border="0" cellspacing="0" cellpadding="0" bgcolor="#'+menu_design[0][4]+'"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td>';
	
	if (menu_design[0][6]>0) { html+='<td bgcolor="#'+menu_design[0][7]+'"><img src="img/spacer.gif" width="'+menu_design[0][6]+'" height="1"></td>';	}
	if (menu_design[0][8]>0) { html+='<td bgcolor="#'+menu_design[0][9]+'"><img src="img/spacer.gif" width="'+menu_design[0][8]+'" height="1"></td>';	}

	html+='<td><table width="'+menu_design[0][2]+'" border="0" cellspacing="0" cellpadding="0"><tr>';
	
	html+='<td><img src="img/spacer.gif" width="'+menu_design[0][5]+'" height="'+menu_design[0][5]+'"></td>';
	html+='<td><img src="img/spacer.gif" width="'+(menu_design[0][2]-(menu_design[0][5]*2))+'" height="'+menu_design[0][5]+'"></td>';
	html+='<td><img src="img/spacer.gif" width="'+menu_design[0][5]+'" height="'+menu_design[0][5]+'"></td>';
	html+='</tr><tr>';
	html+='<td><img src="img/spacer.gif" width="'+menu_design[0][5]+'" height="'+menu_design[0][5]+'"></td><td>';
	for (x=1; x<=number_of_lvl;x++) {
		if (x!=1) { html+='<div><img src="img/spacer.gif" width="'+menu_design[0][5]+'" height="'+menu_design[0][5]+'"></div>'; }
		html+='<div id="lvl_'+x+'"></div>';	
	}
	html+='</td><td><img src="img/spacer.gif" width="'+menu_design[0][5]+'" height="'+menu_design[0][5]+'"></td>';
	html+='</tr><tr>';
	html+='<td colspan="3"><img src="img/spacer.gif" width="'+menu_design[0][5]+'" height="'+menu_design[0][5]+'"></td>';
	html+='</tr></table></td>';
	html+='</tr></table></td>';
	html+='</td></tr></table>';
	html+='</div>';
	document.getElementById('containers').innerHTML=html;
}	

var refreshed=0;

function expansion() {
	sel_exist=0;
	for (x=2; x<=number_of_lvl;x++) { document.getElementById('lvl_'+x).innerHTML='<img src="img/spacer.gif" width="1" height="1">'; }
	for (s=1; s<menu.length;s++) {
		if (menu[s][2]!=0) {
			sel_exist=1;
			menus_mouseoverAction(s,0,0,0);	
			if (menu[s][3].length) {
				create_table(s,0,0,0);
				for (t=1; t<menu[s][3].length; t++) {
					if (menu[s][3][t][2]!=0) {
						menus_mouseoverAction(s,t,0,0);
						if (menu[s][3][t][3].length) {
							create_table(s,t,0,0);
							for (u=1; u<menu[s][3][t][3].length; u++) {
								if (menu[s][3][t][3][u][2]!=0) {
									menus_mouseoverAction(s,t,u,0);
									if (menu[s][3][t][3][u][3].length) {
										create_table(s,t,u,0);
										for (v=1; v<menu[s][3][t][3][u][3].length; v++) {
											if (menu[s][3][t][3][u][3][v][2]!=0) {
												menus_mouseoverAction(s,t,u,v);
	}	}	}	}	}	}	}	}	}	}	}
	if (sel_exist==0) { create_table(0,0,0,0); }
	new additional_out();
	refreshed=1;
}


function create_lvl() {
	
	if (menu[0]==-1) {
		new additional_out();
		create_table(0,0,0,0);
		menu[0]=0;
		if (menu_design[0][11]!=0) { expansion(); }
		refreshed=1;
	}
	else if (refreshed!=1) {
		
		if (menu_design[0][11]!=0) {
			expansion();
		}
		else {
			new additional_out();
			for (x=2; x<=number_of_lvl;x++) { document.getElementById('lvl_'+x).innerHTML='<img src="img/spacer.gif" width="1" height="1">'; } 
			if (menu[menu[0]][2]!=0) {
				document.getElementById('table_'+menu[0]+'_0_0_0').style.background='#'+menu_design[1][2];
				document.getElementById('table_'+menu[0]+'_0_0_0').className=menu_design[1][5];
			} else {
				document.getElementById('table_'+menu[0]+'_0_0_0').style.background='#'+menu_design[1][1];
				document.getElementById('table_'+menu[0]+'_0_0_0').className=menu_design[1][4];
			}
			menu[0]=0;
		}
		refreshed=1;
	}
}

function delete_table(lvl1,lvl2,lvl3,lvl4) {

	if (lvl1!=0) {
		if (menu[0]!=lvl1) {
			for (x=2; x<=number_of_lvl;x++) { document.getElementById('lvl_'+x).innerHTML='<img src="img/spacer.gif" width="1" height="1">'; }
					
		}
		else if (lvl2!=0) { 
			if (menu[lvl1][3][0]!=lvl2) {
				for (x=3; x<=number_of_lvl;x++) { document.getElementById('lvl_'+x).innerHTML='<img src="img/spacer.gif" width="1" height="1">'; }
			}
			else if (lvl3!=0) {
				if (menu[lvl1][3][lvl2][3][0]!=lvl3) {
				for (x=4; x<=number_of_lvl;x++) { document.getElementById('lvl_'+x).innerHTML='<img src="img/spacer.gif" width="1" height="1">'; }
				}			
			}
		}
	}
}

function create_table(lvl1,lvl2,lvl3,lvl4) { 

	delete_table(lvl1,lvl2,lvl3,lvl4);

	var tmp_array=new Array();
	if ((lvl1==0)&&(lvl2==0)&&(lvl3==0)) { 
		tmp_array=menu;
		for (x=2; x<=number_of_lvl;x++) { document.getElementById('lvl_'+x).innerHTML='<img src="img/spacer.gif" width="1" height="1">'; } 
		lvl_sel=1;}
	if ((lvl1!=0)&&(lvl2==0)&&(lvl3==0)) { 
		tmp_array=menu[lvl1][3]; 
		lvl_sel=2;}
	if ((lvl1!=0)&&(lvl2!=0)&&(lvl3==0)) { 
		tmp_array=menu[lvl1][3][lvl2][3]; 
		lvl_sel=3;}
	if ((lvl1!=0)&&(lvl2!=0)&&(lvl3!=0)) { 
		tmp_array=menu[lvl1][3][lvl2][3][lvl3][3]; 
		lvl_sel=4;}	
	
	html='';
	
	var table_width='100%';
	var cell_size='100%';
	
	if (tmp_array[1][4]!=0) {
		table_width='';
	}
	
	if (tmp_array!=0) {
	
		html='<table width="'+table_width+'" border="0" cellspacing="0" cellpadding="0"><tr>';
		
		for (x=1; x<tmp_array.length; x++) {
			
			if (x!=1) { html+='<td width="5"><img src="img/spacer.gif" width="5" height="5"></td>'; }
			
			html+='<td valign="top"><table class="';
			
			if (tmp_array[x][2]==0) { html+=menu_design[lvl_sel][4]; }
			else { html+=menu_design[lvl_sel][5]; }
					
			if (table_width=='') { cell_size=tmp_array[x][4]; }
			html+='" width="'+cell_size+'" border="0" cellspacing="0" cellpadding="0" style="background:#';
			
			if (tmp_array[x][2]==0) { html+=menu_design[lvl_sel][1]; }
			else { html+=menu_design[lvl_sel][2	]; }
			
			html+='; cursor:pointer"';
			
			if (tmp_array[x][1]!='') { 
				lang='';
				if (tmp_array[x][1].indexOf('?')>-1) {lang="&lang="+language;}
				else if (tmp_array[x][1].indexOf('http://')<0) {lang="?lang="+language;}
				html+=' onclick="';
				html+="menus_onclickAction('"+tmp_array[x][1]+lang+"')"; 
				html+='"';
				}
			
			html+=' onMouseOver="';

			if (lvl_sel==1) { a=x; b=0; c=0; d=0; }
			if (lvl_sel==2) { a=lvl1; b=x; c=0; d=0; }
			if (lvl_sel==3) { a=lvl1; b=lvl2; c=x; d=0; }
			if (lvl_sel==4) { a=lvl1; b=lvl2; c=lvl3; d=x; }
			
			if (tmp_array[x][3]!=0) {
				html+="create_table(";
				html+=a+','+b+','+c+','+d ;
				html+="); ";
			}
			else {
				html+="delete_table(";
				html+=a+','+b+','+c+','+d ;
				html+="); ";
			}
			
			html+="menus_mouseoverAction("+a+","+b+","+c+","+d+"); ";
			
			html+='"';
			
			html+=' id="table_';
			
			html+=a+"_"+b+"_"+c+"_"+d;
			
			html+='"><tr><td width="5"><img src="'+menu_design[lvl_sel][7]+'TopLeft.gif" width="5" height="5"></td><td ><img src="img/spacer.gif" width="5" height="5"></td><td width="5"><img src="'+menu_design[lvl_sel][7]+'TopRight.gif" width="5" height="5"></td></tr><tr><td width="5" ><img src="img/spacer.gif" width="5" height="15"></td><td align="';
			if (tmp_array[x][5]=='') { html+=menu_design[lvl_sel][9]; }
			else { html+=tmp_array[x][5]; }
			html+='">';

			html+=tmp_array[x][0];
			if (tmp_array[x][3]!=0) { 
				html+='&nbsp;<img src="'+menu_design[lvl_sel][8]+'">'; }
			
			html+='</td><td width="5" ><img src="img/spacer.gif" width="5" height="5"></td></tr><tr><td width="5"><img src="'+menu_design[lvl_sel][7]+'BottomLeft.gif" width="5" height="5"></td><td ><img src="img/spacer.gif" width="5" height="5"></td><td width="5"><img src="'+menu_design[lvl_sel][7]+'BottomRight.gif" width="5" height="5"></td></tr></table></td>';
		}
		html+='</tr></table>';
	
	}
	
	document.getElementById('lvl_'+lvl_sel).innerHTML=html;
}


function menu_array() {
	this[0]=0;
	this['preloading']=MM_preloadImages_launcher();
	this['content']=create_menu();
	this['containers']=create_containers();
	this['level1']=create_lvl();
}
var menu_process=new menu_array();



function menus_mouseoverAction(lvl1,lvl2,lvl3,lvl4) {

	refreshed=0;
	
	new additional_in();
	
	a=0;
	b=0;
	c=0;
	d=0;
	
	niv=0;
	selected=0;
	niv_old=0;
	selected_old=0;
	
	if (lvl1!=0) {
		niv++;
		niv_old++;
		a=menu[0];
		if (menu[lvl1][2]==1) { selected=1; }
		if (menu[a][2]==1) { selected_old=1; }
		menu[0]=lvl1;
	}
	if (lvl2!=0) {
		niv++; 
		b=menu[lvl1][3][0];
		if (b!=0) {niv_old++;}
		if (menu[lvl1][3][lvl2][2]==1) { selected=1; } else { selected=0; }
		if (menu[lvl1][3][b][2]==1) { selected_old=1; } else { selected_old=0; }
		menu[lvl1][3][0]=lvl2;
	}
	if (lvl3!=0) {
		niv++; 
		c=menu[lvl1][3][lvl2][3][0];
		if (c!=0) {niv_old++;}
		if (menu[lvl1][3][lvl2][3][lvl3][2]==1) { selected=1; } else { selected=0; }
		if (menu[lvl1][3][lvl2][3][c][2]==1) { selected_old=1; } else { selected_old=0; }
		menu[lvl1][3][lvl2][3][0]=lvl3;
	}
	if (lvl4!=0) {
		niv++; 
		d=menu[lvl1][3][lvl2][3][lvl3][3][0];
		if (d!=0) {niv_old++;}
		if (menu[lvl1][3][lvl2][3][lvl3][3][lvl4][2]==1) { selected=1; } else { selected=0; }
		if (menu[lvl1][3][lvl2][3][lvl3][3][d][2]==1) { selected_old=1; } else { selected_old=0; }
		menu[lvl1][3][lvl2][3][lvl3][3][0]=lvl4;
	}
	
	if ((a>0)&&(niv==niv_old)) {		
		document.getElementById('table_'+a+'_'+b+'_'+c+'_'+d).style.background='#'+menu_design[niv][1+selected_old]; 
		document.getElementById('table_'+a+'_'+b+'_'+c+'_'+d).className=menu_design[niv][4+selected_old];
	}
	if (selected!=1) {
		document.getElementById('table_'+lvl1+'_'+lvl2+'_'+lvl3+'_'+lvl4).className=menu_design[niv][6];
		document.getElementById('table_'+lvl1+'_'+lvl2+'_'+lvl3+'_'+lvl4).style.background='#'+menu_design[niv][3];}
	else {
		document.getElementById('table_'+lvl1+'_'+lvl2+'_'+lvl3+'_'+lvl4).style.background='#'+menu_design[niv][2];
	}
}

function menus_onclickAction(x) {
	document.location.href=x;
}