function copyToList(from, to) {
    fromList = eval('document.forms[0].' + from);
    toList = eval('document.forms[0].' + to);
    if (toList.options.length > 0 && toList.options[0].value == 'temp') {
        toList.options.length = 0;
    }

    for (i = 0; i < fromList.options.length; i++) {
        var current = fromList.options[i];
        if (current.selected) {
            txt = current.text;
            val = current.value;
            toList.options[toList.length] = new Option(txt,val);
            fromList.options[i] = null;
            i--;
        }
    }
}

function submitForm(formname) {
	var string_sel_markten = "";
	var string_sel_producten = "";

	var markt_select = document.getElementById('sel_markten');
	var product_select = document.getElementById('sel_producten');
	
	//voor de markten
	for(var i = 0; i < markt_select.length; i++) {
		string_sel_markten += markt_select.options[i].text + ",";
	}
	
	if(string_sel_markten.length > 0)
		string_sel_markten = string_sel_markten.substring(0, string_sel_markten.length -1);
	
	
	//voor de producten
	for(var i = 0; i < product_select.length; i++) {
		string_sel_producten += product_select.options[i].text.replace(/,/g,";") + ",";
	}
	
	if(string_sel_producten.length > 0)
		string_sel_producten = string_sel_producten.substring(0, string_sel_producten.length -1);
	
	document.getElementById('gekozenmarkten').value = string_sel_markten;
	document.getElementById('gekozenproducten').value = string_sel_producten;
	
	//submit the form
	document.getElementById(formname).submit();
}
