// JavaScript Document
function showSubItems(aSubItems) {
	// aSubItems is een array met als 1e element de id van het div-object en als 2e de inhoud
	if (aSubItems.length && aSubItems.length == 2)  {
		var oTarget = document.getElementById(aSubItems[0]);
		if (oTarget) {
			oTarget.innerHTML = aSubItems[1];
			oTarget.style.display = "block";
		}else{
			alert('No target width id=' + aSubItems[0]);
		}
	}else{
		alert(aSubItems);
	}
	
}

function getSubItems(idTarget, nLevel, nRemote, sSuCode, sGroep, sEindeLevel) {
	oTarget = document.getElementById(idTarget);
	if (oTarget) {
		icon = document.getElementById(idTarget + '_icon')
		if (oTarget.style.display == "block") {
			oTarget.style.display = "none";
			icon.src = 'images/bullet_toggle_plus_big.png';
			return;
		}
		icon.src = 'images/bullet_toggle_minus_big.png';
		if (oTarget.innerHTML == "") {
			if (nRemote == 0) {
				sTargetFunction = "getSubItems";
			}else{
				sTargetFunction = "getSubItemsImport";
			}
			
			DWREngine._execute(
				"libs/functions/ajax_functions.inc.cfm", null, sTargetFunction, idTarget, nLevel, sSuCode, sGroep, sEindeLevel, showSubItems
			);
		}else{
			oTarget.style.display = "block";
		}
	}
}

function initBoom() {
	oDeBoom = document.getElementById('idDeBoom');
	if (oDeBoom) {
		if (parent != self && parent.gDeBoom) {
			// Haal de boom weer terug
			oDeBoom.innerHTML = parent.gDeBoom;
		}
	}

}

function showSearchResults(sSuCode, sGroep, sLevel, bACLRestricted) {
	document.getElementById('motordetails').src = 'motorbanden_details.cfm?su_code=' + escape(sSuCode) + '&groep=' + sGroep + '&level=' + sLevel; 

	oDeBoom = document.getElementById('idDeBoom');
/*	if (oDeBoom) {
		if (parent != self) {
			// Save de boom om later weer te tonen
			parent.gDeBoom = oDeBoom.innerHTML;
		}
	}
*/	
	if (bACLRestricted) {
		document.getElementById('motorbandendetails').style.display = 'block'; return window.scroll (0,0);
	}else{
		document.getElementById('motorbandendetails').style.display = 'block'; return window.scroll (0,0);
	}
}

function showResultsBox(sHtml) {
	oTableSearch = document.getElementById("idZoekArgumenten");
	oDivResults = document.getElementById("idZoekResultaten");
	
	if (oTableSearch && oDivResults) {
		oDivResults.style.height = oTableSearch.clientHeight + "px";
		oDivResults.style.width = oTableSearch.clientWidth + "px";
		oDivResults.innerHTML = sHtml;
		oDivResults.style.display = "block";
	}
	//alert(oTableSearch.clientWidth + "," + oTableSearch.clientHeight);
	return false;
}

function closeSearchResults() {
	oDivResults = document.getElementById("idZoekResultaten");

	if (oDivResults) {
		oDivResults.style.display = "none";
	}
}
