var agt = navigator.userAgent.toLowerCase();

var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));


function hideElement(elmID, overDiv, hOffsetDelta) {


	if(ie) {

	for (i = 0; i < document.all.tags(elmID).length; i++) {

	obj = document.all.tags(elmID)[i];


	if(!obj || !obj.offsetParent) {

	continue;

	} else {
		obj.style.visibility = "hidden";
	}

	objLeft = obj.offsetLeft;


	objTop = obj.offsetTop;


	objParent = obj.offsetParent;

		objParent = objParent.offsetParent;



	/**
	while( objParent.tagName.toUpperCase() != "BODY" ) {

		objLeft += objParent.offsetLeft;

		objTop += objParent.offsetTop;

	}*/

	objHeight = obj.offsetHeight;

	objWidth = obj.offsetWidth;



	if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft );

	else if((overDiv.offsetTop + overDiv.offsetHeight +	hOffsetDelta) <= objTop);

	else if( overDiv.offsetTop >= ( objTop + objHeight	));

	else if( overDiv.offsetLeft >= ( objLeft + objWidth	));

	else {

	obj.style.visibility = "hidden";

	}

	}

	}

}



function showElement(elmID) {

	if(ie) {

		for(i = 0; i < document.all.tags(elmID).length; i++) {

			obj = document.all.tags(elmID)[i];
	


			if(!obj || !obj.offsetParent) {

			continue;

			}

			obj.style.visibility = "";

		}

	}

}



activateMenu = function(nav) {

	var menyyDiviObjekt = document.getElementById(nav);



    /* currentStyle restricts the Javascript to IE only */

	if (document.all && document.getElementById(nav).currentStyle) {  

        var navroot = document.getElementById(nav);



        /* Get all the list items within the menu */

        var lis=navroot.getElementsByTagName("LI");  

        for (i=0; i<lis.length; i++) {

        

           /* If the LI has another menu level */

            if(lis[i].lastChild.tagName=="UL"){

            

                /* assign the function to the LI */

             	lis[i].onmouseover=function() {	

					/* display the inner menu */

					this.lastChild.style.display="block";

					hideElement('SELECT', this.lastChild, 0);

                }

                lis[i].onmouseout=function() {                       

                   this.lastChild.style.display="none";

					showElement('SELECT');

                }

            }

        }



		//hideElement ('SELECT', menyyDiviObjekt, 0);

		// juhul kui tahan peita ka applet-tüüpi elemendid

		// hideElement ('APPLET', menyyDiviNimi, 0);

    }

}
