// JavaScript Document
<!-- 

function deleteImage() {
/********************************************
DATE ADDED: 5th March 2006
*********************************************/

	if (confirm("You are about to delete this image.\n\nAre you sure you want to continue?")) {
		document.frm_item.thumbnail_exists.value = "N";
		document.frm_item.submit()
		
	}

}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function fncDisable(chknum) {
/********************************************
DESCRIPTION: toggles email field enabled/disabled for 
directory entries that dont have an email address
PARAMETERS: check number
RETURNS: nothing (enables/disables email text box)
DATE ADDED: 19th January 2005
DATE UPDATED: 
*********************************************/
	if (document.staffDir["chk"+chknum].checked == false) {
		document.staffDir["email"+chknum].disabled = false;
		document.staffDir["email"+chknum].value = "";
	} else {
		document.staffDir["email"+chknum].disabled = true;
		document.staffDir["email"+chknum].value = "no-email@bpc.ac.uk";
	}
}  

function toggleExpiryDate(itemName) {
/********************************************
DESCRIPTION: toggles 'enabled/disabled' expiry date fields 
DATE ADDED: 8th June 2005
DATE UPDATED: 
*********************************************/
	if (document.edit[itemName + "Check"].checked == true) {
		document.edit[itemName + "Day"].disabled = true;
		document.edit[itemName + "Month"].disabled = true;
		document.edit[itemName + "Year"].disabled = true;
	} else {
		document.edit[itemName + "Day"].disabled = false;
		document.edit[itemName + "Month"].disabled = false;
		document.edit[itemName + "Year"].disabled = false;
	}
}  


function changePassword(myForm) {
/********************************************
DESCRIPTION: check the admn area password details before updating
PARAMETERS: form
RETURNS: returns true or false.
*********************************************/

	// current password validation
	var field = myForm.password; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0) {
		alert("Please enter your existing password."); 
		field.focus();
		field.select();
		return false;
  	}

	// new password validation
	var field = myForm.new_password; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!((strTemp.length >= 6) && (strTemp.length <= 12))){
		alert("Please enter a new password, 6 - 12 characters long."); 
		field.focus();
		field.select();
		return false;
  	}

	// password confirm validation
	var pwdField = myForm.new_password; // field
	var pwdConfirmField = myForm.confirm_password; // field
  	var strTemp1 = pwdField.value; // string
  	var strTemp2 = pwdConfirmField.value; // string
	strTemp1 = trimAll(strTemp1);
	strTemp2 = trimAll(strTemp2);
	if(strTemp1 != strTemp2){
		alert("Please confirm your new password correctly."); 
		pwdConfirmField.focus();
		pwdConfirmField.select();
		return false;
  	}

}

function emailValid(email) {
/********************************************
DESCRIPTION: email address validator
PARAMETERS: email field to validate
RETURNS: if the field is a valid email address function returns true.
*********************************************/
	
	// email validation
	var field = email; // email field
  	var str = field.value; // email string
  	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  	if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
		return true;
  	}
  	else {
		alert("The email address you entered isn't a valid one."); 
		field.focus();
		field.select();
		return false;
  	}
}


function athensCheck(myForm){
/********************************************
DESCRIPTION: checks athens info on input
DATE ADDED: 19th September 2005
DATE UPDATED: -
*********************************************/
	// first name validation
	var field = myForm.firstname; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a first name."); 
		field.focus();
		field.select();
		return false;
  	}

	// surname validation
	var field = myForm.surname; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a surname."); 
		field.focus();
		field.select();
		return false;
  	}

	//email validation
	var field = myForm.email; 
	if (!emailValid(field)) {
		return false;
	}

	//check box for accepting privacy policy
	var field = myForm["accept"];  
	if (!field.checked) {
		alert("You need to accept The College's Privacy Policy");
		return false
	}
}


function eNewsSignUpCheck(myForm){
	// first name validation
	var field = myForm.firstname; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter your first name."); 
		field.focus();
		field.select();
		return false;
  	}

	// surname validation
	var field = myForm.surname; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter your surname."); 
		field.focus();
		field.select();
		return false;
  	}

	//email validation
	var field = myForm.email; 
	if (!emailValid(field)) {
		return false;
	}

	//check box for accepting privacy policy
	var field = myForm["accept"];  
	if (!field.checked) {
		alert("You need to accept The College's Privacy Policy");
		return false
	}
}

function contactCheck(myForm){

	// enquiry type validation
	var locTemp = myForm["type"];
	categoryChoice = locTemp.selectedIndex
	if (locTemp.options[categoryChoice].value == 0) {
		alert("What kind of enquiry is this? \n\nPlease choose, so that we can get the right people to respond!")
		locTemp.focus()
		return false
	}
	
	// first name validation
	var field = myForm.firstname; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter your first name."); 
		field.focus();
		field.select();
		return false;
  	}

	// surname validation
	var field = myForm.surname; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter your surname."); 
		field.focus();
		field.select();
		return false;
  	}

	var field = myForm.email; // field
	if (!emailValid(field)) {
		return false;
	}
	
	// enquiry validation
	var field = myForm.message; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter an enquiry!"); 
		field.focus();
		field.select();
		return false;
  	}

	return true;
}

function emailPageCheck(emailOne, emailTwo) {
/********************************************
DESCRIPTION: email-a-page-to-a-friend check

RETURNS: if all the required email addresses
are valid addresses function returns true.
*********************************************/

	if (!emailValid(emailOne)) {
		return false;
	}
	if (!emailValid(emailTwo)) {
		return false;
	}
	return true;
}

function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function submitCalendarEvent(myForm) {
/************************************************
DESCRIPTION: Checks the add event form on submit
DATE ADDED: 14th June 2005
DATE UPDATED: 
*************************************************/

	// event title validation
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a event title."); 
		field.focus();
		field.select();
		return false;
  	}

	// salary validation
	var field = myForm.description; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a summary/description."); 
		field.focus();
		field.select();
		return false;
  	}

	// hours per week validation
	var field = myForm.details; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter details of the event."); 
		return false;
  	}

	//if all the checks pass then you'll end up here...
	return true
}

function submitJobshopAdd(myForm) {
/************************************************
DESCRIPTION: Checks the Add Jobshop form on submit
RETURNS: alerts if any of the fields are invalid or returns true
DATE ADDED: 8th November 2005
DATE UPDATED: -
*************************************************/

	// job category validation
	var locTemp = myForm["category"];
	categoryChoice = locTemp.selectedIndex
	if (locTemp.options[categoryChoice].value == 0) {
		alert("Please select a job category.")
		locTemp.focus()
		return false
	}
	
	// job title validation
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a job title."); 
		field.focus();
		field.select();
		return false;
  	}

	// contact person validation
	var field = myForm.contact_person; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a contact person."); 
		field.focus();
		field.select();
		return false;
  	}
	
	// company validation
	var field = myForm.company; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a company name."); 
		field.focus();
		field.select();
		return false;
  	}

	// location validation
	var field = myForm.location; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a location."); 
		field.focus();
		field.select();
		return false;
  	}

	// rate of pay validation
	var field = myForm.pay; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a rate of pay."); 
		field.focus();
		field.select();
		return false;
  	}
	
	// hours of work validation
	var field = myForm.hours_of_work; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter the hours of work."); 
		field.focus();
		field.select();
		return false;
  	}


	// job description validation
	var field = myForm.description; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a job description!"); 
		return false;
  	}

	//if all the checks pass then you'll end up here...
	return true
}

function submitAddJob(myForm) {
/************************************************
DESCRIPTION: Checks the Add Job form on submit
PARAMETERS: form name
RETURNS: alerts if any of the fields are invalid or returns true
DATE ADDED: -
DATE UPDATED: 16th February 2005
*************************************************/

	// job title validation
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a job title."); 
		field.focus();
		field.select();
		return false;
  	}

	// job category validation
	var locTemp = myForm["category"];
	categoryChoice = locTemp.selectedIndex
	if (locTemp.options[categoryChoice].value == 0) {
		alert("Please select a job category.")
		locTemp.focus()
		return false
	}
	
	// post number validation
	var field = myForm.postNumber; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a post number."); 
		field.focus();
		field.select();
		return false;
  	}

	// salary validation
	var field = myForm.salary; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a salary."); 
		field.focus();
		field.select();
		return false;
  	}

	// location validation
	var locTemp = myForm["location"];
	locationChoice = locTemp.selectedIndex
	if (locTemp.options[locationChoice].value == 0) {
		alert("Please select a job location.")
		locTemp.focus()
		return false
	}
	
	// hours per week validation
	var field = myForm.hoursPerWeek; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter the hours per week."); 
		field.focus();
		field.select();
		return false;
  	}

	// teaching post? validation
	var locTemp = myForm["teaching_post"];
	categoryChoice = locTemp.selectedIndex
	if (locTemp.options[categoryChoice].value == 0) {
		alert("Is this vacancy a teaching post?")
		locTemp.focus()
		return false
	}
	
	// job description validation
	var field = myForm.article; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a Job Description."); 
		return false;
  	}

	//if all the checks pass then you'll end up here...
	return true
}



function submitStaffAdd(myForm, jsLocCount) {
	
	// surname validation
	var field = myForm.surname; // surname field
  	var strTemp = field.value; // surname string

	strTemp = trimAll(strTemp);
	if(strTemp.length > 0){
		//return true;
  	} else {
		alert("Please enter a surname."); 
		field.focus();
		field.select();
		return false;
  	}

	//email check
	var field = myForm.email1; // field
	if (!emailValid(field)) {
		return false;
	}
	
	// loop through and check all the visible location entries
	for (i = 1; i <= jsLocCount; i++){
		
		// job title validation
		var field = myForm["job_title"+i]; // job title field
		var strTemp = field.value; // job title string
	
		strTemp = trimAll(strTemp);
		if(strTemp.length > 0){
			//return true;
		} else {
			alert("Please enter a Job Title in the 'location " + i + "' option."); 
			field.focus();
			field.select();
			return false;
		}
		
		// department check
		var workAreaTemp = myForm["workarea"+i];
		var deptTemp = myForm["deptid"+i];
		departmentChoice = deptTemp.selectedIndex
		if (deptTemp.options[departmentChoice].value == 0) {
			alert("You need to select a Department in the 'location " + i + "' option.")
			workAreaTemp.focus()
			return false
		}
		
		// location check
		var locTemp = myForm["location"+i];
		locationChoice = locTemp.selectedIndex
		if (locTemp.options[locationChoice].value == 0) {
			alert("You need to select a location in the 'location " + i + "' option.")
			locTemp.focus()
			return false
		}
		
		// telephone number check
		re = /(^\d{4}$)/;		
		var phoneTemp = myForm["phone"+i];
		validPhone = re.exec(phoneTemp.value)
		if (!validPhone) {
			alert("Please enter a valid telephone extension for location " + i + ", ie - 4 digits.")
			phoneTemp.focus()
			phoneTemp.select()
			return false
		}
		
	}
	
	//if all the checks pass then you'll end up here...
	return true
}

function submitStaffEdit(myForm, jsLocCount) {
	
	// surname validation
	var field = myForm.surname; // surname field
  	var strTemp = field.value; // surname string

	strTemp = trimAll(strTemp);
	if(strTemp.length > 0){
		//return true;
  	} else {
		alert("Please enter a surname."); 
		field.focus();
		field.select();
		return false;
  	}

	//email check
	var field = myForm.email1; // field
	if (!emailValid(field)) {
		return false;
	}
	
	// loop through and check all the visible location entries
	for (i = 1; i <= jsLocCount; i++){
		
		// job title validation
		var field = myForm["job_title"+i]; // job title field
		var strTemp = field.value; // job title string
	
		strTemp = trimAll(strTemp);
		if(strTemp.length > 0){
			//return true;
		} else {
			alert("Please enter a Job Title in the 'location " + i + "' option."); 
			field.focus();
			field.select();
			return false;
		}
		
		// department check
		var workAreaTemp = myForm["workarea"+i];
		var deptTemp = myForm["deptid"+i];
		departmentChoice = deptTemp.selectedIndex
		if (deptTemp.options[departmentChoice].value == 0) {
			alert("You need to select a Department in the 'location " + i + "' option.")
			workAreaTemp.focus()
			return false
		}
		
		// location check
		var locTemp = myForm["location"+i];
		locationChoice = locTemp.selectedIndex
		if (locTemp.options[locationChoice].value == 0) {
			alert("You need to select a location in the 'location " + i + "' option.")
			locTemp.focus()
			return false
		}
		
		// telephone number check
		re = /(^\d*$)/;		
		var phoneTemp = myForm["phone"+i];
		validPhone = re.exec(phoneTemp.value)
		if (!validPhone) {
			alert("Please enter a valid telephone extension/number for location " + i + ".")
			phoneTemp.focus()
			phoneTemp.select()
			return false
		}
		
	}
	
	//if all the checks pass then you'll end up here...
	return true
}



//email-a-friend function
var popUpWin=0;
function emailPage(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

//general window opener function
var popUpWin=0;
function generalPop(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin.focus()
}

//help window opener function
var helpPopUpWin=0;
function helpPop(URLStr, left, top, width, height)
{
  if(helpPopUpWin)
  {
    if(!helpPopUpWin.closed) helpPopUpWin.close();
  }
  helpPopUpWin = open(URLStr, 'helpPopUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  helpPopUpWin.focus()
}

//general window opener function
var popUpWin=0;
function addLocationPop(staffID)
/********************************************
DESCRIPTION: opens the new location window
DATE ADDED: December 2004
DATE UPDATED: 22nd February 2005
*********************************************/
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open('/admin/phone/addLocation.php?sid='+staffID, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=460,height=310,left=100, top=100,screenX=100,screenY=100');
}


function deleteStaffMember(staffID) {
	if (confirm("You are about to delete this staff member from the system.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/phone/index.php?action=delete&sid=" + staffID;
	}
}

function deleteJobItem(jobID) {
	if (confirm("You are about to delete this job.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/jobs/index.php?action=delete&jid=" + jobID;
	}
}

function deleteJobshopJob(jobshopID) {
	if (confirm("You are about to delete this job.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/jobshop/index.php?a=d&jid=" + jobshopID;
	}
}

function deleteStaffLocation(lID,sID) {
	if (confirm("You are about to delete this location.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/phone/edit.php?action=delete&lid=" + lID + "&sid=" + sID;
	}
}

function deleteFeatureItem(ID) {
	if (confirm("You are about to delete this feature.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/features/index.php?a=d&id=" + ID;
	}
}

function deleteAthensItem(aID) {
	if (confirm("You are about to delete this Athens Login Request.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/athens/index.php?a=d&aid=" + aID;
	}
}

function deleteJobshopItem(jID) {
	if (confirm("You are about to delete this person from the mailing list.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/jobshop/registered.php?a=d&jid=" + jID;
	}
}


function locationCheck(myForm) {
/********************************************
DESCRIPTION: checks valid input before submitting to add new location to a staff member in the directory
DATE ADDED: 2004
DATE UPDATED: 19th January 2005
*********************************************/

	// job title check
	var field = myForm.job_title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a job title."); 
		field.focus();
		field.select();
		return false;
  	}

	// department check
	var workAreaTemp = myForm["workarea"];
	var deptTemp = myForm["deptid"];
	deptChoice = deptTemp.selectedIndex;
	if (deptTemp.options[deptChoice].value == 0) {
		alert("Please select a department.");
		workAreaTemp.focus();
		return false
	}
	
	// location check
	var locTemp = myForm["location"];
	locationChoice = locTemp.selectedIndex;
	if (locTemp.options[locationChoice].value == 0) {
		alert("Please select a location.");
		locTemp.focus();
		return false
	}
	
	// telephone number check
	var field = myForm.phone; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a telephone number."); 
		field.focus();
		field.select();
		return false;
  	}

	return true
}


function checkAddNews(myForm) {
/********************************************
DESCRIPTION: checks 1st news article submission form
DATE ADDED: 3rd February 2005
DATE UPDATED: -
*********************************************/

	// article title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a title for the article."); 
		field.focus();
		field.select();
		return false;
  	}

	// article summary check
	var field = myForm.summary; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a summary for the article."); 
		field.focus();
		field.select();
		return false;
  	}

	// article summary check
	var field = myForm.article; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter text for the article."); 
		return false;
  	}

	// image caption check
	var field = myForm.article_img; // field
	var field2 = myForm.article_image_caption;
	var strTemp = field.value; // string
	var strTemp2 = field2.value; // string
	strTemp = trimAll(strTemp);
	strTemp2 = trimAll(strTemp2);
	if(strTemp.length > 0){
		if(!strTemp2.length > 0){
			alert("Please add a caption for the article image."); 
			field2.focus();
			field2.select();
			return false;
		}
  	}

return true;
}

function checkEditNews(myForm) {
/********************************************
DESCRIPTION: checks 1st news article submission form
DATE ADDED: 3rd February 2005
DATE UPDATED: -
*********************************************/

	// article title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a title for the article."); 
		field.focus();
		field.select();
		return false;
  	}

	// article summary check
	var field = myForm.summary; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a summary for the article."); 
		field.focus();
		field.select();
		return false;
  	}

	// article summary check
	var field = myForm.article; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter text for the article."); 
		return false;
  	}

	// image caption check
	var field = myForm.article_image_status; // article image status. does the article already have a main image?
	var field2 = myForm.article_image_caption;
	var strTemp = field.value; // string
	var strTemp2 = field2.value; // string
	strTemp = trimAll(strTemp);
	strTemp2 = trimAll(strTemp2);
	if(strTemp == "Y"){
		if(!strTemp2.length > 0){
			alert("Please add a caption for the article image."); 
			field2.focus();
			field2.select();
			return false;
		}
  	}

return true;
}


function checkAddDocument(myForm) {
/********************************************
DESCRIPTION: checks agent document add form
DATE ADDED: 25th April 2005
DATE UPDATED: -
*********************************************/

	// article title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please enter a title for the document."); 
		field.focus();
		field.select();
		return false;
  	}

	// article summary check
	var field = myForm.agent_document; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(!strTemp.length > 0){
		alert("Please select a document."); 
		field.focus();
		field.select();
		return false;
  	}

return true;
}

function userConfiguration(myForm) {
/********************************************
DESCRIPTION: checks password exists before submits for configuration
DATE ADDED: 24th May 2005
DATE UPDATED: -
*********************************************/

	// article title check
	var field = myForm.password; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length < 6){
		alert("Please enter a password (minimum 6 characters)."); 
		field.focus();
		field.select();
		return false;
  	}

return true;
}

function submitAddFeature(myForm) {
/********************************************
DESCRIPTION: checks required fields before submit
DATE ADDED: 8th June 2005
DATE UPDATED: -
*********************************************/

	// long title check
	var field = myForm.title_long; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title."); 
		field.focus();
		field.select();
		return false;
  	}

	// short title check
	var field = myForm.title_short; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a short version of the title."); 
		field.focus();
		field.select();
		return false;
  	}

	// location check
	var locTemp = myForm["scheme"];
	locationChoice = locTemp.selectedIndex;
	if (locTemp.options[locationChoice].value == 0) {
		alert("Please select a location.");
		locTemp.focus();
		return false
	}

	// summary check
	var field = myForm.summary; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a summary."); 
		field.focus();
		field.select();
		return false;
  	}

	// short title check
	var field = myForm.flash_file; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please provide a flash movie!"); 
		field.focus();
		field.select();
		return false;
  	}

return true;
}

function submitFeature(myForm) {
/********************************************
DESCRIPTION: checks required fields before submit
DATE ADDED: 7th June 2005
DATE UPDATED: -
*********************************************/

	// long title check
	var field = myForm.title_long; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title."); 
		field.focus();
		field.select();
		return false;
  	}

	// short title check
	var field = myForm.title_short; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a short version of the title."); 
		field.focus();
		field.select();
		return false;
  	}

	// location check
	var locTemp = myForm["scheme"];
	locationChoice = locTemp.selectedIndex;
	if (locTemp.options[locationChoice].value == 0) {
		alert("Please select a location.");
		locTemp.focus();
		return false
	}

	// summary check
	var field = myForm.summary; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a summary."); 
		field.focus();
		field.select();
		return false;
  	}

return true;
}

function externalURLCheck(myForm) {
/********************************************
DESCRIPTION: checks valid input for external related links on news articles
DATE ADDED: 31st January 2005
DATE UPDATED: 29th April 2005
*********************************************/

	// job title validation
	var field = myForm["new_link_title"]; // new link field
	var strTemp = field.value; // new link string
	strTemp = trimAll(strTemp);

	var URLfield = myForm["new_link_url"];
	var URLstrTemp = URLfield.value;
	URLstrTemp = trimAll(URLstrTemp);

	if (((strTemp.length > 0) && (URLstrTemp.length > 0)) || ((strTemp.length <= 0) && (URLstrTemp.length <= 0))){
		//return true;
	} else {
		if (strTemp.length > 0){
			alert("Please enter a URL for the new link."); 
			URLfield.focus();
			URLfield.select();
		} else {
			alert("Please enter a title for the new link."); 
			field.focus();
			field.select();
		}
		return false;
	}
return true;

}

function checkElibraryNews(myForm) {
/********************************************
DESCRIPTION: checks valid input for eLibrary news messages
DATE ADDED: 14th July 2005
DATE UPDATED: -
*********************************************/

	// title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title"); 
		field.focus();
		field.select();
		return false;
  	}

	// message check
	var field = myForm.message; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a news message"); 
		field.focus();
		field.select();
		return false;
  	}

return true;

}

function checkAlibrary(myForm) {
/********************************************
DESCRIPTION: checks valid input for eLibrary additional libraries
DATE ADDED: 15th July 2005
DATE UPDATED: -
*********************************************/

	// name check
	var field = myForm.name; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a library name"); 
		field.focus();
		field.select();
		return false;
  	}

	// link URL check
	var field = myForm.link_URL; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 7){
		alert("Please enter a valid link to the library catalogue"); 
		field.focus();
		field.select();
		return false;
  	}

	// homepage URL check
	var field = myForm.home_URL; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 7){
		alert("Please enter a valid link to the library homepage"); 
		field.focus();
		field.select();
		return false;
  	}

return true;

}

function checkEDb(myForm) {
/********************************************
DESCRIPTION: checks valid input for eLibrary Databases
DATE ADDED: 12th July 2005
DATE UPDATED: -
*********************************************/

	// title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title"); 
		field.focus();
		field.select();
		return false;
  	}

	// URL check
	var field = myForm.link_URL; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 7){
		alert("Please enter a valid link to the database"); 
		field.focus();
		field.select();
		return false;
  	}

	// description check
	var field = myForm.description; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a description"); 
		field.focus();
		field.select();
		return false;
  	}

return true;

}

function checkElibrarySubguide(myForm) {
/********************************************
DESCRIPTION: checks valid input for eLibrary Databases
DATE ADDED: 12th July 2005
DATE UPDATED: -
*********************************************/

	// title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title"); 
		field.focus();
		field.select();
		return false;
  	}

return true;

}

function checkRally(myForm) {
/********************************************
DESCRIPTION: checks valid input for Rally form
DATE ADDED: 8th January 2006
DATE UPDATED: -
*********************************************/

	// title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title"); 
		field.focus();
		field.select();
		return false;
  	}

	// location check
	var field = myForm.location; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a location"); 
		field.focus();
		field.select();
		return false;
  	}

	// marshal check
	var field = myForm.marshal01_contact_name; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter an event marshal"); 
		field.focus();
		field.select();
		return false;
  	}

return true;

}

function checkCareerGuide(myForm) {
/********************************************
DESCRIPTION: checks valid input for eLibrary Databases
DATE ADDED: 8th November 2005
DATE UPDATED: -
*********************************************/

	// title check
	var field = myForm.title; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter a title"); 
		field.focus();
		field.select();
		return false;
  	}

	// overview check
	var field = myForm.overview; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter an overview."); 
		field.focus();
		field.select();
		return false;
  	}

	// further study check
	var field = myForm.further_study; // field
  	var strTemp = field.value; // string
	strTemp = trimAll(strTemp);
	if(strTemp.length <= 0){
		alert("Please enter further study details."); 
		field.focus();
		field.select();
		return false;
  	}

return true;

}

function itemSelect(myField) {
/********************************************
DESCRIPTION: checks a selection has been made from list
DATE ADDED: 23rd February 2005
DATE UPDATED: -
*********************************************/

  var strTemp = myField.value; // new link string
  if (myField.length) {
      for (i = 0; i < myField.length; i++) {
         if (myField[i].checked) {
            return true;
         }
      }
   }
   else {
      if (myField.checked) {
         return true;
      }
   }
	alert("Please make a selection!");
	return false;
}


function deleteItem(ID) {
/********************************************
DESCRIPTION: confirms action, before item is deleted
DATE ADDED: 10th January 2006
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this item.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "index.php?a=d&id=" + ID;
	}
}

function deleteDraftArticle(aID) {
/********************************************
DESCRIPTION: confirms action, before a draft article is deleted
DATE ADDED: 15th February 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this draft article.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/news/draft.php?a=d&aid=" + aID;
	}
}

function deletePendingArticle(aID) {
/********************************************
DESCRIPTION: confirms action, before a submitted article is deleted
DATE ADDED: 5th May 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this submitted article.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/newspublisher/index.php?a=d&aid=" + aID;
	}
}

function deleteCourse(cID) {
/********************************************
DESCRIPTION: confirms action, before a course is deleted
DATE ADDED: 9th March 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this course.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/courses/index.php?action=delete&cid=" + cID;
	}
}

function deleteAgentBB(ID) {
/********************************************
DESCRIPTION: confirms action, before an agent message is deleted from the BB
DATE ADDED: 14th April 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this message.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/agentbb/index.php?a=d&mid=" + ID;
	}
}

function deleteVoxpop(ID) {
/********************************************
DESCRIPTION: confirms action, before an agent message is deleted from the BB
DATE ADDED: 14th April 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this case study.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/voxpops/index.php?a=d&vid=" + ID;
	}
}

function deleteElibraryDb(ID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary eDatabase is deleted
DATE ADDED: 12th July 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this eLibrary database.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibrarydatabases/index.php?a=d&edbid=" + ID;
	}
}

function deleteElSubguideLink(urlID, esgID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary subject guide website link is deleted
DATE ADDED: 20th July 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this Subject Guide Website.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibrarysubguides/addLinks.php?a=d&urlid=" + urlID + "&esgid=" + esgID;
	}
}

function deleteCareerGuideLink(urlID, cgID) {
/********************************************
DESCRIPTION: confirms action, before an career guide website link is deleted
DATE ADDED: 8th November 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this website from the Career Guide.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/careerguides/addLinks.php?a=d&urlid=" + urlID + "&cgid=" + cgID;
	}
}

function deletePageRelLink(urlID, pID) {
/********************************************
DESCRIPTION: confirms action, before a page related link is deleted
DATE ADDED: 31st October 2005 - spoooky!
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this related page link.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/editor/addLinks.php?a=d&urlid=" + urlID + "&pid=" + pID;
	}
}

function deleteElSubguideBook(bID, esgID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary subject guide book is deleted
DATE ADDED: 2nd September 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this Subject Guide Book.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibrarysubguides/addBooks.php?a=d&bid=" + bID + "&esgid=" + esgID;
	}
}

function deleteElibrarySubguide(ID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary subject guide is deleted
DATE ADDED: 15th July 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this eLibrary Subject Guide.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibrarysubguides/index.php?a=d&esgid=" + ID;
	}
}

function deleteElibraryGate(ID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary information gateway is deleted
DATE ADDED: 14th July 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this eLibrary Information Gateway.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibraryinfogate/index.php?a=d&eigid=" + ID;
	}
}

function deleteElibraryNews(ID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary news message is deleted
DATE ADDED: 14th July 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this eLibrary news message.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibrarynews/index.php?a=d&enid=" + ID;
	}
}

function deleteAlibrary(ID) {
/********************************************
DESCRIPTION: confirms action, before an eLibrary Additional Library is deleted
DATE ADDED: 15th July 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this Additional Library.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/elibraryother/index.php?a=d&ealid=" + ID;
	}
}

function deleteDocument(ID) {
/********************************************
DESCRIPTION: confirms action, before an agent document is deleted 
DATE ADDED: 18th April 2005
DATE UPDATED: 8th February 2006
*********************************************/
	if (confirm("You are about to delete this document.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "index.php?a=d&did=" + ID;
	}
}


function deleteMailer(ID) {
/********************************************
DESCRIPTION: confirms action, before a mailshot is deleted 
DATE ADDED: 19th April 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this mailshot.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/mailer/index.php?a=d&msid=" + ID;
	}
}

function deleteMailRecipient(ID, listID) {
/********************************************
DESCRIPTION: confirms action, before a mailshot recipient is deleted from a list
DATE ADDED: 20th April 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this entry.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/mailer/editList.php?a=d&mslid=" + listID + "&msrid=" + ID;
	}
}

function deleteExtRelURL(ID, aID) {
/********************************************
DESCRIPTION: confirms action, before an external related link is deleted from an article
DATE ADDED: 29th April 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this related link.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/news/links/externalURLs.php?a=d&relid=" + ID + "&aid=" + aID;
	}
}

function deleteNewsRelURL(ID, aID) {
/********************************************
DESCRIPTION: confirms action, before an news related link is deleted from an article
DATE ADDED: 4th May 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to delete this related article link.\n\nAre you sure you want to continue?")) {
		window.document.location.href= "/admin/news/links/newsURLs.php?a=d&relid=" + ID + "&aid=" + aID;
	}
}

function confirmNewsSubmit(myForm) {
/********************************************
DESCRIPTION: confirms action, before a draft news article is submitted for approval 
DATE ADDED: 4th May 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to submit this news article for approval.\n\nAre you sure you want to continue?")) {
		return true;
	} else {
		return false;
	}
}

function confirmNewsApprove(myForm) {
/********************************************
DESCRIPTION: confirms action, before a draft news article is made live on the site 
DATE ADDED: 6th May 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to submit this news article to the website.\n\nAre you sure you want to continue?")) {
		return true;
	} else {
		return false;
	}
}

function confirmMailer(myForm) {
/********************************************
DESCRIPTION: confirms action, before sending selected mailshot out to selected mailing list 
DATE ADDED: 24th May 2005
DATE UPDATED: -
*********************************************/
	if (confirm("You are about to send this mailshot.\n\nAre you sure you want to continue?")) {
		return true;
	} else {
		return false;
	}
}



// End hiding script -->
