// Create namespace
function WTE() { };

WTE.getChildren = function(objTarget, tmplId, strRecordType, params) {
	for (x=objTarget.length; x >= 0; x--) {
		objTarget[x] = null;
	}
	objTarget[0] = new Option("-","");
	if (tmplId == '' || tmplId == null) return;
	var url;
	if (params != null) {
		// Template query parameters passed
		url = '/ui.ashx?f=fts_execute&d=' + parseInt(tmplId) + '&uniq=' + Math.random();
		for (i=0; i < params.length; i++) {
			var val = parseInt(params[i].value);
			if (isNaN(val)) val = 0;
			url += '&' + encodeURIComponent(params[i].name) + '=' + val;
		}
	} else {
		url = '/ui.ashx?f=frag_list&d=' + parseInt(tmplId) + '&tag=json';
	}
	
	var _xh= GetXMLHTTP();
	
	if (_xh) {
		AJAX_loadStart();
		_xh.onreadystatechange = function() {
			if (_xh.readyState == 4) {
				if (_xh.status == 200) {		
					if (_xh.responseText != '' && _xh.responseText != null) {
						try {
							eval("var options=" + _xh.responseText);

							for (i=0; i < options.length; i++) {
								objTarget[i + 1] = new Option(options[i].text,options[i].value);
							}
						} catch(e) {
							objTarget[0] = new Option("-","");
						}
					}
					AJAX_loadEnd();
				}
			}
		}
		
		_xh.open('GET',url,true);
		_xh.send(null);
	}
}
WTE.setCheckboxChildren = function(obj,val) {
	for (var i=0; i < obj.childNodes.length; i++) { 
		var cObj = obj.childNodes[i];		
		if (cObj.tagName == 'INPUT' && cObj.type == 'checkbox') {
			cObj.checked = val;
			markupParentSelected(cObj, val);
		} else {
			if (cObj.hasChildNodes()) {
				WTE.setCheckboxChildren(cObj,val);
			}
		}
	}
}
