// JavaScript Document


function get_object (id) {
	if (document.all) {
		return document.all[id];
	}
	return document.getElementById (id);
}

function addOption(selectId, txt, val)
{
	var obj = get_object(selectId);
    var objOption = new Option(txt, val);
    obj.options.add(objOption);
}

function emptyBox(selectId) {
	var obj = get_object(selectId);
	
	var obj = document.getElementById(selectId);
	
	for (i=obj.options.length-1;i>=0;i--) {
		obj.removeChild(obj.options[i]);
	}
}

function select_all_selected(selectId) {	
	var obj = get_object(selectId);
	
	
	if (obj.options.length > 0) {
		for (i=obj.options.length-1;i>=0;i--) {
			obj.options(i).selected = true;
		}
	}	
}

function copyOptions(selectId1,selectId2) {
	var i = 0;
	var count = 0;
	
	var from = get_object(selectId1);
	var to = get_object(selectId2);
	
	if (from.options.length > 0) {
		for (i=from.options.length-1;i>=0;i--) {
			count = to.options.length;
				
			if (from.options(i).selected) {
				to.options.add(document.createElement('OPTION'));
				
				to.options(count).text = from.options(i).text;
				to.options(count).value = from.options(i).value;				
				
				from.options.remove(i);	
			}
		}		
	}	
}

function copyOption(obj, to) {
	if (obj[obj.selectedIndex].value > '') {
		var to = get_object(to);
		var objOption = new Option(obj[obj.selectedIndex].text, obj[obj.selectedIndex].value);
    	to.options.add(objOption);
	}
}

function removeOptions(selectId) {	
	var obj = get_object(selectId);
	
	if (obj.options.length > 0) {
		for (i=obj.options.length-1;i>=0;i--) {
				
			if (obj.options(i).selected) {			
				obj.options.remove(i);	
			}
		}		
	}	
}
