var arHelp = new Object();
var helpPopup;
var searchResult_currentSelected = 0;

function helpInit() {
	helpPopup = document.getElementById('help_popup');
}
function showInfo(str) {
	helpPopup = document.getElementById('help_popup');
	helpPopupInner = document.getElementById('help_popup_inner');
	helpPopupInner.innerHTML = str;
	helpPopup.style.display = 'block';

	helpPopup.style.marginTop = isInternetExplorer() ? '20px' : '60px';
	helpPopup.style.marginLeft = '468px';
}
function hideInfo() {
	helpPopup.style.display = 'none';
}

// searchresults
function toggleSearchResultRow(r,calledBySelf) {
	// click on same row as before ? skip this and close row
	if (searchResult_currentSelected != r) {
		if (calledBySelf != true) {
			// also toggle last selected row
			searchResult_currentSelected != 0 ? toggleSearchResultRow(searchResult_currentSelected,true) : void(0);
			// .. and set current row as selected
			searchResult_currentSelected = r;
		}
	}
	// do the toggle
	var mainrow = document.getElementById('row_' + r);
	var hiddenrow = document.getElementById('hidden_' + r);
	var doSelect = mainrow.className == 'row' ? true : false;
	mainrow.className = doSelect ? 'selectrow' : 'row';
	hiddenrow.style.display = doSelect ? (isInternetExplorer() ? 'block' : 'table-row') : 'none';
	// if row is toggled off without being called by this function, it must be a close-row click
	// so set selected  to 0
	if (!doSelect && !calledBySelf) searchResult_currentSelected = 0;
}
function closeAllRows() {
	
}
function selectResultPage(p) {
	document.forms[0]['START'].value = p;
	document.forms[0].submit();
}
function sortByName() {
	document.forms[0]['SORT'].value = 'BEDRIJF_NAAM ASC';
	document.forms[0].submit();
}
function sortByPostcode() {
	document.forms[0]['SORT'].value = 'BEDRIJF_POSTCODE ASC';
	document.forms[0].submit();
}
function sortByPlaats() {
	document.forms[0]['SORT'].value = 'BEDRIJF_PLAATS ASC';
	document.forms[0].submit();
}
function printMe() {
	window.print();
}

/* Zaterdag van de afbouw */
function toggleSearchResultRowZVDA(r,id,pc,hn) {
	// toggle eerst de row als normaal
	toggleSearchResultRow(r);
	// alleen cfhttp-en als de row open gaat
	var hiddenrow = document.getElementById('hidden_' + r);
	if (hiddenrow.style.display != 'none') {
		
		var obj = fillObjectFromXml("/getZVDAinfo.cfm?id=" + id + "&pc=" + pc + "&hn=" + hn);
		if(obj.success != 0) {
			document.getElementById('zvda_' + r).innerHTML = obj.content;
			document.getElementById('zvda_tr' + r).style.display = 'block';
		} else {
			window.status='no results';
		}
	}
}
function getZVDA(r,id,pc,hn) {
	var obj = fillObjectFromXml("/getZVDAinfo.cfm?id=" + id + "&pc=" + pc + "&hn=" + hn);
	if(obj.success != 0) {
		document.getElementById('zvda_' + r).innerHTML = obj.content;
		document.getElementById('zvda_tr' + r).style.display = 'block';
	} else {
		window.status='no results';
	}
}

function initZVDA() {
	if (arZVDA) {
		for ( var i=0; i < arZVDA.length; i++ ) {
			obj = arZVDA[i];
			getZVDA(obj.r, obj.id, obj.pc, obj.hn)
		}
	} else {
		window.status = 'geen ZVDA gevonden';
	}
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

