var root=false
var engaged = false


var buffer = new Array(5);
buffer[0] = null;
buffer[1] = null;
buffer[2] = null;
buffer[3] = null;
buffer[4] = null;

var isNav, isIE, isOld, ns6
if (parseInt(navigator.appVersion) == 5){
		ns6 = true
		isNav = true;
		obj="document.getElementById";
		posLeft=".style.left";
		posTop=".style.top";
		posWidth=".style.width";
		posWidth2=".clientWidth"; // de juiste !
		posHeight=".style.height";
		posHeight2=".clientHeight";			// de juiste !
		bgColor=".style.backgroundColor";
		visibility=".style.visibility";
		visible="='visible'";
		visible_eng="visible";
		invisible="='hidden'";
		invisible_eng="hidden";
} else if (parseInt(navigator.appVersion) >= 4){
	if (navigator.appName == "Netscape") 
    {
		isNav = true;
		obj="document.layers";
		innerLayersLength=".document.layers.length";
		innerLayer=".document.layers";
		posLeft=".left";
		posTop=".top";
		posWidth=".clip.width";
		posHeight=".clip.height";
		posHeight2=".clip.height";
		bgColor=".bgColor";
		visibility=".visibility";
		visible="='show'";
		visible_eng="show";
		invisible="='hide'";
		invisible_eng="hide";	
	} else {	
		isIE = true;
		obj="document.all";
		innerLayersLength=".children.length";
		innerLayer=".children";
		posLeft=".style.pixelLeft";
		posTop=".style.pixelTop";
		posWidth=".style.posWidth";
		posWidth2=".style.clientWidth"; // de juiste !
		posHeight=".style.pixelHeight";
		posHeight2=".clientHeight";			// de juiste !
		bgColor=".style.backgroundColor";
		visibility=".style.visibility";
		visible="='visible'";
		visible_eng="visible";
		invisible="='hidden'";
		invisible_eng="invisible";
	}
}
else isOld = true;

if (isOld) top.location.href= "/misc/oldbrowser.htm"

function handleResize()
{
	location.reload()
	return false
}

if (isNav)
{
	window.captureEvents(Event.RESIZE)
	window.onresize = handleResize
}

function hideAll()
{
	if (engaged){
		oldDmenu = -1;
		hideLayer('Lmenu')
		open1 = false;
		hideLayer('Lsmenu')
		open2 = false;
	}
}

function showLayer(layerName)
{
	if (ns6) eval(obj+'("'+layerName+'")'+visibility+visible);
	else eval(obj+'["'+layerName+'"]'+visibility+visible);
}

function hideLayer(layerName)
{
	if (ns6) eval(obj+'("'+layerName+'")'+visibility+invisible);
	else eval(obj+'["'+layerName+'"]'+visibility+invisible);
}
	
function moveLayer(layerName,left,top)
{
	if (ns6){
		eval(obj+'("'+layerName+'")'+posLeft+"="+left);
		eval(obj+'("'+layerName+'")'+posTop+"="+top);
	} else {
		eval(obj+'["'+layerName+'"]'+posLeft+"="+left);
		eval(obj+'["'+layerName+'"]'+posTop+"="+top);
	}
}

function moveTop(layerName,top){
	if (ns6) eval(obj+'("'+layerName+'")'+posTop+"="+top);
	else eval(obj+'["'+layerName+'"]'+posTop+"="+top);
}

function moveLeft(layerName,left){
	if (ns6) eval(obj+'("'+layerName+'")'+posLeft+"="+left);
	else eval(obj+'["'+layerName+'"]'+posLeft+"="+left);
}
var aCell = new Array(0,0,0,0,0,0,0,0);

function showCell(cellId)
{ 
	if (ns6){
		document.getElementById(cellId).bgColor = "#0099ff"
	} else {
		eval(cellId+'.bgColor="#0099ff"');
		eval(cellId+'.style.cursor="hand"');
	}
}

function hideCell2(cellId)
{
	if (cellId == aCell)
	{
	
	if (ns6) document.getElementById(cellId).bgColor = "#fc6c4b"
	else eval(cellId+'.bgColor="#fc6c4b"');
	}
	else
	{
	if (ns6) document.getElementById(cellId).bgColor = "#0067cc"		
	else eval(cellId+'.bgColor="#0067cc"');	
	}
}

function hideCell3(cellId,item)
{
	if (aCell[item-1] == 1)
	{
	if (ns6) document.getElementById(cellId).bgColor = "#fc6c4b"
	else eval(cellId+'.bgColor="#fc6c4b"');
	}
	else
	{
	if (ns6) document.getElementById(cellId).bgColor = "#00018D"
	else eval(cellId+'.bgColor="#00018D"');	
	}
}

function hideCell(cellId)
{
	if (ns6) document.getElementById(cellId).bgColor = "#0067cc"
	else eval(cellId+'.bgColor="#0067cc"');	
}

function initCell()
{
	url=top.location.href;
	if (( url == 'Avaleht' )||(url == '/oce/default.asp')) { aCell[0]=1;}		//Avaleht
	if ( url.indexOf('yld') != -1 ) { aCell[1]=1;}
	if ( url.indexOf('insenert') != -1 ) { aCell[2]=1;}			//A0 tooted kataloog
	else if ( url.indexOf('koopiam') != -1 ) { aCell[3]=1;}		//A4 tooted kataloog
//	if ( url.indexOf('directoryName') != -1 ) { aCell[3]=1; }	//jobs
	if ( url.indexOf('kasut') != -1 ) { aCell[4]=1; }			//kasutatud masinad
//	if ( url.indexOf('directoryName') != -1 ) { aCell[7]=1; }
}
initCell()
function DA_menuLink(selectObject, windowRef){
  toURL = selectObject.options[selectObject.selectedIndex].value
  resetIndex = -1
  for (x = 0 ; x < selectObject.length ; x++) {
    if (selectObject.options[x].defaultSelected)  { resetIndex = x }
  }
  selectObject.selectedIndex = resetIndex
  if (toURL) {
    if (windowRef == 'blank'  ||  (windowRef == 'window.opener'  &&  (!window.opener || window.opener.closed))) {
      window.open(toURL)
    }
    else {
      eval(windowRef + ".location.href = toURL")
    }
  }
}


function hidePrev(menuId)
{
	var i = menuId;
	do
		{
			if (buffer[i] !=null) 
			{
				if (ns6) eval(obj+'("'+buffer[i]+'")'+visibility+invisible);
				else eval(obj+'["'+buffer[i]+'"]'+visibility+invisible);
				buffer[i]=null;
			}
		} while (++i < buffer.length-1);
}

function showProduct(menuId,layerName,posY)
{
	hidePrev(menuId)
	if (buffer[i] != layerName)
	{
		buffer[menuId] = layerName;
		if (ns6){
			eval(obj+'("'+layerName+'")'+visibility+visible);
			eval(obj+'("'+layerName+'")'+posTop+"="+posY);
		} else { 
			eval(obj+'["'+layerName+'"]'+visibility+visible);
			eval(obj+'["'+layerName+'"]'+posTop+"="+posY);
		}
	}
}

var formObj = 'document.seek1';

function checkSearch()
{
	if (ns6) formObj = obj+'("seek1")'
	else if (isNav) formObj = 'document.layers.funcNavL.document.seek1';
	tSearch = eval(formObj+".qt.value.length;");
	if (tSearch<1)
	{
		top.location.href="http://search.oce.com/";
		return false;
	}
	
	eval(formObj+".submit();");
}

