ua = navigator.userAgent.toLowerCase();

if (ua.indexOf('msie') != -1 && parseInt(navigator.appVersion) >= 4)  // IE4 up
{
document.write("<link rel='stylesheet' type='text/css' href='images/style.css'>");
}
if (ua.indexOf('gecko') != -1){                                     // Gecko
document.write("<link rel='stylesheet' type='text/css' href='images/style.css'>");
}
if (ua.indexOf('konqueror') != -1){                                 // Konquerer
document.write("<link rel='stylesheet' type='text/css' href='images/style.css'>");
}
if (window.opera){                                                  // Opera
document.write("<link rel='stylesheet' type='text/css' href='images/opera.css'>");
}

var autoHideTimer = 0;
var autoHideTimer3 = 0;
var timeBeforeAutoHide = 500;
var currentEl;
var q;
var q3;
var elem = new Array(10);
var elem3 = new Array(10);


function getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null)
	{
	  returnValue += inputObj.offsetTop;
	}
  return returnValue;
}

function getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null) returnValue += inputObj.offsetLeft;
  return returnValue;
}

function setWidth(el, w)
{
	whichEl = eval(el);
	whichEl.style.width = w;
}

function clearCoord()
{
	cvar = document.all["shg"];
	cvar.value='';
	cvar = document.all["shm"];
	cvar.value='';
	cvar = document.all["dlg"];
	cvar.value='';
	cvar = document.all["dlm"];
	cvar.value='';
}



function showHr(el)
{
	whichHr = eval("hr2");
	ParentEl = document.all["tm" + el];
	whichHr.style.top = getTopPos(ParentEl)+ParentEl.offsetHeight;
	whichHr.style.left = getLeftPos(ParentEl);
//	alert(el);
//	alert(whichHr.style.top);
	whichHr.style.width = 94;
	whichHr.style.display = "block";
}

function hideHr(el)
{
	whichHr = eval("hr2");
	whichHr.style.display = "none";
}

function regCity(reg)
{
	window.open('cityselect.php?reg=' + reg, 'city', 'resizable, yes - scrollbars, width=400, height=400').focus();
}

function chrCity(chr)
{
	window.open('cityselect.php?letter=' + chr, 'city', 'resizable, yes - scrollbars, width=400, height=400').focus();
}

function expandIE(el, qq)
{
	q=qq;
	currentEl = el;
	whichEl = eval("sm" + el);
	ParentEl = eval("m" + el);
	whichEl.style.top = getTopPos(ParentEl);
	whichEl.style.left = getLeftPos(ParentEl)+ParentEl.offsetWidth-20;
    if (whichEl.style.display == "block") initAutoHide(el);
    else
	{
		var i=0;
		elem[el]=1
		for (i=0;i<q;i++) 
			if (el!=i)
				document.all["sm" + i].style.display = "none";
			else
				document.all["sm" + i].style.display = "block";
	}
}

function expandIE3(el, pl, qq)
{
	q3=qq;
	currentEl = el;
	whichEl = eval("sm3_" + el);
	RowEl = eval("sr" + el);
	ParentEl = eval("sm" + pl);

	whichEl.style.top = getTopPos(RowEl);

	whichEl.style.left = getLeftPos(ParentEl)+ParentEl.offsetWidth-20;

	stopAutoHide(pl);

	if (whichEl.style.display == "block") initAutoHide3(el);
    else
	{
		var i=0;
		elem3[el]=1
		for (i=0;i<q3;i++) 
			if (el!=m3a[i])
				document.all["sm3_" + m3a[i]].style.display = "none";
			else
				document.all["sm3_" + m3a[i]].style.display = "block";
	}
}

function stopAutoHide(el)
{
	var i;
	for (i=0;i<q;i++) elem[i]=0;
	elem[el]=1;
	autoHideTimer = -1;
}

function initAutoHide(el)
{
	elem[el]=0;
	autoHideTimer = 0;
	autoHide();
}

function stopAutoHide3(el)
{
	var i;
	for (i=0;i<q3;i++) elem3[i]=0;
	elem3[el]=1;
	autoHideTimer3 = -1;
	stopAutoHide(el);
}

function initAutoHide3(el)
{
	elem3[el]=0;
	autoHideTimer3 = 0;
	autoHide3();
}

function autoHide()
{
	var i;
	
	if(autoHideTimer>timeBeforeAutoHide)
	{
		for (i=0;i<q;i++) 
			if (elem[i]==0)
			{
				whichEl = eval("sm" + i);
				whichEl.style.display = "none";
			};
	}
	else
	{
		if(autoHideTimer>=0)
		{
			autoHideTimer+=100;
			setTimeout('autoHide()',100);
		}
	}
}

function autoHide3()
{
	var i;
	
	if(autoHideTimer3>timeBeforeAutoHide)
	{
		for (i=0;i<q3;i++) 
			if (elem3[i]==0)
			{
				whichEl = eval("sm3_" + m3a[i]);
				whichEl.style.display = "none";
			};
	}
	else
	{
		if(autoHideTimer3>=0)
		{
			autoHideTimer3+=100;
			setTimeout('autoHide3()',100);
		}
	}
}
