
//SPECIAL FEATURE FOR HOTBANANA PATH
//for pages like news and partners where url contain arguments
//1: removing the folder name in the scriptname
var count=0;
while (count<1) {
	rel_url=rel_url.substring(rel_url.indexOf('/')+1,rel_url.length);
	count++;
} 
//2: removing the name of the page and all the arguments
if (rel_url.indexOf('index.cfm')>-1) {
	rel_url=rel_url.substring(0,rel_url.indexOf('index.cfm'));
}

var number_of_lvl=1; //MAX 4
function create_menu() {
	for (x=1; x<menu.length;x++) {
		if (menu[x][1]==rel_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++) {
			if (menu[x][3][y][1]==rel_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++) {
				if (menu[x][3][y][3][z][1]==rel_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++) {
					if (menu[x][3][y][3][z][3][z2][1]==rel_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%">';
	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 (s=1; s<menu.length;s++) {
		if (menu[s][2]!=0) {
			sel_exist=1;
			create_table(s,0,0,0);
			menus_mouseoverAction(s,0,0,0);	
			if (menu[s][3].length) {
				for (t=1; t<menu[s][3].length; t++) {
					if (menu[s][3][t][2]!=0) {
						create_table(s,t,0,0);
						menus_mouseoverAction(s,t,0,0);
						if (menu[s][3][t][3].length) {
							for (u=1; u<menu[s][3][t][3].length; u++) {
								if (menu[s][3][t][3][u][2]!=0) {
									create_table(s,t,u,0);
									menus_mouseoverAction(s,t,u,0);
									if (menu[s][3][t][3][u][3].length) {
										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); }
	refreshed=1;
}


function create_lvl(caller) {
	
	if (menu[0]==-1) {
		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 {
			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]!='') { 
				html+=' onclick="';
				html+="menus_onclickAction('"+tmp_array[x][1]+"')"; 
				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="img/'+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="img/'+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="img/'+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="img/'+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 menus_mouseoverAction(lvl1,lvl2,lvl3,lvl4) {

	//SPECIAL FEATURE FOR HOTBANANA
	allowed_lvl=1; 

	refreshed=0;
	
	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) {
	var y = x.toLowerCase();
	if (y.indexOf('http://') >=0 )
		document.location.href = x;
	else	
		document.location.href = doc_url+'/' + x;
}

function menu_array() {
	this[0]=0;
	this['content']=create_menu();
	this['containers']=create_containers();
	this['level1']=create_lvl('script');
}
var menu_process=new menu_array();