/////////////////// below is for new admin layout /////////////////////

// Function to check or uncheck a group of checkboxes
boxesChecked = false;
function checkAllBoxes(obj)
	{
	//alert(obj);
	if (typeof obj.length == "undefined")
		{obj.checked = true;}
	else
		{
		for (i=0; i < obj.length; ++i)
			{obj[i].checked = !boxesChecked;}
		}
	boxesChecked = !boxesChecked;	
	}		

function checkVal(obj) {
	if (isNaN(obj.value)) {
		alert("Quantities must be a valid number.      ");
		obj.value = "";
		}
	}	
function setDelivery(obj) {
	formObj = obj.form;

	if (obj.checked) {
		formObj.delivery_address.value = formObj.address.value;
		formObj.delivery_suburb.value = formObj.suburb.value;
		formObj.delivery_postcode.value = formObj.postcode.value;
		formObj.delivery_state.value = formObj.state.value;
		formObj.delivery_contactnumber.value = formObj.contactnumber.value;
		formObj.delivery_country.value = formObj.country.value;
		}
	else {	
		formObj.delivery_address.value = "";
		formObj.delivery_suburb.value = "";
		formObj.delivery_postcode.value = "";
		formObj.delivery_state.value = "";
		formObj.delivery_contactnumber.value = "";
		formObj.delivery_country.value = "";
		}
	}
function dynamicWindow(str, w, h)
	{
	dynamicPopup = window.open("about:blank","dynamicPopup","status=1,width=" + w + ",height=" + h);
	docStyle = document.getElementsByTagName("link");

	docStyles = "";
	for (i=0; i < docStyle.length; ++i) {
		docStyles += docStyle[i].outerHTML;}

	dynamicPopup.document.write(docStyles + str);
	dynamicPopup.document.title = document.title;
	dynamicPopup.document.close();
	//dynamicPopup.window.print();
	//dynamicPopup.window.close();
	}
							
// Button state function
buttons = new Object();
function pickState(item,mode,activate)
	{
	
	// Set up button object
	if (typeof buttons[item.id] == "undefined")
		{
		//alert(typeof buttons[item.id]);
		buttons[item.id] = new Object();
		buttons[item.id].state = item.className;
		buttons[item.id].active = false;
		buttons[item.id].originalState = item.className;
		
		}
	//alert(mode);
	
	itemState = buttons[item.id].state
	switch (mode){
		case "click":
			{
			if (activate == true)
				{//alert("click");
				if (itemState == "buttonActive")
					{
					buttons[item.id].state = "buttonOver";
					buttons[item.id].active = false;
					buttons[item.id].originalState = false;
					}
				else
					{
					buttons[item.id].state = "buttonActive";
					buttons[item.id].active = true;
					}
				item.className = buttons[item.id].state;	
				}
			pickState(item,"mouseup",activate);	
			break;	
			}
		case "mousedown":
			{
			item.className = "buttonPress";
			break;
			}
		
		case "mouseup":
			{
			//alert();
			if (buttons[item.id].active == true)
				{
				item.className = "buttonPress";
				//buttons[item.id].active = false;
				}
			else
				{
				item.className = "buttonOver";
				//buttons[item.id].active = true;
				}	
			break;
			}
		case "mouseover":
			{
			if (buttons[item.id].active != true)
				{item.className = "buttonOver";}
			if (buttons[item.id].active == true)
				{item.className = "buttonPress";}	
			break;
			}
		case "mouseout":
			{
			//alert(itemState);
			if (buttons[item.id].active == true)
				{buttons[item.id].state = "buttonActive";}
			else
				{	
				if (itemState != "buttonActive")
					{
					buttons[item.id].state = buttons[item.id].originalState;
					}
				}	
			item.className = buttons[item.id].state;
			break;
			}
		}
	}

// Password request popup
function getPassword()
	{
	qString = location.href.split("?");
	qString.length > 1 ? queryString = "?" + qString[1] : queryString = "";
	window.open("viewmodes/getPassword.cfm" + queryString, "download", "width=300,height=150,scrollbar=no");
	}

// Launch file download window
function getDownloadFile(docID)
	{
	//qString = location.href.split("?");
	//fQString = "";
	//vPairs = qString.split("&");
	/*
	for (i=0; i < vPairs.length; ++i)
		{
		thisPair = vPairs[i].split("=");
		fQString = thisPair[0].toLowerCase() != "viewmode" ? "&" + vPairs[i] : "";
		}
	*/	
	//qString.length > 1 ? queryString = "?" + qString[1] : queryString = "";
	window.open("index.cfm?viewmode=getDownload&displayContainer=false&documentid=" + docID, "download", "width=300,height=150");
	}

// Open applications
 function launchApp(strCmdLine)
  {
   var obj = new ActiveXObject("LaunchinIE.Launch");
	obj.LaunchApplication(strCmdLine);
  }

// reload main window
function logout()
	{top.location.href = "logout.cfm";}

// Dump object properies
function dumpObject(obj)
	{for (p in obj)
		{document.write(p +  " = " + obj[p] + "<br>");}}	

/////////////  Blocked IP Address functions  /////////////////////////
	function addIPAddress(thisForm)
		{
		if (thisForm.newIPAddress[0].value.replace(/[ ]/g,"") != "" &&
			thisForm.newIPAddress[1].value.replace(/[ ]/g,"") != "" &&
			thisForm.newIPAddress[2].value.replace(/[ ]/g,"") != ""  &&
			thisForm.newIPAddress[3].value.replace(/[ ]/g,"") != "")
			{
			ipAddress = thisForm.newIPAddress[0].value + "." + 
						thisForm.newIPAddress[1].value + "." + 
						thisForm.newIPAddress[2].value + "." + 
						thisForm.newIPAddress[3].value;
			insertOptionAt(thisForm.blocked, ipAddress, ipAddress, 1);
			}
		thisForm.newIPAddress[0].value = "";
		thisForm.newIPAddress[1].value = "";
		thisForm.newIPAddress[2].value = ""; 
		thisForm.newIPAddress[3].value = "";
				
		}
	
	function checkVal(obj,pos)
		{
		//alert(obj.value);
		if ((window.event.keyCode >= 48 && window.event.keyCode <=58) || window.event.keyCode == 46)
			{if (obj.value.length == 3 || window.event.keyCode == 46)
				{if (pos < 3)
					{document[obj.form.name][obj.name][pos+1].focus();}
				}
			if (window.event.keyCode == 46)
				{return false;}
			}
		else
			{return false;}			
		
		}
	
	function setIPAddress(obj)
		{
		ipAddress = window.clipboardData.getData("Text")
		ipAddress = ipAddress.replace(/[ ]/g,"");
		isNaN(ipAddress.replace(/[.]/g,"")) ? badData = true : badData = false;
		if (!badData)
			{
			ipBits = ipAddress.split(".");
			if (ipBits.length == 4)
				{for (i=0; i < 4; ++i)
					{document[obj.form.name][obj.name][i].value = ipBits[i];}
				//document[obj.form.name][obj.name][3].focus();	
				}
			}
		else
			{return false;}	
		}	
//////////////////////////////////////////////////////////////////////////		





// Searches a select box for a pericular value passed in from a text field
function searchSelect(selectObj,textVal,selectIt)
	{
	//alert(textVal);
	if (selectObj.length > 0)
		{
		// Insert option at the end
		insertPoint = 1;
		// Select last option in box
		selectPoint = 0;
		strLength = 1;
		// Get the start letter of the last option
		// If the last option in the select box is less than the option text being serached
		if (textVal.toLowerCase().substring(0,1) > selectObj.options[selectObj.length-1].text.substring(0,1).toLowerCase())
			{
			// Insert option at the end
			insertPoint = selectObj.length+1;
			// Select last option in box
			selectPoint = selectObj.length;
			}
		// Otherwise find the start point for the start letter	
		else
			{
			// Find the start os the letter
			for (a=0; a < selectObj.length; ++a)
				{
				if (selectObj.options[a].text.substring(0,1).toLowerCase() >= textVal.substring(0,1).toLowerCase())
					{startAlphaPoint = a; break;}}
			
			// Did we get a match or go past?
			textVal.toLowerCase().substring(0,1) == selectObj.options[a].text.substring(0,1).toLowerCase() ? overShoot = false : overShoot = true
			// If we have gone past out letter, then our insert point is behind the index position
			if (overShoot == true)
				{	
				// Insert option at the end
				insertPoint = a+1;
				// Select last option in box
				selectPoint = a;
				}
			else
			// Otherwise, look for our string
				{	
				function findOption(startOption, strLength)
					{
					// Find a match for the string with no case
					foundOne = 0;
					for (o=startOption; o < selectObj.length; ++o)
						{
						if (selectObj.options[o].text.substring(0,strLength).toLowerCase() == textVal.substring(0,strLength).toLowerCase())
							{
							foundOne = 1;
							++strLength;
							break;
							}
						}
					// If string found, recurse and look for next char
					if (foundOne == 1 && strLength < textVal.length)
						{findOption(o,strLength);}
					// Otherwise matching complete	
					else
						{
						// If our serach string is below the current option, insert position is below
						if (textVal.toLowerCase().substring(0,strLength) < selectObj.options[startOption].text.substring(0,strLength).toLowerCase())
							{
							// Insert option at the end
							insertPoint = startOption+1;
							// Select last option in box
							selectPoint = startOption;
							}
						// Otherwise need to find the end of the match area	
						else
							{	
							// Go from the current option to the end or untill we reach the end of out match area
							for (r=startOption; r < selectObj.length; ++r)
								{
								// If we have gone past the match, set vars
								if ((textVal.toLowerCase().substring(strLength-1,strLength) > selectObj.options[r].text.substring(strLength-1,strLength).toLowerCase()) && (selectObj.options[r].text.substring(0,strLength-1).toLowerCase() == textVal.substring(0,strLength-1).toLowerCase()))
									{
									// Insert option at the end
									insertPoint = r+2;
									// Select last option in box
									selectPoint = r+1;
									}
								// Else if we have gone past out match area, break so we dont waste time looking at the rest of the options
								else
									{
									if (selectObj.options[r].text.substring(0,1).toLowerCase() != textVal.substring(0,1).toLowerCase())
										{break;}
									}	
								}
							}		
						}	
					}
					findOption(a, 1);
				}
			}		
		}
	else
		{
		// Insert option at the end
		insertPoint = 1;
		// Select last option in box
		selectPoint = 0;
		}
	if (selectIt == 1)
		{selectObj.options[selectPoint].selected = true;}
	return insertPoint;	
	}	

function insertOptionAt(selectObj, optionText, optionValue, optionPosition)
	{
	len = selectObj.length;
	for (i=len; i > optionPosition-1; --i)
		{selectObj.options[i] = new Option(selectObj.options[i-1].text, selectObj.options[i-1].value);}
	selectObj.options[optionPosition-1] = new Option(optionText,optionValue);	
	}	
	
function addKeyword(thisKeyword)
	{
	cleanKeyWord = thisKeyword.replace(/[ ]/g,"");
	exists = false;
	if (cleanKeyWord != "")
		{
		for (i=0; i < document.keywordList.keywords.options.length; ++i)
			{if (document.keywordList.keywords.options[i].text.toLowerCase() == cleanKeyWord.toLowerCase())
				{alert("Keyword " + cleanKeyWord + " already exists.      "); exists = true; break;}}
		
		if (exists == false)
			{
			searchSelect(document.keywordList.keywords,cleanKeyWord,"0");
			insertOptionAt(document.keywordList.keywords, cleanKeyWord, cleanKeyWord, insertPoint);
			}
		document.keywordForm.reset();
		document.keywordForm.Keyword.focus();
		document.keywordList.keywords.options[exists == true ? i : insertPoint-1].selected = true;
		}
	return false;
	}

function removeKeyword()
	{
	//alert(parseFloat(document.keywordForm.keywordItem.value)+1);
	document.keywordList.keywords.options[document.keywordForm.keywordItem.value].selected = false;
	removeOptionAt(document.keywordList.keywords,parseFloat(document.keywordForm.keywordItem.value)+1); 
	document.keywordForm.keywordFormButton.value = document.keywordForm.keywordFormButton.value.replace("Edit","Add");
	document.keywordForm.onsubmit = new Function("return addKeyword(this.Keyword.value);");
	document.keywordForm.Keyword.value = "";
	document.keywordForm.removeButton.style.visibility='hidden';	
	}
	
function editKeyword(thisSelect)
	{
	if(thisSelect.selectedIndex >=0 )
		{	
		document.keywordForm.Keyword.value = thisSelect[thisSelect.selectedIndex].text;
		document.keywordForm.keywordItem.value = thisSelect.selectedIndex;
		document.keywordForm.keywordFormButton.value = document.keywordForm.keywordFormButton.value.replace("Add","Edit");
		document.keywordForm.onsubmit = new Function("return updateKeyword(this);");
		document.keywordForm.removeButton.style.visibility = "visible";
		}
	return false;
	}

function updateKeyword(thisForm)
	{
	//alert(document.keywordForm.keywordItem.value);
	document.keywordList.keywords.options[document.keywordForm.keywordItem.value].text = thisForm.Keyword.value;
	document.keywordList.keywords.options[document.keywordForm.keywordItem.value].selected = false;
	//document.keywordForm.keywordItem.value = thisSelect.selectedIndex;
	document.keywordForm.keywordFormButton.value = document.keywordForm.keywordFormButton.value.replace("Edit","Add");
	document.keywordForm.onsubmit = new Function("return addKeyword(this.Keyword.value);");
	thisForm.Keyword.value = "";
	thisForm.Keyword.focus();
	return false;
	}	
		
// Remmoves a select box option at a give position.  Position is literal position, not index position	
function removeOptionAt(selectObj, optionPosition)
	{for (i=optionPosition; i < selectObj.length; ++i)
		{selectObj.options[i-1] = new Option(selectObj.options[i].text, selectObj.options[i].value);}
	selectObj.options[selectObj.length-1] = null;	
	}	
	
// Places all the options from a select box and places them into an array to feed into hidden form fields
function compileSelect(thisForm)
	{
	
	theValues = new Array();
	theKeywords = new Array();
	
	for (i=0; i < thisForm.keywords.length; ++i)
		{
		theKeywords[i] = thisForm.keywords.options[i].text;
		theValues[i] = thisForm.keywords.options[i].value;
		}
	thisForm.keywordValues.value = theValues;
	thisForm.keywordText.value = theKeywords;	
	return true;
	}

	
// Date popup function
function getCalander(form,field)
	{window.open("modules/content/calander.cfm?formName=" + form + "&fieldName=" + field,"calander","width=183,height=200");}

function getCalanderFrontEnd(form,field, format)
	{window.open("viewmodes/popupCalander.cfm?formName=" + form + "&fieldName=" + field + "&mask=" + format,"calander","width=183,height=200");}
	

function popContent(formName, fieldName, mode)//
					{window.open("modules/content/popContent.cfm?formName=" + formName + "&fieldName=" + fieldName + "&mode=" + mode,"popContent","width=600,height=510,status=1,resizable=1");}//	
	
// Sets the value in the status bar
function doStatus(value)
	{window.status = value;
	return true;}


// Returns a number holding 2 decimal places
function jsDecimal(number)
	{
	thisNumber = Math.round((number) * 100) / 100;	

	if (thisNumber.toString().indexOf(".") == -1)
		{thisNumber = thisNumber + ".00";}
	else
		{
		parts = thisNumber.toString().split(".");
		if (parts[1].length < 2)
			{thisNumber = thisNumber + "0";}
		}
	//alert(thisNumber);		
	return thisRounded = thisNumber;
	}	


document.onload = new function () {
							//alert(parent.window.frames.length);
							//if (parent.window.frames.length == 0)
							//	{parent.location.href = "index.cfm";}
							}	

// Selects all the options in a multi-select box
function selectAll(obj)
	{
	for (i=0; i < obj.options.length; ++i)
		{obj.options[i].selected = true;}
	}




		
function swapOptions(form,from,to)
	{
	// If the form can be found, continue
	if(typeof document[form] != "undefined")
		{
		// If the from field can be found, continue
		if(typeof document[form][from] != "undefined")
			{
			// If the to field can be found, continue
			if(typeof document[form][to] != "undefined")
				{
				// Set up the constant variables
				fromSelect	= document[form][from];
				toSelect	= document[form][to];
				fromLength 	= document[form][from].options.length - 1;
				toLength	= document[form][to].options.length
				swap		= new Array();
				// Create an array to hold the options to move, but remove them as we go
				for (i=fromLength; i >= 0; --i)
					{
					// If the option is selected, then add it into the array
					if (fromSelect.options[i].selected == true)
						{
						temp = new Array(i,fromSelect.options[i].text,fromSelect.options[i].value);
						swap.push(temp);
						fromSelect.options[i] = null;
						}
					}
				// Add the options back in but in the right order	
				swap.reverse();	
				for (i=0; i < swap.length; ++i)
					{
					toSelect.options[toLength+i] = new Option(swap[i][1],swap[i][2]);
					}
				}
			else
				{alert("the to field \"" + to + "\" does not exist.   ");}
			}
		else
			{alert("the From field \"" + from + "\" does not exist.   ");}
		}
	else
		{alert("the form \"" + form + "\" does not exist.   ");}
	}
	


function countDown()
	{
	hour 	= document.getElementById("sessionHour").value;
	minute	= document.getElementById("sessionMin").value;
	second	= document.getElementById("sessionSec").value;
	// If the second is greater that ZERO, decrement it
	if (second > 0)
		{
		if (second > 10)
			{document.getElementById("sessionSec").value = second - 1;}
		else
			{document.getElementById("sessionSec").value = "0" + (second - 1);}	
		}
	// If the second equals ZERO, set it back to 59 and decrement the minute
	else
		{
		document.getElementById("sessionSec").value = 59;
		// If the minute is greater than ZERO, decrement it		
		if (minute >= 1)
			{
			if (minute > 10)
				{document.getElementById("sessionMin").value = minute - 1;}
			else
				{document.getElementById("sessionMin").value = "0" + (minute - 1);}
			//alert(hour);	
			if (minute == 5 && hour == 0)
					{alert("You have 5 minutes remaining for your session before you will be automatically logged out.      \n                      Please save all information now before continuing.");}	
			}
		// If the minute equals ZERO, set it back to 59 and decrement the hour	
		else
			{
			if (hour > 0)
				{
				document.getElementById("sessionMin").value = 59;
				if (hour != 0)
					{document.getElementById("sessionHour").value = hour - 1;}
				}
			}
		}
		
	if (hour > 0)
		{setTimeout("countDown(document.getElementById('sessionHour').value,document.getElementById('sessionMin').value,document.getElementById('sessionSec').value);",1000);}
	else if (minute > 0)
		{setTimeout("countDown(document.getElementById('sessionHour').value,document.getElementById('sessionMin').value,document.getElementById('sessionSec').value);",1000);}	
	else
		{if (second > 1)
			{setTimeout("countDown(document.getElementById('sessionHour').value,document.getElementById('sessionMin').value,document.getElementById('sessionSec').value);",1000);}
		else
			{
			//document.getElementById("status").style.color = "red";
			alert("Your session has ended.     ");
			}	
		}		
	}	
				

function showHide(x)
	{if (typeof document.getElementById(x) != "undefined")
		{
		if (document.getElementById(x).style.display == "none")
			{action 	= "block";}
		else
			{action 	= "none";}
		document.getElementById(x).style.display = action;
		}
	}	
	
function showHideCats(x,img,folder,thisCategoryID,thisLevel,rowPos)
	{
	//alert(typeof document.getElementById(x));
	thisObject = document.getElementById(x);
	if (thisObject != null)
		{
		if (thisObject.style.display == "none")
			{
			action 	= "block";
			//bgSrc 	= "images/drill_mid_bg2.gif";
			//alert(document.images[img].src);
			imgSrc 	= document.images[img].src.replace("Plus","Minus");
			if (typeof document.images[folder] != "undefined")
				{folderImgSrc 	= document.images[folder].src.replace("Closed","Open");}
			//alert(imgSrc);
			}
		else
			{
			action 	= "none";
			imgSrc 	= document.images[img].src.replace("Minus","Plus");
			if (typeof document.images[folder] != "undefined")
				{folderImgSrc 	= document.images[folder].src.replace("Open","Closed");}
			//bgSrc 	= "images/drill_mid_bg.gif";
			//img 	= "images/drill_mid_plus.gif";
			}
			thisObject.style.display = action;
			document.images[img].src = imgSrc;
			
			if (typeof document.images[folder] != "undefined")
				{document.images[folder].src = folderImgSrc;}
			//document.getElementById("[x + "_bg"].src = bgSrc;	
			//document.getElementById("[x + "_img"].src = img;	
		}
	else
		{
		//alert(tmpVar);
		//document.getElementById("scriptDiv").innerHTML = "<script language=\"JavaScript\" src=\"scripts\\getNodeLevel.cfm?catID=" + thisCategoryID + "&level=" + thisLevel + "&item=" + x + "&img=" + img + "&folder=" + folder + "\"><\/script>";
		//document.getElementById("scriptInclude").src = "scripts/getNodeLevel.cfm?catID=" + thisCategoryID + "&level=" + thisLevel + "&item=" + x + "&img=" + img + "&folder=" + folder;
		document.getElementById("processCategory").src = "scripts/getNodeLevel.cfm?CategoryID=" + thisCategoryID + "&level=" + thisLevel + "&item=" + x + "&img=" + img + "&folder=" + folder + "&rowPosition=" + rowPos;
		//alert(tmpVar);
		}	

	}	

// Highlights Folders in tree view
function overFolder(folder,mode)
	{
	if (mode == "over")
		{document.images[folder].src = 	document.images[folder].src.replace(".gif","_over.gif");}
	else
		{document.images[folder].src = 	document.images[folder].src.replace("_over","");}	
	}	
	
function dropNav(x)
	{
	for (i=0; i < rootNavID.length; ++i)
		{
		//alert(rootNavID[i]);
		if (rootNavID[i] == x)
			{
			showHide(rootNavName[i]);
			break;
			}	
		}
	}	
rootNavID 	= new Array();
rootNavName = new Array();

/////////////////////////////////////////////////////////////////////////////////
////////    Categories Stuff                     ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
	function getCategory(formName, CategoryID)
		{document.getElementById("processCategory").src = "scripts/getCategoryInfo.cfm?CategoryID=" + CategoryID + "&formName=" + formName;}
		
	
	function editCategory(formName,Category)
		{
		// Get the array we need to populate the form fields for the category
		thisCategory 				= eval("cat_" + Category);
		//thisAssignedGroups 			= eval("AssignedGroups_" + Category);
		//thisAvailableGroups 		= eval("Available_" + Category);
		//thisAssignedMetadataGroups 	= eval("UnAvailableMetaDataGroups_" + Category);
		//thisAvailableMetadataGroups = eval("AvailableMetaDataGroups_" + Category);
		
		document[formName].CategoryID.value 				= thisCategory[0];

		// Select the ParentID for the category
		for (z=0; z < document.forms[0].ParentID.options.length; ++z)
			{if (document[formName].ParentID.options[z].value == thisCategory[1])
				{document.forms[0].ParentID.options[z].selected = true; break;}}
		
		document[formName].categoryname.value 				= thisCategory[2];
		
		if (thisCategory[3] == 1)
			{document[formName].status[0].checked 			= true;}
		else
			{document[formName].status[1].checked 			= true;}
		
		
		document[formName].sortorder.value 					= thisCategory[4];
		document[formName].externalurl.value 				= thisCategory[5];
		document[formName].internalurl.value 				= thisCategory[6];
		document[formName].target.value 					= thisCategory[7];
		
		if (thisCategory[8] == 1)
			{document[formName].footerItem[0].checked 		= true;}
		else
			{document[formName].footerItem[1].checked 		= true;}
		
		document[formName].applicationurl.value 			= thisCategory[9];
		
		if (thisCategory[10] == 1)
			{document[formName].hiddenItem[0].checked 		= true;}
		else
			{document[formName].hiddenItem[1].checked 		= true;}
		
		if (thisCategory[11] == 1)
			{document[formName].noLink[0].checked 		= true;}
		else
			{document[formName].noLink[1].checked 		= true;}
		
		
		// Change the values of the buttons
		document[formName].Add.value = Category == 0 ? document[formName].Add.value.replace("Update","Add") : document[formName].Add.value.replace("Add","Update");
		
		// Populate the AccessGroups for this category
		
		if (document[formName].Assigned.options.length > 0)
			{resetAccessGroups(formName);}
		//alert(thisCategory[thisCategory.length-2]);	
		for (a=0; a < thisCategory[thisCategory.length-2].length; ++a)
			{
			for(i=0; i < document[formName].Available.options.length; ++i)
				{
				//alert(thisCategory[thisCategory.length-2][a] == document[formName].Available.options[i].value);
				if (thisCategory[thisCategory.length-2][a] == document[formName].Available.options[i].value)
					{
					document[formName].Assigned.options[document[formName].Assigned.options.length] = new Option(document[formName].Available.options[i].text,document[formName].Available.options[i].value); 
					document[formName].Available.options[i] = null;
					break;
					}
				}
			}
			
		
		// Populate the Metadata Groups for this category
		
		if (document[formName].AssignedMetadataGroups.options.length > 0)
			{resetMetaDataGroups(formName);}
			
		for (a=0; a < thisCategory[thisCategory.length-1].length; ++a)
			{
			for(i=0; i < document[formName].AvailableMetadataGroups.options.length; ++i)
				{if (thisCategory[thisCategory.length-1][a] == document[formName].AvailableMetadataGroups.options[i].value)
					{
					document[formName].AssignedMetadataGroups.options[document[formName].AssignedMetadataGroups.options.length] = new Option(document[formName].AvailableMetadataGroups.options[i].text,document[formName].AvailableMetadataGroups.options[i].value); 
					document[formName].AvailableMetadataGroups.options[i] = null;
					break;
					}
				}
			}		
			
			//document[formName].AssignedMetadataGroups.options[a] = new Option(thisAssignedMetadataGroups[a][1],thisAssignedMetadataGroups[a][0]);}
			
		//alert(typeof document.getElementById("exeptionTable").style);
			
		if (document.getElementById("exeptionTable") != null)
			{document.getElementById("exeptionTable").style.display = "none";}
			
				
		}
	

	
	function resetAccessGroups(formName)
		{// Populate the AccessGroups for this category
		document[formName].Assigned.length = 0;
		document[formName].Available.length = 0;
		
		for (a=0; a < AccessGroups_All.length; ++a)
			{document[formName].Available.options[a] = new Option(AccessGroups_All[a][1],AccessGroups_All[a][0]);}	
		}	
		
	function resetMetaDataGroups(formName)
		{// Populate the MetaDataGroups for this category
		document[formName].AssignedMetadataGroups.length = 0;
		document[formName].AvailableMetadataGroups.length = 0;
		
		for (a=0; a < AccessGroups_All.length; ++a)
			{document[formName].AvailableMetadataGroups.options[a] = new Option(MetaDataGroups_All[a][1],MetaDataGroups_All[a][0]);}	
		}	
	
	function resetForm(formName)
		{
		document[formName].Add.value = "Add"; 
		resetAccessGroups(formName);
		resetMetaDataGroups(formName);
		document[formName].reset();
		}
	
	function whatToDo(x)
		{if (x == "Reset")
			{document.forms[0].reset();}
		else
			{document.forms[0].submit();}
		}
		
	function doFieldFocus(obj)
		{obj.style.background = "87B0D8";}
	function doFieldBlur(obj)
		{obj.style.background = "FFFFFF";}		
//////////////////////////////////////////////////////////////////////////////
function resizeContentDiv()
		{
		
		if (navigator.appName.toLowerCase() == "netscape")
			{
			titleHeight = parseFloat(document.getElementById("sectionTitle").style.height.replace("px",""));
			titleHeight = titleHeight + 11;
			mainHeight = document.getElementById("mainContent").offsetHeight;
			mainWidth = document.getElementById("mainContent").offsetWidth;
			windowHeight = this.window.innerHeight;
			windowWidth = this.window.innerWidth;
			if (mainWidth > windowWidth)
				{document.getElementById("mainContent").style.width = windowWidth-1;}
			else
				{document.getElementById("mainContent").style.width = "100%";}	
			//document.getElementById("sectionTitle").style.width = windowWidth-2;
			document.getElementById("mainContent").style.height = windowHeight - titleHeight;
			}
		else
			{
			
			titleHeight = document.all.sectionTitle.offsetHeight;
			obj = document.all.sectionTitle;
			
			//alert(document.all.sectionTitle.offsetHeight);
			statusHeight = typeof document.all.statusBar != "undefined" ? document.all.statusBar.clientHeight : 0;
			mainHeight = document.all.mainContent.clientHeight;
			mainWidth = document.all.mainContent.clientHeight;
			thisWindowHeight = this.window.frameElement.clientHeight;
			thisWindowWidth = this.window.frameElement.width-4;
			//alert(thisWindowHeight - titleHeight - statusHeight);
			//alert(thisWindowHeight - titleHeight);
			//document.all.mainContent.style.pixelHeight = (thisWindowHeight - titleHeight);
			//alert(document.all.mainContent.style.pixelHeight);
			//document.all.mainContent.style.pixelWidth = thisWindowWidth;
			
			//alert(document.all.filetext_frame);
			
			if (typeof document.all.filetext_frame != "undefined")
				{
				
				if (document.all.filetext_frame.tagName.toLowerCase() == "textarea")
					{
					if (document.all.filetext_frame.wrap == "off")
						{document.all.filetext_frame.style.height = (thisWindowHeight - titleHeight - statusHeight)-10;}
					else
						{document.all.filetext_frame.style.height = (thisWindowHeight - titleHeight)-2;}	
					document.all.filetext_frame.style.height = document.all.filetext_frame.clientHeight-2;	
					}	
				else
					{
					//document.all.filetext_frame.style.height = (thisWindowHeight - titleHeight - statusHeight)-28;
					}
				}
			
			document.all.mainContent.style.pixelHeight = (thisWindowHeight - titleHeight)-2;
			
			}
			
		}
