function NationalPlant() { };

NationalPlant.getChildren = function(objTarget, tmplId, strRecordType, params) {
	for (x=objTarget.length; x >= 0; x--) {
		objTarget[x] = null;
	}
	objTarget[0] = new Option("-- All " + strRecordType + "s --","");
	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 if (tmplId == '' || tmplId == null) {
                url = '/ui.ashx?f=frag_list&a=10537&tag=json';
        }
          else {
		url = '/ui.ashx?f=children_option_list&d=' + parseInt(tmplId);
	}
	
	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.replace('&amp;','&'),options[i].value);
							}
						} catch(e) {
							objTarget[0] = new Option("-- Select " + strRecordType + " --","");
						}
					}
					AJAX_loadEnd();
				}
			}
		}
		
		_xh.open('GET',url,true);
		_xh.send(null);
	}
}

// Dropdown function overrides
// Close (conditionally)
NationalPlant.ddCvx = function(strIdn) {
	strId = 'dm_' + strIdn;
	$(strId).dmEnable = 0;
	setTimeout('NationalPlant.cVis(\'dm_'+strIdn+'\',$(\''+strId+'\').dmEnable)',100);
}

NationalPlant.cVis = function(strId, dmx) {
	if (dmx != 1) { 
		var objTgt = $(strId);
		if (objTgt._hasIframe == 1) objTgt._iframe.style.display='none';
		objTgt.style.display='none';
	}
}
// Open DD
NationalPlant.ddOvx = function(strIdn) {
	strId = 'dm_'+strIdn;
	strTopId = 'ml_'+strIdn;
	var objTgt = $(strId);
	objTgt.dmEnable = 1;
	objTgt.style.top=(findPosY($(strTopId)) + $(strTopId).offsetHeight) + "px";
	objTgt.style.left=(findPosX($(strTopId)) - 5) + "px";
	objTgt.style.display='block';
	if (document.selection) {
		// IE IFRAME underlay trick
		if (objTgt._hasIframe != 1) {
			var iFrame = document.createElement('IFRAME');
			iFrame.className = 'dd_iframe_underlay';
			iFrame.frameBorder = 'no';
			iFrame.style.display = 'none';
			iFrame.style.top = objTgt.style.top;
			iFrame.style.left = objTgt.style.left;
			iFrame.style.width = objTgt.offsetWidth + 'px';
			iFrame.style.height = objTgt.offsetHeight + 'px';
			objTgt._iframe = iFrame;
			objTgt.parentNode.appendChild(iFrame);
			objTgt._hasIframe = 1;
		}
		objTgt._iframe.style.display='block';
	}
}
// Sustain DD
NationalPlant.ddSvx = function(strIdn) {
	strId = 'dm_'+strIdn;
	$(strId).dmEnable = 1;
}
function NationalPlantUpdatePriceTo(priceFrom,priceTo)
{
        
	for (x=priceTo.length-1; x >= 0; x--) {

                if (parseInt(priceTo[x].value)<parseInt(priceFrom))
		       priceTo[x] = null;
	}        
}
