	 /* -------------------------------------------------------------
	 vCal
	 Open a snazzy window to handle the vCalendar export
	---------------------------------------------------------------- */

	function vCal() {
		var params="?filename=myreminders.vcs"
		
		window.open(servletURL+"wv_event.ExportReminders"+params, "_blank",'height=450,width=450,toolbar=no,menubar=no,resizable=yes,scrollbars=yes')
	}  
      
     /*----------------------------------------------------------
        CheckFindBy
        The Event Reference search only allows "is" for its 
        findby, so check for it and act accordingly.
        ----------------------------------------------------------*/       
      function CheckFindBy () {
      
	 var findby = document.getElementById("selFindBy");
         var searchon = document.getElementById("selSearchOn");
         
         if (searchon.options[searchon.selectedIndex].value == 1) {
               findby.selectedIndex = 0;
               findby.disabled = true;
         }else{
               findby.disabled = false;
         }
      
      }

	 /* -------------------------------------------------------------
	 QSearchEvent
	 Submit the Event Quick Search form.
	---------------------------------------------------------------- */
	function QSearchEvent() {

      var findBy = document.getElementById("selFindBy").value;
      var searchOn = document.getElementById("selSearchOn").value;
      var criteria = document.getElementById("txtCriteria").value;
      var sURL = servletURL + "wv_event.QSearch?searchon=" + searchOn + ",findby=" + findBy + ",criteria=" + criteria;
            

		document.location = sURL;

   }
  
	 /* -------------------------------------------------------------
	 QSearchEventName
	 Submit the Event Quick Search form.
	---------------------------------------------------------------- */
	function QSearchEventName() {

      var findBy = document.getElementById("selFindByEv").value;
      var criteria = document.getElementById("txtCriteriaEvName").value;
      var sURL = servletURL + "wv_event.QSearch?searchon=0;findby=" + findBy + ";criteria=" + criteria

		document.location = sURL;

   }
  


	 /* -------------------------------------------------------------
	 QSearchEventRef
	 Submit the Event Quick Search.
	---------------------------------------------------------------- */
	function QSearchEventRef() {

      var criteria = document.getElementById("txtCriteriaEvRef").value;
      var sURL = servletURL + "wv_event.QSearch?searchon=1,findby=0,criteria=" + criteria

		document.location = sURL;

   }



  /* -------------------------------------------------------------
	 QSearchSpace
	 Submit the Space Quick Search form.
	---------------------------------------------------------------- */
	function QSearchSpace() {

      var findBy = document.getElementById("selFindBySp").value;
      var criteria = document.getElementById("txtCriteriaSp").value;
      var sURL = servletURL + "wv_space.QSearch?findby=" + findBy + ",criteria=" + criteria
   
		document.location = sURL;

   }



	
	
	/* -------------------------------------------------------------
	 ValidateCreateUser
	 Validate the Create New User form, then submit if fields are OK.
	---------------------------------------------------------------- */
	function ValidateCreateUser(curForm){
		
		if (ValidateUserDetails (curForm)) {

         curForm.action = servletURL + "wv_user.Create";
   
   		curForm.submit();
   
   		return (true); 
   		
      } else {
         return (false);  
      }
	
}

	
	
	
	/* -------------------------------------------------------------
	 ValidateUserDetails
	 Make sure user has entered every required detail.
	---------------------------------------------------------------- */
	function ValidateUserDetails (curForm) {

		var EmailHasAt, EmailValue;
		
		/* Last Name */
		if (curForm.elements["FAMILY_NAME.CONTACTS.R25"].value == "") {
			alert("Please supply a last name.");
			curForm.elements["FAMILY_NAME.CONTACTS.R25"].focus();
			return (false);
		}
		
		/* Email */
		EmailValue = curForm.elements["E_MAIL.CONT_ADDR.R25"].value;
		EmailHasAt = EmailValue.match(/@/);
		if (EmailValue == "" | EmailHasAt == null) {
			alert("Please supply a valid email address.");
			curForm.elements["E_MAIL.CONT_ADDR.R25"].focus();
			return (false);
		}
		
				
	   /* Username */
		if (curForm.elements["USERNAME.WEBUSERS.R25"].value == ""){
			alert("Please supply a username.");
			curForm.elements["USERNAME.WEBUSERS.R25"].focus();
			return (false);
		}
		
		/* Password */
		if (curForm.elements["PWD1.WEBUSERS.R25"].value == "") {
			alert("Please supply a password.");
			curForm.elements["PWD1.WEBUSERS.R25"].focus();
			return (false);
		}
		
		/* Password Confirm */
		if (curForm.elements["PWD2.WEBUSERS.R25"].value == "") {
			alert("Please confirm your password.");
			curForm.elements["PWD2.WEBUSERS.R25"].focus();
			return (false);
		}
		
		/* Passwords Match */
		if (curForm.elements["PWD1.WEBUSERS.R25"].value != curForm.elements["PWD2.WEBUSERS.R25"].value) {
			alert("Your two passwords do not match; please retype them");
			curForm.elements["PWD1.WEBUSERS.R25"].value = "";
			curForm.elements["PWD2.WEBUSERS.R25"].value = "";
			curForm.elements["PWD1.WEBUSERS.R25"].focus();
			return (false);
		}
	
	   return (true);
		
	}
		
		
		
		
		
	/* -------------------------------------------------------------
	 UserDetailNoChange
	 From the change user details form (wv_user_change.hts), user
	 has opted to go ahead without changing any details.
	---------------------------------------------------------------- */
	function UserDetailNoChange (curForm) {
			   
		   curForm.action = servletURL + "wv_user.ActivateNextContent";
		
		   curForm.submit();
		
		   return (true);
		   
	}
	
	
	/* -------------------------------------------------------------
	 UserDetailUpdate 
	 From the change user details form (wv_user_change.hts), user
	 has opted to go ahead witht changing details.
	---------------------------------------------------------------- */
	function UserDetailUpdate (curForm){
			
		if (ValidateUserDetails (curForm)) {
		   
   		curForm.action = servletURL + "wv_user.Update";
   		
   		curForm.submit();
   		
   		return (true);
		
		} else {
		   return (false);
		}
		
		
	}
	
	
	
	/* -------------------------------------------------------------
	 SpaceInfo 
	 Open a small space details window when called from any room_short.
	 If RoomID = 0, we do nothing.
	---------------------------------------------------------------- */	
	function spaceInfo(RoomID) {
   	
   	var winName = "";
   	var winParams = "height=450,width=450,toolbar=no,menubar=no,resizable=yes,scrollbars=yes";
		
		if (RoomID == -1) {
			alert("You do not have security access to view details for this space.");
		}
		else if (RoomID == 0) {
	          //return false;
	     }
		else {
			open(servletURL + "wv_space.Detail?RoomID=" +RoomID, winName, winParams);
		}

	}
	
	
	/* -------------------------------------------------------------
	 rsrvInfo 
	 Open a small event details window when called from any
	 event name.
	---------------------------------------------------------------- */	
	function rsrvInfo(rsrvID) {

      var winName = "";
   	var winParams = "height=450,width=550,toolbar=no,menubar=no,resizable=yes,scrollbars=yes";
   	var sURL = servletURL + "wv_event.Detail?id=" + rsrvID;

		if (rsrvID == -2) {
			// Blackout
		}else if ((rsrvID == -1) || (rsrvID == "")) {
			alert("You do not have security access to view details for this event.");

		}else{
			open(sURL, winName, winParams);
		}

	}

	
	/* -------------------------------------------------------------
	 eventInfo 
	 Open a small event details window when called from any
	 event name.
	---------------------------------------------------------------- */	
	function eventInfo(eventID) {

   	var winName = "";
   	var winParams = "height=450,width=550,toolbar=no,menubar=no,resizable=yes,scrollbars=yes";

   	var urlParams = "?evid=" + eventID;

		open(servletURL + "wv_event.EventDetail" + urlParams, winName, winParams);

	}
	
	/* -------------------------------------------------------------
	 markUnread 
	 Force a task to remain unread, not to be confused with un-red.
	---------------------------------------------------------------- */
	function markUnread (todoID, notifyID, curForm){
   
         var newURL = servletURL + "wv_wf_detail.MarkUnread?todoid=" + todoID + ",notifyid=" + notifyID;  
           
         curForm.action = newURL
         curForm.submit();
         refreshOpener();  
         close();
         

	}

	/* -------------------------------------------------------------
	 completeToDo
	 Send the todo to UNIFACE for completion.
	---------------------------------------------------------------- */
	function completeToDo (curForm){
			
		curForm.action = servletURL + "wv_wf_detail.CompleteToDo";
				
		curForm.submit();
		
		// Refresh the calling form
      refreshOpener();
      
	}

	/* -------------------------------------------------------------
	 declineToDo
	 Send the todo to UNIFACE for denial.
	---------------------------------------------------------------- */
	function declineToDo (curForm){
			
		curForm.action = servletURL + "wv_wf_detail.DeclineToDo";
				
		curForm.submit();
		
		// Refresh the calling form
      refreshOpener();
      
	}
	

	/* -------------------------------------------------------------
	 workflowInfo 
	 Open a small event details window when called from task from
	 either of the workflow subtabs.
	---------------------------------------------------------------- */	
	function workflowInfo(eventID, dt, notifyID, todoID, curForm) {

          var winName = "";
      	var winParams = "height=450,width=750,toolbar=no,menubar=no,resizable=yes,scrollbars=yes";
      	var winURL = servletURL + "wv_workflow.Detail?evid=" + eventID + ",wfdt=" + dt + ",notifyid=" + notifyID + ",todoid=" + todoID;
           var anch = document.getElementById("aTaskName");
           
		open(winURL, winName, winParams);
		
		document.location = curForm;
				
   }
   
	
	/* -------------------------------------------------------------
	 grantWorkflow 
	 Send the workflow item on to UNIFACE for approvination.
	---------------------------------------------------------------- */
	function grantWorkflow (curForm){
			
		curForm.action = servletURL + "wv_wf_detail.Grant";
				
		curForm.submit();
		
		// Refresh the calling form
          refreshOpener();
      
	}
	
	
	/* -------------------------------------------------------------
	 denyWorkflow 
	 Send the workflow item on to UNIFACE for denyification.
	---------------------------------------------------------------- */
	function denyWorkflow (curForm){
			
		curForm.action = servletURL + "wv_wf_detail.Deny";
		
		curForm.submit();
		
		// Refresh the byday list
		refreshOpener();		
         
	}
		
	
	/* -------------------------------------------------------------
	 storeNotifyComment
	 Send a notification comment to its appropriate resting place.
	---------------------------------------------------------------- */
	function storeNotifyComment (curForm){

		curForm.action = servletURL + "wv_wf_detail.StoreNotifyComment";
		
		curForm.submit();			
	}
		
	
	/* -------------------------------------------------------------
	 storeToDoComment
	 Send the To Do comment for this workflow item to UNIFACE for storage.
	---------------------------------------------------------------- */
	function storeToDoComment (curForm){

		curForm.action = servletURL + "wv_wf_detail.StoreToDoComment";
		
		curForm.submit();			
	}

	/* -------------------------------------------------------------
	 showCommentButton
	 Make the 'Save Comment' Button appear.
	---------------------------------------------------------------- */
	function showCommentButton (curForm){

      curForm.elements["CommentButton"].style.display = "block";
	     
	}
	
	/* -------------------------------------------------------------
	 schedEvent 
	 Create a new Request from a matrix.
	---------------------------------------------------------------- */
	function schedEvent (startDate, endDate, roomID){
			
	   var params = "";
	   
	   params = "roomid=" + roomID + ",start=" + startDate + ",end=" + endDate;
	   
        document.location = servletURL + "wv_request.Request?" + params;
		
	}
	
	/* -------------------------------------------------------------
	 editRequest 
	 Edit an existing (outstanding only) request.
	---------------------------------------------------------------- */
	function editRequest (eventID){
	   
      opener.location = servletURL + "wv_request.Edit?eventid=" + eventID;
      document.close();
		
	}
	
	/* -------------------------------------------------------------
	 createRequest 
	 Create a new Request (SpeedViewer).
	---------------------------------------------------------------- */
	function createRequest (curDate){
			
      	  alert("Sorry, you are not allowed to create a new request.");
		
	}
	
	/* -------------------------------------------------------------
	 refreshOpener
	 Refresh the form that opened another form.
	---------------------------------------------------------------- */
	function refreshOpener (){
	   	   
	   // If the opener is busy, try again
         if (typeof(window.opener) == "undefined") {
            setTimeout("refreshOpener();", 1000);
         }else{
            window.opener.history.go(0);
	    }  
	}
	
	
	/* -------------------------------------------------------------
	 openNewWindow
	 Open the specified URL in a new window.
	---------------------------------------------------------------- */	
	function openNewWindow(sURL) {

         var winName = "";
         var winParams = "";
         
         // Not sure how built the incoming URL is
         if (sURL.match(/http/) < 0) {
   	      sURL = servletURL + sURL
   	   }

         open(sURL, winName, winParams);

	}
	
	
	/* -------------------------------------------------------------
	 getWindowHeight
	 Return the height of the browser window
	---------------------------------------------------------------- */	
	function getWindowHeight() {

	  var winHeight = 0;

	  if( typeof( window.innerHeight ) == 'number' ) {
	    //Non-IE
	    winHeight = window.innerHeight;
	  } else {
	    if( document.documentElement && document.documentElement.clientHeight ) {
	      //IE 6+ in 'standards compliant mode'
	      winHeight = document.documentElement.clientHeight;
	    } else {
	      if( document.body && document.body.clientHeight ) {
	        //IE 4 compatible
	        winHeight = document.body.clientHeight;
	      }
	    }
	  }

	  return winHeight;

	}


/* -------------------------------------------------------------
custom functions
FU-created functions for the WebViewer
---------------------------------------------------------------- */	

// loops through all tags of type changetag in the document looking for the string tagstring in the ID
// and changes their class to cssstring
function changeTags(changetag,tagstring,cssstring) {
var tags = document.getElementsByTagName(changetag);

// check if the ID has our string then change class to pre-defined class
for (i=0;i<tags.length;i++)
	if (tags[i].id.indexOf(tagstring) > -1)
		tags[i].className = cssstring;
} //function


// used to handle annoying errors
// for some reason try/catch won't work all the time...  this is the "final solution" to this problem
function ignore_error() {return true;}
window.onerror = ignore_error;
