
	// go to another page in doc listing
	function changePage(whichPage)	{
		document.menuForm.pageNumber.value = whichPage;
		document.menuForm.submit();
	}

	// popup window	
	function popwin(page,wid,hght,winname)	{
		window.open(page, winname, "width="+wid+",height="+hght+",scrollbars=yes");
	}

	// Updates the textbox
	function showhelptext(texttoshow)	{
		document.forms[0].helptext.value = texttoshow
	}

	// Sets textbox back to default
	function returntext()	{
		document.forms[0].helptext.value = "<! -- MMI MAIN MENU-- !>"
	}
	
	// Checks before deleting
	function checkDelete(urlToGoTo)	{
		if (confirm('Are you sure you want to delete this asset type. Deleting will also delete all the sub types below it'))	{
			parent.edit.location.href = urlToGoTo
		}
	}

	// Find an object on a page
	function MM_findObj(n, d) { //v3.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
	}

	
	function changeHighlight(showWhichMenu, allowClick)	{

		if (allowClick == '1' || allowClick == 1)		{
			lastSelected = document.menuForm.aType.value

			showLoc = document.getElementById("topLevel" + showWhichMenu)
			hideLoc = document.getElementById("topLevel" + lastSelected)

			if (showWhichMenu == '0')	{
				showClass = 'topLevelFolderSelected'
			} else { 
				showClass = 'secondLevelFolderSelected'
			}

			if (lastSelected == '0')	{
				hideClass = 'topLevelFolder'
			} else {
				hideClass = 'secondLevelFolder'
			}

			hideLoc.className  = hideClass
			showLoc.className  = showClass

			document.menuForm.aType.value = showWhichMenu
		}	else	{
			alert("Sorry this can't be changed now the type has been created")
		}
	}



	function changeHighAsset(showWhichMenu, allowClick, caption)	{

		if (allowClick == '1' || allowClick == 1)
		{
			lastSelected = document.menuForm.joined.value

			showLoc = document.getElementById("topLevel" + showWhichMenu)
			hideLoc = document.getElementById("topLevel" + lastSelected)

			showWhichMenuIndex = showWhichMenu.indexOf("_")
			lastSelectedIndex = lastSelected.indexOf("_")
			//alert(showWhichMenuIndex + " - " + lastSelectedIndex)

			if (showWhichMenuIndex == -1)	{
				showClass = 'topLevelFolderSelected'
			} else {
				showClass = 'secondLevelFolderSelected'
			}

			if (lastSelectedIndex == -1)	{
				hideClass = 'topLevelFolder'
			} else {
				hideClass = 'secondLevelFolder'
			}


			if (hideLoc)	{					// can break the first time as we have nothing to hide
				hideLoc.className  = hideClass
			}
			showLoc.className  = showClass

			if (lastSelectedIndex != -1 )	{
				splitValues = showWhichMenu.split("_")
				aType = splitValues[0]
				aSType = splitValues[1]
			}	else	{
				aType = showWhichMenu
				aSType = ""
			}
			
			document.menuForm.joined.value = showWhichMenu
			document.menuForm.assetLocation.value = caption
			document.menuForm.aType.value = aType
			document.menuForm.aSType.value = aSType
		}	else	{
			alert("Sorry this can't be changed now the type has been created")
		}
	}


	function refreshTree()	{
		document.parent.main.location.href = "adminlist.asp"
	}


	function validateForm()	{

		errorMsg = ""
		allOK = 1

		if (document.forms[0].aType.value == "0" || document.forms[0].aSType.value == "0")	{
			allOK = 0
			errorMsg += " - please select a asset type and sub type from the Location list \n"
		}

		if (document.forms[0].assetName.value.replace(" ","") == "")	{
			allOK = 0
			errorMsg += " - please enter a name for this asset\n"
		}


		// Only need to check this if it's an add op
		if (document.forms[0].op.value == "add")	{
			if (document.forms[0].uploadFile.checked == true)	{
				//if (document.forms[0].uploadFile.checked)	{
				//}
				//allOK = 0
				//errorMsg += " - please enter a name for this asset\n"
			}
		}

		if (allOK == 1)	{
			document.forms[0].submit();
		}	else	{
			alert(errorMsg);
		}
		
	}

	function doSearch()	{
		if (document.menuForm.quickSearch.value != 'Search')	{
			parent.edit.location.href = "assetList.asp?keywords=" + document.menuForm.quickSearch.value
		}
	}

	function isSomethingTicked()	{
		for (i = 1; i < totalTicks; i++)	{
			currentTick = "document.assetListHolder.as_" + i + ".checked"
			if (eval(currentTick) == true)	{	
				return true;
			}
		}
	}
	
	function changeTickedStatus()	{
		if (document.assetListHolder.checkAll.checked == true)	{	whichWay = true	}	else {	whichWay = false	}

		for (i = 1; i < totalTicks; i++)	{
			currentTick = "document.assetListHolder.as_" + i + ".checked";
			eval(currentTick + " = " + whichWay)
		}
	}
	
	function makeMassChange(whichOp)	{
		if (isSomethingTicked() == true)	{
			if (confirm("Are you sure you want to make this bulk change ? ") == true)	{
				document.assetListHolder.op.value = whichOp
				document.assetListHolder.submit()
			}
		} else	{
			alert("please tick one or more boxes to perform this action")
		}
	}


	function moveValidate()	{

		errorMsg = ""
		allOK = 1

		if (document.forms[0].aType.value == "0" || document.forms[0].aSType.value == "0")	{
			allOK = 0
			errorMsg += " - please select a asset type and sub type from the Location list \n"
		}

		if (allOK == 1)	{
			document.forms[0].submit();
		}	else	{
			alert(errorMsg);
		}
		
	}



	// Changes the class of a div to hide or show content
	function showHidesubItem(subMenuNo)	{
		//hiddenHolder = document.forms[0].assetTypesActive
		docLoc = document.getElementById("subItem" + subMenuNo)
		if (docLoc.className  == 'visible')	{
			docLoc.className  = 'hidden'
			assetTypesActive = killArrayElement(subMenuNo)
			//hiddenHolder.value = assetTypesActive.join()
		}	else	{
			docLoc.className  = 'visible'
			assetTypesActive.push(subMenuNo)
			//hiddenHolder.value = assetTypesActive.join()
		}
	}

	function killArrayElement(elementNo)	{
		var tempArray = new Array()
		for (i=0 ; i<assetTypesActive.length ; i++)	{
			if (assetTypesActive[i] != elementNo)	{
				tempArray.push(assetTypesActive[i])
			}
		}
		return tempArray
	}


	function refreshPage()	{
		hiddenHolder = document.menuForm.assetTypesActive.value
		document.location.href = "adminList.asp?assetTypesActive=" + hiddenHolder
	}