// JavaScript Document
function append()
{
	//alert("entered");
	//alert(document.choiceForm.addkeyword.value);
	var newvalue = document.choiceForm.addkeyword.value;
	
var boxLength = document.choiceForm.choiceBox.length;
//alert(boxLength);
//var selectedItem = document.choiceForm.addkeyword.selectedIndex;
var selectedItem = '0';

//alert(selectedItem);
var selectedText = document.choiceForm.addkeyword.value;
var selectedValue = '1';

var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.addkeyword.selectedIndex=-1;

//document.choiceForm.choiceBox.value = newvalue;
}
function moveOver()
{
	alert("entered to fun");
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
//alert(selectedItem);
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
//alert("selctedtext"+selectedText);
//alert("selectedvalue"+selectedValue);

var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}
function saveMe() {
var strValues = "";
var categoryselected = "";
var boxLength = document.choiceForm.choiceBox.length;
var count = 0;
		if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
		if (count == 0) {
		strValues = document.choiceForm.choiceBox.options[i].value;
		categoryselected = document.choiceForm.choiceBox.options[i].text;
		}
		else {
		strValues = strValues + "," + document.choiceForm.choiceBox.options[i].value;
		categoryselected = categoryselected + "," + document.choiceForm.choiceBox.options[i].text;
		}
		count++;
		}
		}
			if (strValues.length == 0) {
			alert("You have made no selection(s)");
			}
			else {
			alert("Here are the values you've selected:\r\n" + strValues);
			choiceForm.valuesForInsert.value = strValues;
			choiceForm.selectedValues.value = categoryselected;
			choiceForm.count.value = boxLength;
			//alert("valuesForInsert :"+choiceForm.valuesForInsert.value);
			//alert("selectedValues :"+choiceForm.selectedValues.value);
			choiceForm.submit();
			}
}
//// adminGroups multiple select swap code finish
function validate()
{

if(document.choiceForm.groupname.value=="")
{
alert("You must enter a group name");
document.choiceForm.groupname.focus();
return(false);
}
if(document.choiceForm.gDescription.value=="")
{
alert("Please enter a brief description, you may edit this anytime");
document.choiceForm.gDescription.focus();
return(false);
}
saveMe();
//return (true);
}

function groupValidate()
{

if(document.adminGroupsComments.suggestionString.value=="")
{
alert("You must enter a suggestion");
document.adminGroupsComments.suggestionString.focus();
return(false);
}
return (true);
}
