// This is a JavaScript file that is used by the Scisense web site

//----------- The following functions are available:

/*
	Expandable Listmenu Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initMenus() 
{
	if (!document.getElementsByTagName) return;
	
	var aMenus = document.getElementsByTagName("LI");
	for (var i = 0; i < aMenus.length; i++) 
	{
		var mclass = aMenus[i].className;
		if (mclass.indexOf("treenode") > -1) 
		{
			var submenu = aMenus[i].childNodes;
			for (var j = 0; j < submenu.length; j++) 
			{
				if (submenu[j].tagName == "A") 
				{					
					submenu[j].onclick = function() 
					{
						var node = this.nextSibling;											
						while (1) 
						{
							if (node != null) 
							{
								if (node.tagName == "UL") 
								{
									var d = (node.style.display == "none")
									node.style.display = (d) ? "block" : "none";
									this.className = (d) ? "treeopen" : "treeclosed";
									return false;
								}
								node = node.nextSibling;
							} else 
							   {
								return false;
							   }
						   }
						return false;
					}					
					submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
				}				
				if (submenu[j].tagName == "UL")
					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}
//window.onload = initMenus;


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//*************** doSetFocus ***************************************************** 
function doSetFocus(frm, variable)
// Set the focus in the form "frm" to the specified "variable".
{
myLoc = "document." + frm + "." + variable + ".focus()";
eval(myLoc);
}   // doSetFocus

//*************** doSetFocusLogin ***************************************************** 
function doSetFocusLogin()
// Sets the focus to the pages first field, depending on url
   {
   document.frmLogin.userName.focus();
   } // doSetFocus
   
//*************** getSelectValue ***************************************************** 
function getSelectValue(selObj)
// Returns the selected value of a SELECT object
   {
   return selObj.options[selObj.selectedIndex].value
   } // getSelectValue

//*************** goThere ***************************************************** 
function goThere(frm) 
{
   //var page=document.form.go.value;
      alert("in goThere");
   var page=frm + ".go.value";
   alert("page=" + page);
   window.location=page;
}

//*************** openHelpWindow ***************************************************** 
function openHelpWindow(strURL)
   {
   var newWindow;
   //   var strOptions = "status,menubar,scrollbars,resizable"
   var strOptions = "width=500,height=500,scrollbars=yes,resizable=yes,menubar=yes";
   newWindow = window.open(strURL,"helpWindow",strOptions);
   newWindow.focus();
   } // generateHelpWindow
   
//*************** validateDeleteWithLinks ***************************************************** 
function validateDeleteWithLinks(frm)
// Ask to confirm a delete of a DB item.
   {
   var autoKnownID;
   var table;
   autoKnownID=frm.autoKnownID.value;
   table=frm.table.value;
   return confirm("You are about to delete item with Auto ID " + autoKnownID + " in table " + table + ".  Are you sure?");
   }    // validateDeleteWithLinks

//*************** validatePeopleFn ***************************************************** 
function validateDeleteDBItem(frm)
// Ask to confirm a delete of a DB item.
   {
   var autoKnownID;
   var table;
   autoKnownID=frm.autoKnownID.value;
   table=frm.table.value;
   return confirm("You are about to delete item with Auto ID " + autoKnownID + " in table " + table + ".  Are you sure?");
   }   // validateDeleteDBItem

//*************** validatePeopleFn ***************************************************** 
function validateUpdateDBItem(frm)
// Ask to confirm an update of a DB item.
   {
   var autoKnownID;
   var table;
   autoKnownID=frm.autoKnownID.value;
   table=frm.table.value;
   return confirm("You are about to update item with Auto ID " + autoKnownID + " in table " + table + ".  Are you sure?");
   }   // validateUpdateDBItem
   
//*************** validatePeopleFn ***************************************************** 
function validateAdministratorSubmit(frm)
// Ask to confirm an administrator add or delete (deleteAdministrator or addAdministrator)
   {
   var functionType;
   functionType=frm.functionType.value;
//   alert(functionType)
   if (functionType=="deleteAdministrator")
      {
      return confirm("You are about to Delete an Administrator.  Are you sure?");
      }
   else
      {
      return confirm("You are about to Add an Administrator. Are you sure?");
      }
   }   // validateAdministratorSubmit

//*************** validatePeopleFn ***************************************************** 
function validatePeopleFn(frm)
   // Ask to confirm a delete of a Person.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoPersonID;
   functionType = frm.functionType.value;
   autoPersonID = frm.autoPersonID.value;

   //   alert(functionType)
   if (functionType=="deletePerson")
      {
      return confirm("You are about to Delete Person with ID " + autoPersonID + ". Are you sure?");
      }
   }   // validatePeopleFn   

//*************** validateContactInfoFn *****************************************************   
function validateAppointmentFn(frm)
// Ask to confirm a delete of an Appointment.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoApptID;
   functionType = frm.functionType.value;
   autoApptID   = frm.autoAppointmentID.value;

//   alert(functionType)
   if (functionType=="deleteAppointment")
      {
      return confirm("You are about to Delete Appointment ID " + autoApptID + ". Are you sure?");
      }
   }   // validateAppointmentFn
   
//*************** validateContactInfoFn *****************************************************   
function validateContactInfoFn(frm)
// Ask to confirm a delete of a Contact Info record.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoContactInfoID;
   functionType      = frm.functionType.value;
   autoContactInfoID = frm.autoContactInfoID.value;

//   alert(functionType)
   if (functionType=="deleteContactInfo")
      {
      return confirm("You are about to Delete Contact Info ID " + autoContactInfoID + ". Are you sure?");
      }
   }   // validateContactInfoFn
   
//*************** validateNotesFn *****************************************************   
function validateNotesFn(frm)
// Ask to confirm a delete of a Note.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoPersonNotesID;
   functionType      = frm.functionType.value;
   autoPersonNotesID = frm.autoPersonNotesID.value;

//   alert(functionType)
   if (functionType=="deleteNote")
      {
      return confirm("You are about to Delete Note ID " + autoPersonNotesID + ". Are you sure?");
      }
   }   // validateNotesFn   
   
//*************** validateTrainingFn *****************************************************   
function validateTrainingFn(frm)
// Ask to confirm a delete of an appointment.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoTrainingID;
   functionType   = frm.functionType.value;
   autoTrainingID = frm.autoTrainingID.value;

//   alert(functionType)
   if (functionType=="deleteTraining")
      {
      return confirm("You are about to Delete Training ID " + autoTrainingID + ". Are you sure?");
      }
   }   // validateTrainingFn  

//*************** validateAreasOfExpertiseFn *****************************************************   
function validateAreasOfExpertiseFn(frm)
   // Ask to confirm a delete of an area of expertise.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoExpertiseID;
   functionType = frm.functionType.value;
   autoExpertiseID   = frm.autoExpertiseID.value;

   //   alert(functionType)
   if (functionType=="deleteExpertise")
      {
      return confirm("You are about to Delete Area of Expertise ID " + autoExpertiseID + ". Are you sure?");
      }
   }   // validateAreasOfExpertiseFn


//*************** validateConstituencyFn *****************************************************   
function validateConstituencyFn(frm)
// Ask to confirm a delete of a member constituency.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoMembConstituencyID;
   functionType           = frm.functionType.value;
   autoMembConstituencyID = frm.autoMembConstituencyID.value;

//   alert(functionType)
   if (functionType=="deleteConstituency")
      {
      return confirm("You are about to Delete Member Constituency ID " + autoMembConstituencyID + ". Are you sure?");
      }
   }   // validateConstituencyFn 
   
//*************** validateAttributeFn *****************************************************   
function validateAttributeFn(frm)
// Ask to confirm a delete of a member attribute.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoAttributeID;
   functionType        = frm.functionType.value;
   autoMembAttributeID = frm.autoMembAttributeID.value;

//   alert(functionType)
   if (functionType=="deleteAttribute")
      {
      return confirm("You are about to Delete Member Attribute ID " + autoMembAttributeID + ". Are you sure?");
      }
   }   // validateAttributeFn  
     
//*************** validateMembExpertiseFn *****************************************************   
function validateMembExpertiseFn(frm)
// Ask to confirm a delete of a member area of expertise.  No confirmation alert box needed for Add or Update.
   {
   var functionType;
   var autoMembExpertiseID;
   functionType        = frm.functionType.value;
   autoMembExpertiseID = frm.autoMembExpertiseID.value;

//   alert(functionType)
   if (functionType=="deleteMembExpertise")
      {
      return confirm("You are about to Delete Member Expertise ID " + autoMembExpertiseID + ". Are you sure?");
      }
   }   // validateMembExpertiseFn            