function setOptions(dest,val,defaultSelect)
{
	
	eval("arrayDest = "+dest.name);
	dest.length = 0;
	dest.options[0] = new Option(defaultSelect,''); 
	index = 1;
	
	if(val != '' && val != 0)
	{
	   for(i=0;i<arrayDest.length;i++)
	   {
		 if(arrayDest[i][2] == val || val == '')
		 {
			dest.options[index] = new Option(arrayDest[i][1],arrayDest[i][0]); 
			index++;
		 }
		
	   }
    }
	
}

function setOptions2(dest,val,val2,defaultSelect)
{
	
	eval("arrayDest = "+dest.name);
	dest.length = 0;
	dest.options[0] = new Option(defaultSelect,''); 
	index = 1;
	
	for(i=0;i<arrayDest.length;i++)
	{

		if((arrayDest[i][2] == val || val == '') && (arrayDest[i][3] == val2 || val2 == ''))
		{
			dest.options[index] = new Option(arrayDest[i][1],arrayDest[i][0]); 
			index++;
		}
		
	}
	
}


function setIndex(dest,index)
{
	selectedIndex = 0;
	for(i=0;i<dest.options.length;i++)
		if(dest.options[i].value == index)
			selectedIndex = i;
	dest.selectedIndex = selectedIndex;
}


function orderItems(s)
{
	for(i=0;i<s.length;i++)
	{
		if(s.options[i].selected && i>0)
		{
			preText = s.options[i-1].text;
			preValue = s.options[i-1].value;
			s.options[i-1].text = s.options[i].text;
			s.options[i-1].value = s.options[i].value;
			s.options[i].text=preText;
			s.options[i].value=preValue;
		}	
	}
}

//move selected options between the 2 menus, from source (s) to destination (d)
function moveItems(s,d)
{
	for(i=0;i<s.length;i++)
	{
		if(s.options[i].selected)
		{
			d.options[d.length]=new Option(s.options[i].text, s.options[i].value);
			s.options[i] = null;
			i--;
		}	
	}
}

//select All options in the menu
function selectAll(menu)
{
	for(i=0;i<menu.length;i++)
		menu.options[i].selected=true;
}

//check/Uncheck All checkboxes
function checkUncheckAll(theElement,selectAllFieldName) {
	
	var theForm = theElement.form, z = 0;
  
	for(z=0; z<theForm.length;z++)
    	if(theForm[z].type == 'checkbox')
		{
				/*theForm[z].checked = theElement.checked;*/
				theForm[z].checked = true;
		}
}
function UncheckAll(theElement,selectAllFieldName){
	
	var theForm = theElement.form, z = 0;
  
	for(z=0; z<theForm.length;z++)
    	if(theForm[z].type == 'checkbox')
		{
				theForm[z].checked = false;
		}
}

function checkUncheckAllWizard(theElement,selectAllFieldName) {

	var theForm = theElement, z = 0;
	
	if(typeof theForm.length == "undefined")
	{
		theForm.checked = selectAllFieldName.checked;
	}
	else
	{
		for(z=0; z<theForm.length;z++)
	  		theForm[z].checked = selectAllFieldName.checked;
	}
}