function swapClass(obj, cls)
{
	var t = document.getElementById(obj);
	if (t == null) return;
	t.className = cls;
}


function SelectAll(list1)
{
    for(var x=0;x<list1.length;x++)
    {
    	list1.options[x].selected = true;
    }  
}

function AddToListBox(list1ID, list2ID, addAll)
{
    if (addAll == null)
        addAll = false;
        
    var flag;   
    var list1 = document.getElementById(list1ID);
    var list2 = document.getElementById(list2ID);
    if (list1 == null || list2 == null) return;
    //Add it to list2
    for(var x=0;x<list1.length;x++)
    {
    	var opt = list1.options[x];
    	
    	flag = 1;
    	//check if option exists if not add it
    	for (var y=0;y<list2.length;y++)
    	{
    		var myopt = list2.options[y];
    		if (myopt.value == opt.value)
    		{
    			flag = 0;
    		}
    	}
    	if (flag && (opt.selected || addAll))
    	{
    		//This is not a duplicate so add it to the select box.
    		AddOption(list2, opt.value, opt.text);
    		//list2.options[list2.options.length] = new Option(opt.text, opt.value, 0, 0);
    	}
    	
    }  
}

function RemoveFromListBox(listID, removeAll) 
{
    if (removeAll == null)
        removeAll = false;
     
    var list1 = document.getElementById(listID);
    if (list1 == null) return; 
    //Delete it from my locations
    for(var x=list1.length-1;x>=0;x--)
    {
    	var opt = list1.options[x];
    	if (opt.selected || removeAll)
    	{
    		//Remove it from the select box
    		list1.remove(x);
    		//list1.options[x] = null;
    	}
    }
}

function AddOption(cmb, value, text)
{
    var opt = document.createElement('option');
    opt.text = text;
    opt.value = value;      
    try { cmb.add(opt); } catch(e) { cmb.add(opt,null); }   
}





function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document.images[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		//edit_over = newImage("images/edit-over.gif");
		//print_over = newImage("images/print-over.gif");
		preloadFlag = true;
	}
}