// +----------------------------------------------------------------------+
// | Source file version 1.0                                              |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002 - 2003 OÜ HansaNet (http://www.hansanet.ee)       |
// +----------------------------------------------------------------------+
// | This source file is property of OÜ HansaNet. Modifying and           |
// | distribution of any kind is prohibited without written permission    |
// | from OÜ HansaNet.                                                    |
// +----------------------------------------------------------------------+
// | Authors: Reio Piller <reio@hansanet.ee>                              |
// +----------------------------------------------------------------------+

var all_grp_ids = new Array();

function grpSetAllValue(nr_list) {
	for (var i = 0 ; i < nr_list.length ; i++) {
		grpSetValue(nr_list[i]);
	}
}
function grpSetAllValue1(nr_list) {
		grpSetValue(nr_list);
		

}
function grpSetValue(nr) {
	var dest = getObjectById("grp_dest_box"+nr);
	var res  = getObjectById("grp_result_value"+nr);
	res.value = '';
	for (var i = 0 ; i < dest.options.length ; i++) {
		res.value += ',' + dest.options[i].value;
	}
//console.log(res.value);
	
}

function grpMoveToDest(nr) {
	var src = getObjectById("grp_src_box"+nr);
	var dest = getObjectById("grp_dest_box"+nr);
	var res = getObjectById("grp_result_value"+nr);
	for (var i = 0 ; i < src.options.length ;) {
		if (src.options[i].selected == true) {
			dest.options[dest.options.length] = new Option(src.options[i].text, src.options[i].value, false, false);
			src.options[i] = null;
		}
		else {
			i++;
		}
	}
}

function grpMoveToSrc(nr) {
	var src = getObjectById("grp_dest_box"+nr);
	var dest = getObjectById("grp_src_box"+nr);
	var res = getObjectById("grp_result_value"+nr);
	for (var i = 0 ; i < src.options.length ;) {
		if (src.options[i].selected == true) {
			dest.options[dest.options.length] = new Option(src.options[i].text, src.options[i].value, false, false);
			src.options[i] = null;
		}
		else {
			i++;
		}
	}
}

function grpMoveUp(nr) {
	var dest = getObjectById("grp_dest_box"+nr);
	var res = getObjectById("grp_result_value"+nr);
	var tmp1;
	var tmp2;
	if (dest.options.length < 2 || dest.options[0].selected == true) {
		return 0;
	}
	for (var i = 1 ; i < dest.options.length ; i++) {
		if (dest.options[i].selected == true) {
			tmp1 = new Option(dest.options[i-1].text, dest.options[i-1].value, false, false);
			tmp2 = dest.options[i];
			dest.options[i] = tmp1;
			dest.options[i-1] = tmp2;
		}
	}
}

function grpMoveDown(nr) {
	var dest = getObjectById("grp_dest_box"+nr);
	var res = getObjectById("grp_result_value"+nr);
	var tmp1;
	var tmp2;
	if (dest.options.length < 2 || dest.options[dest.options.length - 1].selected == true) {
		return 0;
		}
	for (var i = (dest.options.length - 2) ; i >= 0 ; i--) {
		if (dest.options[i].selected == true) {
			tmp1 = new Option(dest.options[i+1].text, dest.options[i+1].value, false, false);
			tmp2 = dest.options[i];
			dest.options[i] = tmp1;
			dest.options[i+1] = tmp2;
		}
	}
}

