function copyToList(from,to,num,formName)
{
  fromList = document.getElementById(from);
  toList = document.getElementById(to);
  
  if ($(to) == null || $(to)=='null' || $(from) == null || $(from)=='null')
  {
  	alert("You haven't selected any options!");
  }
  else
  {
	  if (toList.options.length > 0 && toList.options[0].value == 'temp')
	  {
	    toList.options.length = 0;
	  }
	  var sel = false;
	  for (i=0;i<fromList.options.length;i++)
	  {
	    var current = fromList.options[i];
	    if (current.selected)
	    {
	      sel = true;
	      if (current.value == 'temp')
	      {
	        alert ('You cannot move this text!');
	        return;
	      }
	      txt = current.text;
	      val = current.value;
	      toList.options[toList.length] = new Option(txt,val);
	      fromList.options[i] = null;
	      i--;
	    }
	  }
	  
	  if (!sel)
	  	alert ('You haven\'t selected any options!');
	  else
	  {
	  	if (formName =="projectareas")
	  		saveForm('projectareas',new Array('servicepossible'));
	  		
	  	if (formName == "projecttype")
	  		saveForm('projecttype',new Array('possible'));
	  }
  }
}

//num = form field
//sfield = select field
//seperator = to seperate the objects

// Return Format string from select box
function allSelect(formNum,selectField,seperator)
{
  List = document.forms[formNum].selected;
  var temp2 = "";
  
  if (List.length == 0)
  	return false;
  	
  for (i=0;i<List.length;i++)
  {
     temp2 = temp2 + List.options[i].value + seperator;
  }
  return temp2;
 
}
function serviceallSelect(formNum,selectField,seperator)
{
  List = document.forms[formNum].serviceselected;
  var temp2 = "";
  
  if (List.length == 0)
  	return false;
  	
  for (i=0;i<List.length;i++)
  {
     temp2 = temp2 + List.options[i].value + seperator;
  }
  return temp2;
 
}
function generalallselect(formNum,selectField,seperator)
{
  List = document.forms[formNum].selected;
  var temp2 = "";
  
  if (List.length == 0)
  	return false;
  	
  for (i=0;i<List.length;i++)
  {
     temp2 = temp2 + List.options[i].value + seperator;
  }
  return temp2;
 
}

function verify_company_type()
{
	var types = allSelect(2,'selected',',');
	var msg = 'The Following Problems occured \n';
	if (types == false)
	{
		msg = msg + "No Type Selected \n"
		alert(msg);
	}
	else
	{
		document.getElementById('types').value = types;
		document.companytype.submit();
	}
	
}

function verify_service_areas()
{
	var types = serviceallSelect(1,'serviceselected',',');
	var msg = 'The Following Problems occured \n';
	if (types == false)
	{
		msg = msg + "No Areas Selected \n"
		alert(msg);
	}
	else
	{
		document.getElementById('serviceareas').value = types;
		document.serviceareasForm.submit();
	}
	
}

function verify_general_area()
{
	var types = generalallselect(0,'selected',',');
	var msg = 'The Following Problems occured \n';
	if (types == false)
	{
		msg = msg + "No Areas Selected \n"
		alert(msg);
	}
	else
	{
		document.getElementById('aid').value = types;
		document.generalareas.submit();
	}
	
}
