// Menu.js Novusolutions v1.0
// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Distribute this code, any part or any modified version of it.
//     Instead, you can link to the homepage of this code:
//     http://www.php-development.ru/javascripts/menu.php.
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as a part of another product provided that
//     its main use is not creating javascript menus.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind, either
// expressed or implied, including, but not limited to, the implied warranties
// of merchantability and fitness for a particular purpose. You expressly
// acknowledge and agree that use of this code is at your own risk.

// If you find my script useful, you can support my site in the following ways:
// 1. Vote for the script at HotScripts.com (you can do it on my site)
// 2. Link to the homepage of this script or to the homepage of my site:
//    http://www.php-development.ru/javascripts/menu.php
//    http://www.php-development.ru/
//    You will get 50% commission on all orders made by your referrals.
//    More information can be found here:
//    http://www.php-development.ru/affiliates.php


// ----- DropDown Control ------------------------------------------------------

// ----- Show Aux -----

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  //p.className = "active";
if(p.className=="topNav"){

p.style.background = "url(/media/10309/topnavcenter.png) repeat-x";

var pLeft = document.getElementById(parent + "l");
pLeft.src = "/media/10315/topnavleft.png";
var pRight = document.getElementById(parent + "r");
pRight.src = "/media/10321/topnavright.png";
}
 // var top  = (c["at_position"] == "y") ? p.offsetHeight-0 : 0;
 // var left = (c["at_position"] == "x") ? p.offsetWidth -200 : -200;
 var top  = (c["at_position"] == "y") ? p.offsetHeight + 6 : 0;
 var left = (c["at_position"] == "x") ? p.offsetWidth -200 : p.offsetLeft -8;

 /*for (; p; p = p.offsetParent)
  {
    if (p.style.position != 'absolute')
    {
      left += p.offsetLeft;
      top  += p.offsetTop;
    }
  }*/


  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Hide Aux -----

function at_hide_aux(parent, child)
{
  var p = document.getElementById(parent);
if(p.className == "topNav"){
p.style.background = "url(/media/10814/plaintne.png) repeat-x";
var pLeft = document.getElementById(parent + "l");
pLeft.src = "/media/10814/plaintne.png";
var pRight = document.getElementById(parent + "r");
pRight.src = "/media/10814/plaintne.png";
}
else
{
p.className="topNavSection";
p.style.background = "url(/media/10309/topnavcenter.png) repeat-x";
var pLeft = document.getElementById(parent + "l");
pLeft.src = "/media/10315/topnavleft.png";
var pRight = document.getElementById(parent + "r");
pRight.src = "/media/10321/topnavright.png";
}

  document.getElementById(child).style.visibility = "hidden";
}

// ----- Show -----

function at_show_p()
{
  c = document.getElementById(this["at_child" ]); 
  at_show_aux(this.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_show_c()
{
  p = document.getElementById(this["at_parent"]);

  at_show_aux(p.id, this.id);
  clearTimeout(this["at_timeout"]);
}

// ----- Hide -----

function at_hide_p()
{
  c = document.getElementById(this["at_child" ]);
  c["at_timeout"] = setTimeout("at_hide_aux('"+this.id+"', '"+c.id+"')", 300);
}

function at_hide_c()
{
  p = document.getElementById(this["at_parent"]);
  this["at_timeout"] = setTimeout("at_hide_aux('"+p.id+"', '"+this.id+"')", 300);
}

// ----- Attach -----

function at_attach(parent, child, position)
{
  p = document.getElementById(parent);
  c = document.getElementById(child);

  p["at_child"]    = c.id;
  c["at_parent"]   = p.id;
  c["at_position"] = position;

  p.onmouseover = at_show_p;
  p.onmouseout  = at_hide_p;
  c.onmouseover = at_show_c;
  c.onmouseout  = at_hide_c;
}

// ----- DropDown Menu ---------------------------------------------------------

// ----- Build Aux -----

function dhtmlmenu_build_aux(parent, child, position)
{
  if (parent != "")
  {
      document.write('<div class="vert_menu" id="'+parent+'_child">');

      n = 0;
      for (var i in child)
      {
var thisn = n;
        if (i == '-')
        {
          document.getElementById(parent).href = child[i];
          continue;
        }

        if (typeof child[i] == "object")
        {
          document.write('<a id="'+parent+'_'+thisn+'">'+i+'</a>');
          dhtmlmenu_build_aux(parent+'_'+thisn, child[i], "x");
        }
        else {
document.write('<a id="'+parent+'_'+thisn+'" href="'+child[i]+'">'+i+'</a>');
}
        n++;
      }

      document.write('</div>');

      at_attach(parent, parent+"_child", position);
    }
}

// ----- Build -----

function dhtmlmenu_build(menu)
{
  for (var i in menu) dhtmlmenu_build_aux(i, menu[i], "y");
}
/**************************************************************************
 *                                                                        *
 *  JAVASCRIPT MENU HIGHLIGHTER v.1.0 (051123)                            *
 * --------------------------------------------                           *
 * ©2005 Media Division (www.MediaDivision.com)                           *
 *                                                                        *
 * Written by Marius Smarandoiu & Armand Niculescu                        *
 *                                                                        *
 * You are free to use, modify and distribute this file, but please keep  *
 * this header and credits                                                *
 *                                                                        *
 * Usage:                                                                 *
 * - the script will apply the .current class to the <a> and its parent   *
 *   <li> that is contained in the element with id="primarynav" and points*
 *   to the current URL                                                   *
 * - works in IE6, Firefox and Opera                                      *
 **************************************************************************/
function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{
	for(var i=0; i < arr.length; i++)
		if(extractPageName(arr[i].href) == crtPage)
		{
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("nav")!=null) 
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
}