var expiryTimer;
var arr = [];

var ajax1Groep = new sack();
ajax1Groep.onCompletion = showDataGroep;

function addOptionGroep(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function removeAllOptionsGroep(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		selectbox.remove(i);
	}
}

function getDataGroepen(object)
{
	theField=document.getElementById(object);
	if (theField.value != "")
	{
		getAjaxFile(ajax1Groep,"../include/getdatagroepen.php?modelcode="+theField.value);
	}
}

function showDataGroep()
{
	optionsElement = document.getElementById('groepcode');
	xmlValues = ajax1Groep.responseXML.getElementsByTagName("dataline");
	populateOptionsGroep(optionsElement,xmlValues);
}

function populateOptionsGroep()
{
	var len = xmlValues.length;
    if(len==0)
	{
		removeAllOptionsGroep(optionsElement);
		//addOptionGroep(optionsElement, '[Groep]', '0');
    }
	else
	{
		removeAllOptionsGroep(optionsElement);
		//addOptionGroep(optionsElement, '[Groep]', '0');
		for(var i=0; i<len; i++)
		{
			addOptionGroep(optionsElement, xmlValues[i].getAttribute('waarde'), xmlValues[i].getAttribute('id'));
		}
    }
}
