var generalFunctions=
{
_charBuf:'',
_curList:0,
_prevSelected:0,
_debug:'',
// _evt: document.createEvent("MouseEvents"),
addFileAttach: function(args)
{
/************************************************************************************
addFileAttach
Author: Glenn Hassell
Date: 05/2/07
Copyright 2007
Purpose: This function is used to add a new file upload form element to a page.
There must be a field with the id 'num_files' for holding the number
of file attachments. The table id containing the file attachment forms
must be 'Files'. THe table must be a two column table where the first column
holds the lable and the second column holds the file input type.
***************************************************************************************/
args=args || {};
if(!args.id)
this._numFilesAttached = args.Files ? args.Files : this._numFilesAttached;
if(id != nfiles.value)
return;
var i = nfiles.value*1;
var files = document.getElementById('Files').insertRow(i);
i++;
nfiles.value = i;
var cell = files.insertCell(0);
cell.innerHTML='Attached file '+i+':';
cell = files.insertCell(1);
cell.innerHTML = '';
},
buildArgs: function(AjaxObj,fields)
{
/*******************************************************************************************
Function: buildArgs
Purpose: This function is used to build an argument list to be passed back to the server
containing all of the fields and their values. If a field value is set to null
that field will not be included in the returned argument list.
Arguments: fields - an object containing all of the fields for menu items and sub-menu items.
*******************************************************************************************/
var args="";
var field;
for(field in fields)
{
if(fields=='isObject')
continue;
if(fields[field] != null && fields[field].isObject)
args+=this.buildArgs(fields[field]);
else if(fields[field] != null)
AjaxObj.setVar(field,fields[field]);
}
return args;
},
resetBuf: function(e)
{
e.cancelBubble=true;
e.returnValue=false;
if(e.stopPropagation || e.preventDefault)
{
e.preventDefault();
e.stopPropagation();
}
this._charBuf='';
this._prevSelected=0;
this._curList=0;
},
throwAway: function(select,e)
{
e.cancelBubble=true;
e.returnValue=false;
if(e.stopPropagation || e.preventDefault)
{
e.preventDefault();
e.stopPropagation();
}
select.selectedIndex = this._prevSelected;
return false;
},
findOption: function(select,e)
{
e.cancelBubble=true;
e.returnValue=false;
if(e.stopPropagation || e.preventDefault)
{
e.preventDefault();
e.stopPropagation();
}
if(window.event) // IE
{
var keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
var keynum = e.which;
}
if(keynum == 13)
{
if(document.createEvent)
{
this._evt=document.createEvent("MouseEvents");
this._evt.initMouseEvent("click", true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
select.options[this._prevSelected].dispatchEvent(this._evt);
}
else
{
select.options[this._prevSelected].fireEvent('onclick');
select.fireEvent('onclick');
}
this._charBuf='';
select.selectedIndex = this._prevSelected;
return false;
}
if(keynum == 8 || keynum == 37)
{
this._charBuf=this._charBuf.substr(0,(this._charBuf.length-1));
}
else if(keynum == 46 || keynum == 36)
{
this._charBuf='';
select.selectedIndex=0;
}
else
{
this._charBuf += String.fromCharCode(keynum);
}
var buf = this._charBuf.toUpperCase();
var sString;
var spos;
for(var i=0;i