/*-==========================================================-*
 *                                                            *
 * Author		:	Zone Media OY	              *
 * Homepage		:	http://www.zone.ee            *
 * 			:	http://data.zone.ee           *
 * Contact		:	info@zone.ee                  *
 * Copyright		:	2003	                      *
 *							      *
 *-==========================================================-*/


/*
 * Avab peamenyyst vastava punkti, mis leht parajasti ees on
 * (juhul kui see juba avatud pole)
 */
function openCurrentParentNode () {

	var PP = gvar_pv;

	if (menuSupportsThisBrowser && PP != null) {

		var divs = document.getElementsByTagName ('DIV');

		var typ = getLocationVariable ('typ');

		// k2ime k6ik menu DIV-id l2bi
		for (var c = 0; c < divs.length; c++) {

			if (divs[c].id.substr (0, menuChildrenTag.length) == menuChildrenTag) {

				var as = divs[c].getElementsByTagName("A");

				for (var i = 0; i < as.length; i++) {

					var test_PP = getLocationVariableEx (gvar_p, as[i].href);

					if (test_PP != null && test_PP == PP &&
						// NB! Menyys mailikontode menyypunkti 6ige valimine
						(typ == null || getLocationVariableEx ('typ', as[i].href) == typ)) {

						// m2rgistame valitud menyypunkti
						if (as[i].parentNode != null && as[i].parentNode.nodeName == 'TD') {

							// paneme tabeli celli backgroundi teist v2rvi
							as[i].parentNode.attributes['background'].value = gvar_styledir + '/media/0.gif';

							// paneme tabeli celli teksti teist v2rvi
							as[i].style.color	= 'white';
							as[i].style.fontWeight	= 'bold';
						}
						//

						MenyyEx (divs[c].id.substr (menuChildrenTag.length), 'show');

						break;
					}
					
				}
			}
			
		}
	}
}

/*
 * Paneb yleval listboxis 6ige valiku
 * (kui vastav leht on valikutes olemas)
 */
function setCurrentListboxOption () {

    if (typeof (document['listbox_dz']) != 'undefined' && document['listbox_dz'] != null) {
    	var lb = document.listbox_dz[gvar_n];
    	var PP = gvar_pv;
    
        if (typeof (lb) != 'undefined' && lb != null) {
        	for (c = 0; c < lb.options.length; c++) {
        
        		var test_PP = getLocationVariableEx (gvar_p, lb.options[c].value);
        
        		if (test_PP == PP) {
        			lb.options[c].selected = true;
        			break;
        		}
        	}
        }
    }
}

/*
 * Avab/sulgeb kogu menyy
 */
function openAllNodes (mode) {

	if (menuSupportsThisBrowser) {
		var divs = document.body.getElementsByTagName("DIV");

		// k2ime k6ik menu DIV-id l2bi
		for (var c = 0; c < divs.length; c++) {

			if (divs[c].id.substr (0, menuParentTag.length) == menuParentTag) {
				MenyyEx (divs[c].id.substr (menuParentTag.length), mode);
			}

		}
	}
}