var _ua = navigator.userAgent.toUpperCase();
var _mac = (_ua.indexOf("MAC") != -1) ? true : false;
var _o = (_ua.indexOf("OPERA") != -1) ? true : false;
var _ie = ((document.all&&!_o) ? true : false);



var path_root = null;
var path = window.location.href.replace(/(http:\/\/[^\/]*)(.*\/)([^\/]*)/i, '$2').toLowerCase();
var page_index = window.location.href.replace(/(http:\/\/[^\/]*)(.*)/i, '$2').toLowerCase();
var site_host = window.location.href.replace(/(http:\/\/[^\/]*)(.*)/i, '$1').toLowerCase();
var indexes = new Array('', 'index.php', 'default.asp', 'default.jsp', 'index.jsp', 'index.shtml');
var nav_selected = null, nav_cur = null;
var nav_selected2 = null, nav_cur2 = null;
var __nav2_timer;







var __nav_cover = null;
function setNavBG(x, y, w, h)
{
  var bAdd = false;

	if(!__nav_cover)
	{
		bAdd = true;
		__nav_cover = document.createElement("IFRAME");
		__nav_cover.style.display = "none";
	}

	__nav_cover.style.overflow = 'hidden';
	__nav_cover.style.zIndex = 1;

	__nav_cover.style.position = "absolute";
	__nav_cover.style.left = x + 'px';
	__nav_cover.style.top = y + 'px';
	__nav_cover.style.width = w + 'px';
	__nav_cover.style.height = h + 'px';

	__nav_cover.style.display = "block";


	if(bAdd)
	{
		document.body.appendChild(__nav_cover);
	}
}
function hideNavBG()
{
	if(__nav_cover)
	{
		__nav_cover.style.display = 'none';
	}
}








function init_nav()
{
  var oNav, oDiv, oLI, oUL, oA, i, j, k, k1, l, t, o, m, n, a;


	a = document.getElementsByTagName('H1');
	if(a)
	{
		l = a.length;
		for(j=0; j<l; j++)
		{
			a[j].onclick = function (){
				window.location = site_host;
			}
		}
	}	
	
	
	oNav = document.getElementById('nav');
	if(oNav)
	{
		oLI = oNav.getElementsByTagName('LI');
		if(oLI)
		{
			l = oLI.length;
			for(j=0; j<l; j++)
			{
				oA = oLI[j].getElementsByTagName('A');
				if(oA)
				{
					k = oA.length;
					for(i=0; i<k; i++)
					{
						t = (oA[i].href + '').replace(/(http:\/\/[^\/]*)([^\?#]*).*/i, '$2').toLowerCase();
						a = path.split('/');
						p = '/';

						for(n=1; n<a.length; n++)
						{
							p += a[n] + '/';
							for(m=0; m<indexes.length; m++)
							{

								if(t == p+indexes[m] || t == page_index)
								{

									oLI[j].id = 'current';
								}
							}
						}
					}

				}
			}
		}
	}

	oA = document.getElementsByTagName('A');
	if(oA)
	{
		k = oA.length;
		for(i=0; i<k; i++)
		{
			o = oA[i];
			t = o.href;
			j = t.indexOf('#');
			if(j>=0)
			{
				m = t.substr(j+1);
				a = m.split('x');
				if(a.length==2)
				{
					if(a[0])
					{
						o.href = 'javascript:ppopup("'+t.substr(0,j)+'",'+a[0]+','+a[1]+')';
						o.target = '_self';
					}
				}
			}

			if(o.className == 'opt')
			{
				o.href = 'javascript:ShowOpt("'+o.href+'")';
				o.target = '_self';
			}
		}
	}
}



addHook('OnWindowLoad', 'init_nav');



function ShowOpt(url)
{
	ShowPopup(url,270,150);
}

function ShowPopup(url, w, h)
{
	if(window.showModalDialog)
	{
		window.showModalDialog(url, "", "dialogWidth:"+w+"px;dialogHeight:"+h+"px;center:yes;edge:sunken;help:no;resizable:no;scroll:no;status:0;unadorned:1");
	}else{
		wpopup(url,w,h,1);
	}
}