non_base_item_width='150px'
text_color='#000000'
text_color_hover='#000000'
bg_color='#6EDC65'
bg_color_hover='#50BF47'
border_color='#4F6F4D'
bg_color_hover_main='transparent'
bg_color_main='transparent'

from_body=false;
sp_table=new Array();
last_main_menu_item=null;
tables_array=null;
last_item=null;

/* -------------------- hide all (begin) ---------------- */
function hide_all(){
from_body=true

if(last_main_menu_item){
document.getElementById(last_main_menu_item).style.backgroundColor=bg_color_main
document.getElementById(last_main_menu_item).style.color=text_color

}



	if(!tables_array) return

	for (i in tables_array)
	{
		if((tables_array[i].id).split("-")[2]>0) 
		{
		document.getElementById(tables_array[i].id).style.display='none'

			if(document.getElementById(tables_array[i].id).style.backgroundImage)
			{
			document.getElementById(tables_array[i].id).style.backgroundImage='url(black_arrow.gif)'
			}
		}
		/* (mb) else
		{
		document.getElementById(tables_array[i].id).style.borderStyle='solid'
		document.getElementById(tables_array[i].id).style.borderWidth='1px'
		document.getElementById(tables_array[i].id).style.borderColor='#F3F3F3'
		document.getElementById(tables_array[i].id).style.backgroundColor='#F3F3F3'
		document.getElementById(tables_array[i].id).style.color='black'
		}*/
	}

//rendering bug in Opera begin
if(window.opera){
document.body.style.display='none'
document.body.style.display='block'
}
//rendering bug in Opera end

}
/* -------------------- hide all (end) ---------------- */







/* ------------------ attach event handlers (begin)---------------- */

function attach_ev(){

tables_array=new Array()
border_array=new Array()

//filtering tables which are menu items (begin) 
temp_tables_array=document.getElementsByTagName('span')

  for (i=0;i<temp_tables_array.length;i++)
  {
	if((temp_tables_array[i].id).indexOf("-")>-1)
	{
	tables_array[tables_array.length]=temp_tables_array[i]
	}
  }

//filtering tables which are menu items (end) 


  for (i in tables_array)
  {

	if((tables_array[i].id).split("-")[2]>0)
	{
	first_par=(tables_array[i].id).split("-")[0]
	second_par=(tables_array[i].id).split("-")[1]
	third_par=(tables_array[i].id).split("-")[2]
		
		if(border_array[first_par])
		{
		border_array[first_par]=parseInt(border_array[first_par])+1
		}
		else 
		{
		border_array[first_par]=1
		}


if(sp_table[first_par+'-00-'+third_par]){sp_table[first_par+'-00-'+third_par][sp_table[first_par+'-00-'+third_par].length]=tables_array[i].id}
else{
sp_table[first_par+'-00-'+third_par]=new Array();
sp_table[first_par+'-00-'+third_par][sp_table[first_par+'-00-'+third_par].length]=tables_array[i].id
}

	}

else{
if(window.opera){document.getElementById(tables_array[i].id).style.display='inline-table'}
}


  }//end of "for (i in tables array)"















//rendering border (begin)

nr_array=new Array()
for (i in tables_array){

  if((tables_array[i].id).split("-")[2]>0){

	first_par=(tables_array[i].id).split("-")[0]
//	second_par=(tables_array[i].id).split("-")[1]
	if(nr_array[first_par]){

	nr_array[first_par]=nr_array[first_par]+1

	}
	else {nr_array[first_par]=1}


	if(parseInt(border_array[first_par])>=nr_array[first_par]){
	document.getElementById(tables_array[i].id).style.borderRightStyle='solid'
	document.getElementById(tables_array[i].id).style.borderRightWidth='1px'
	document.getElementById(tables_array[i].id).style.borderRightColor=border_color

//	document.getElementById(tables_array[i].id).style.borderLeftStyle='solid'
//	document.getElementById(tables_array[i].id).style.borderLeftWidth='1px'
//	document.getElementById(tables_array[i].id).style.borderLeftColor=border_color
	}


	if(parseInt(border_array[first_par])==nr_array[first_par]){
	document.getElementById(tables_array[i].id).style.borderBottomStyle='solid'
	document.getElementById(tables_array[i].id).style.borderBottomWidth='1px'
	document.getElementById(tables_array[i].id).style.borderBottomColor=border_color
	}


	if(nr_array[first_par]==1){
	document.getElementById(tables_array[i].id).style.borderTopStyle='solid'
	document.getElementById(tables_array[i].id).style.borderTopWidth='0px'
//	document.getElementById(tables_array[i].id).style.borderTopColor=border_color
	}
  }

}

//rendering border (end)











//ataching events



for (i in tables_array)
{
//attaching events to menu items in depth>0 (begin)
   if((tables_array[i].id).split("-")[2]>0) 
   {
           if(document.all)
	   {
		document.getElementById(tables_array[i].id).onmouseover=function(){
			event.cancelBubble=true;
			if(this.id==last_item) return


			hide(this.id)	

			item_top=this.offsetTop;
			item_left=this.offsetLeft;
			item_width=this.offsetWidth;
			item_height=this.offsetHeight;

			child_items=(this.id).split("-")[1]
	
			first_par_ef=(this.id).split("-")[0]
			second_par_ef=(this.id).split("-")[1]
			third_par_ef=parseInt((this.id).split("-")[2])+1

			height_correction=0
			
			soot=second_par_ef+'-00-'+third_par_ef



			if(typeof(sp_table[soot])=="object")
			{

				for(i in sp_table[soot])
				{
				document.getElementById(sp_table[soot][i]).style.position='absolute'
																		document.getElementById(sp_table[soot][i]).style.top=item_top+height_correction+'px'
				document.getElementById(sp_table[soot][i]).style.left=item_left+item_width+'px'
				document.getElementById(sp_table[soot][i]).style.width=non_base_item_width
				document.getElementById(sp_table[soot][i]).style.display='block'
				last_item_height=document.getElementById(sp_table[soot][i]).offsetHeight
				height_correction+=last_item_height
				}
		        }
		        this.style.backgroundColor=bg_color_hover;
		        this.style.color=text_color_hover;

			if(this.style.backgroundImage){this.style.backgroundImage='url(hover_arrow.gif)'}
			
			if(last_item.split("-")[2]==(this.id).split("-")[2]){
			document.getElementById(last_item).style.backgroundColor=bg_color
			document.getElementById(last_item).style.color=text_color

			if(document.getElementById(last_item).style.backgroundImage){
			document.getElementById(last_item).style.backgroundImage='url(black_arrow.gif)'
			}

			}


//rendering bug in Opera begin
if(window.opera){
document.body.style.display='none'
document.body.style.display='block'
}
//rendering bug in Opera end

		last_item=this.id
		}//end of mouseover function

	   }//end of if(document.all)

	  else //if(!document.all)
	  {
	  document.getElementById(tables_array[i].id).addEventListener("mouseover",over_non_base,false)		
  	  }

}  //attaching events to menu items in depth>0 (end)























//attaching events to menu items in depth==0 (begin)
else 
    {
     if(document.all) 		
		{
		document.getElementById(tables_array[i].id).onmouseover=function(){
		event.cancelBubble=true;
		
		if(last_main_menu_item && (this.id==last_main_menu_item) && !from_body) return
		from_body=false

		hide(this.id)	

		item_top=this.offsetTop;
		item_left=this.offsetLeft;
		item_width=this.offsetWidth;
		item_height=this.offsetHeight;

		child_items=(this.id).split("-")[1]

		first_par_ef=(this.id).split("-")[0]
		second_par_ef=(this.id).split("-")[1]
		third_par_ef=parseInt((this.id).split("-")[2])+1

		soot=second_par_ef+'-00-'+third_par_ef


		if(typeof(sp_table[soot])=="object")
		{
			height_correction=0
			for(i in sp_table[soot])
			{
											document.getElementById(sp_table[soot][i]).style.position='absolute'
			document.getElementById(sp_table[soot][i]).style.top=item_top+item_height+height_correction+'px'
			document.getElementById(sp_table[soot][i]).style.left=item_left-12+'px'
			document.getElementById(sp_table[soot][i]).style.width=non_base_item_width
			document.getElementById(sp_table[soot][i]).style.display='block'
									last_item_height=document.getElementById(sp_table[soot][i]).offsetHeight
			height_correction+=last_item_height


			}
		}

		if(last_main_menu_item){
		document.getElementById(last_main_menu_item).style.backgroundColor=bg_color_main
		document.getElementById(last_main_menu_item).style.color=text_color

		if(document.getElementById(last_main_menu_item).style.backgroundImage){
			document.getElementById(last_main_menu_item).style.backgroundImage='url(black_arrow.gif)'}


		/*(mb )document.getElementById(last_main_menu_item).style.borderStyle='solid'
		document.getElementById(last_main_menu_item).style.borderWidth='1px'
		document.getElementById(last_main_menu_item).style.borderColor='#F3F3F3'
		document.getElementById(last_main_menu_item).style.backgroundColor='#F3F3F3'
		document.getElementById(last_main_menu_item).style.color='black'*/

		}


		
/*(mb)
		document.getElementById(this.id).style.borderStyle='solid'
		document.getElementById(this.id).style.borderWidth='1px'
		document.getElementById(this.id).style.borderColor='#006B42'
		document.getElementById(this.id).style.backgroundColor='#E2E2E2'
		document.getElementById(this.id).style.color='#F26522'
*/
		this.style.backgroundColor=bg_color_hover_main;
		this.style.color=text_color_hover;


		if(this.style.backgroundImage){this.style.backgroundImage='url(hover_arrow.gif)'}

//rendering bug in Opera begin
if(window.opera){
document.body.style.display='none'
document.body.style.display='block'
}
//rendering bug in Opera end


		last_main_menu_item=this.id

     	        last_item=this.id
		}//end of mouseover function

	   }//end of if(document.all)

     else
	{
	document.getElementById(tables_array[i].id).addEventListener("mouseover",over_base,false)
	}

      } //end of else - attaching events to menu items in depth==0 (end)
 }//end of for loop
}//end of attach_ev() function
/* ------------------ attach event handlers (end)---------------- */










function over_non_base(e){

		e.stopPropagation()
		if(this.id==last_item) return
		hide(this.id)	

		item_top=this.offsetTop;
		item_left=this.offsetLeft;
		item_width=this.offsetWidth;
		item_height=this.offsetHeight;

		child_items=(this.id).split("-")[1]

		first_par_ef=(this.id).split("-")[0]
		second_par_ef=(this.id).split("-")[1]
		third_par_ef=parseInt((this.id).split("-")[2])+1

		height_correction=0

		soot=second_par_ef+'-00-'+third_par_ef


	     	for(i in sp_table[soot])
		{
		document.getElementById(sp_table[soot][i]).style.position='absolute'
		document.getElementById(sp_table[soot][i]).style.top=item_top+height_correction+'px'
		document.getElementById(sp_table[soot][i]).style.left=item_left+item_width+'px'
		document.getElementById(sp_table[soot][i]).style.width=non_base_item_width
		document.getElementById(sp_table[soot][i]).style.display='block'
		last_item_height=document.getElementById(sp_table[soot][i]).offsetHeight
		height_correction+=last_item_height	
		}

		this.style.backgroundColor=bg_color_hover;
		this.style.color=text_color_hover;


		if(this.style.backgroundImage){
		this.style.backgroundImage='url(hover_arrow.gif)'
		}

		if(last_item.split("-")[2]==(this.id).split("-")[2])
		{
		document.getElementById(last_item).style.backgroundColor=bg_color
		document.getElementById(last_item).style.color=text_color


		if(document.getElementById(last_item).style.backgroundImage){
		document.getElementById(last_item).style.backgroundImage='url(black_arrow.gif)'
		}

		}

		last_item=this.id
}//end of over_non_base


















function over_base(e){
		e.stopPropagation()
//		if(this.id==last_item) return

		if(last_main_menu_item && (this.id==last_main_menu_item) && !from_body) return
		from_body=false


		hide(this.id)	




		item_top=this.offsetTop;
		item_left=this.offsetLeft;
		item_width=this.offsetWidth;
		item_height=this.offsetHeight;

		child_items=(this.id).split("-")[1]

		first_par_ef=(this.id).split("-")[0]
		second_par_ef=(this.id).split("-")[1]
		third_par_ef=parseInt((this.id).split("-")[2])+1
		height_correction=0

		soot=second_par_ef+'-00-'+third_par_ef

		   for(i in sp_table[soot])
	   	   {
		   document.getElementById(sp_table[soot][i]).style.position='absolute'
		   document.getElementById(sp_table[soot][i]).style.top=item_top+item_height+height_correction+'px'
		   document.getElementById(sp_table[soot][i]).style.left=item_left-12+'px'
		   document.getElementById(sp_table[soot][i]).style.width=non_base_item_width
		   document.getElementById(sp_table[soot][i]).style.display='block'
		   last_item_height=document.getElementById(sp_table[soot][i]).offsetHeight
		   height_correction+=last_item_height

		}
		
		if(last_main_menu_item){

		document.getElementById(last_main_menu_item).style.backgroundColor=bg_color_main
		document.getElementById(last_main_menu_item).style.color=text_color


		if(document.getElementById(last_main_menu_item).style.backgroundImage){
		document.getElementById(last_main_menu_item).style.backgroundImage='url(black_arrow.gif)'}


/* (mb)
		document.getElementById(last_main_menu_item).style.borderStyle='solid'
		document.getElementById(last_main_menu_item).style.borderWidth='1px'
		document.getElementById(last_main_menu_item).style.borderColor='#F3F3F3'
		document.getElementById(last_main_menu_item).style.backgroundColor='#F3F3F3'
		document.getElementById(last_main_menu_item).style.color='black'*/
		}

		/* (mb)document.getElementById(this.id).style.borderStyle='solid'
		document.getElementById(this.id).style.borderWidth='1px'
		document.getElementById(this.id).style.borderColor='#006B42'
		document.getElementById(this.id).style.backgroundColor='#E2E2E2'
		document.getElementById(this.id).style.color='#F26522'*/


		this.style.backgroundColor=bg_color_hover_main;
		this.style.color=text_color_hover;
		if(this.style.backgroundImage){this.style.backgroundImage='url(hover_arrow.gif)'}

		last_main_menu_item=this.id

   	        last_item=this.id
}



















/* -------------------------------- hide begin  -------------------------------- */
function hide(item){

	if (last_item)
		      {
		      current_depth=item.split("-")[2]
		      last_item_depth=last_item.split("-")[2]

 		      /* -- hiding if event comes from same depth as last item begin-- */
				if(current_depth==last_item_depth)
				{
				//get 2nd id from last items child
				last_item_child=last_item.split("-")[1]
				last_item_child_depth=parseInt(current_depth)+1
					//
					soothide=last_item_child+'-00-'+last_item_child_depth
					//alert(soothide)
					if(typeof(sp_table[soothide])=="object") 
					{
						for (i in sp_table[soothide])
						{
						document.getElementById(sp_table[soothide][i]).style.display='none'					
						}
					
					}
					//
					/*for (i in tables_array)
					{
		   			loop_parent_child_array=(tables_array[i].id).split("-")
					loop_current_table_parent=loop_parent_child_array[0]
						if (last_item_child==loop_current_table_parent) 
						{
						document.getElementById(tables_array[i].id).style.display='none'
						}
   					}*/
				}//no lower l
/* -- hiding if event comes from same depth as last item end -- */


/* -- hiding if event comes from lower depth begin -- */
		from_child_to_parent=(last_item.split("-")[0]==item.split("-")[1]) 

		if(current_depth<last_item_depth  && !from_child_to_parent)
		{
		//
		
		for (i in sp_table)
		{
		
		curr_loop_depth=sp_table[i][0].split("-")[2]
			if(current_depth<curr_loop_depth)
			{

				for(j in sp_table[i])
				{
				
				document.getElementById(sp_table[i][j]).style.display='none'
				document.getElementById(sp_table[i][j]).style.backgroundColor=bg_color
				document.getElementById(sp_table[i][j]).style.color=text_color

					if(document.getElementById(sp_table[i][j]).style.backgroundImage)
					{
			      		document.getElementById(sp_table[i][j]).style.backgroundImage='url(black_arrow.gif)'
					}
				}
			}

			if(current_depth==curr_loop_depth && current_depth>0)
			{
				for(j in sp_table[i])
				{
				document.getElementById(sp_table[i][j]).style.backgroundColor=bg_color
				document.getElementById(sp_table[i][j]).style.color=text_color

					if(document.getElementById(sp_table[i][j]).style.backgroundImage)
					{
			      		document.getElementById(sp_table[i][j]).style.backgroundImage='url(black_arrow.gif)'
					}
				}
			}
	}		
		}//no lower level end of saved2


		if(from_child_to_parent)
		{
//
			for (i in sp_table)
			{

			curr_loop_depth=sp_table[i][0].split("-")[2]

				if(current_depth==(curr_loop_depth-2))
				{
					for(j in sp_table[i])
					{
					document.getElementById(sp_table[i][j]).style.display='none'
					}
				}
			}
//
			/*for (i in tables_array) 
			{
				loop_parent_child_array=(tables_array[i].id).split("-")
				loop_current_table_depth=loop_parent_child_array[2]
					if (current_depth==loop_current_table_depth-2) 
					{
					document.getElementById(tables_array[i].id).style.display='none'
					}
			}*/

	      	document.getElementById(last_item).style.backgroundColor=bg_color
	      	document.getElementById(last_item).style.color=text_color

			if(document.getElementById(last_item).style.backgroundImage)
			{
			document.getElementById(last_item).style.backgroundImage='url(black_arrow.gif)'
			}

			/*if(document.getElementById(tables_array[i].id).style.backgroundImage)
			{
			document.getElementById(tables_array[i].id).style.backgroundImage='url(black_arrow.gif)'
			}*/
	   }//no lower level

/* -- hiding if event comes from lower depth end -- */
}//end of "if(last item)"


}//end of function hide()
/* -------------------------------- hide end  -------------------------------- */




