top.hiddenframeurl = '';

function callhiddenframe(hiddenpage, hiddenid, realid, selfcalled)
{
// uses some assuptions about the current DOM
// maybe these should be in a config and sourced?

	switch (true) {
	case (!top.hiddenframeurl && selfcalled) :
	{
		// data is ready
//alert(realid);
//alert(hiddenid);
//alert(top.frames.hiddenFrame.document.getElementById(hiddenid).innerHTML);
//alert(document.getElementById(realid).innerHTML);
		document.getElementById(realid).innerHTML =
			top.frames.hiddenFrame.document.getElementById(hiddenid).innerHTML;

//alert('Data Ready');
//		realid.visiblility='hidden';
//		realid.visiblility='visible';
		break;
	}
	case (!top.hiddenframeurl && !selfcalled) :
	{
		// new request
		top.hiddenframeurl = hiddenpage;
		top.frames.hiddenFrame.document.location=hiddenpage;
		selfcalled = true;
	}
	case (selfcalled) :
	{
		// data not ready yet, wait a bit
		setTimeout('callhiddenframe(top.hiddenframeurl, \'' + hiddenid + '\', \'' + realid +
			'\',true);', 100);
	}}
}

//Break this into hunks suitable for get method posting, say 7k
function fncGetSelectedOptions(SelectControl)
{
	var strOptions = '';
	for(i = 0; i < SelectControl.options.length; i++)
	{
		if (SelectControl.options[i].selected == true)
		{
			if (strOptions.length > 0)
			{
				strOptions += ",";
			}
			strOptions += SelectControl.options[i].value;
		}
	}
	return encodeURI(strOptions);
}


function fncRemoveSelectedOptions(SelectControl)
{
	var strOptions = '';
	for(i = 0; i < SelectControl.options.length; i++)
	{
		while (SelectControl.options[i].selected == true)
		{
			SelectControl.options[i] = null;
		}
	}
}


function popupW(relativeURL, thisWide, thisHigh, windowName) {  // opens a new browser window

    if(arguments.length > 3){
        wname = arguments[3];
    }else{
        wname = 'myWindowName';
    }
	leftPos = 0;
	topPos = 0;
	wide = 600;
	high = 600;
	if (thisWide) {
		wide = thisWide;
	}
	if (thisHigh) {
		high = thisHigh;
	}
	if (screen) {
		leftPos = (screen.width/2)-210;
		topPos  = (screen.height/2)-100;
	}
	popupWin=window.open(relativeURL, wname ,'resizable=yes,scrollbars=yes,status=no,toolbar=no,width='+wide+',height='+high+',left='+leftPos+',top='+topPos);
	popupWin.focus();
    return popupWin;
}


// grid functions  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

function fncGridIsExpanded(gridIndex) { // Ensure Grid is expanded with appropriate button bar state

	var br=document.getElementById('btnResize_'+gridIndex)
	var g=document.getElementById('tblgrid_'+gridIndex)

	if (g) {  // grid has been loaded, just expand it if not already expanded

		if (g.style.display=='none') {    // not presently displayed
			br.title='Collapse Grid';
			br.value='^';
            br.src='/images/ClassIcons/ArrowUp.png';
			g.style.display='block';
		}

	} else { // grid has not been loaded, so load it
		top.frames.hiddenFrame.document.location.href="/includes/forms/loadGrid.php?gi="+gridIndex;
		br.title='Collapse Grid';
        br.src='/images/ClassIcons/ArrowUp.png';
		br.value='^';
	}
}


/*function fncGridResize(gridIndex) { // toggle grid collapse/expand mode plus update button bar state

//	var br=document.getElementById('btnResize_'+gridIndex)
//	var g=document.getElementById('tblGrid_'+gridIndex)

//	if (g) {  // grid has been loaded, just show it or  hide it

//		if (g.style.display=='none') {    // not presently displayed
			br.title='collapse grid';
			br.value='^';
//			g.style.display='block';
            g.style.cssText = getComputedStyle(g,null).cssText;
	          // get the width of an element in the dom as the array that specifies the log header row cells width
	          //var temp = top.frames.hiddenFrame.document.width * 0.6;
			//alert(temp);
	          //g.style.width=temp+'%';  // this sets the width

		} else {
			br.title='expand grid';
			br.value='v';
			g.style.display='none';

		}

	} else { // grid has not been loaded, so load it

		top.frames.hiddenFrame.document.location.href="/includes/forms/loadGrid.php?gi="+gridIndex;
		br.title='collapse grid';
		br.value='^';
	}
     //var a = top.frames.hiddenFrame.document.width;
     //
	//alert(a+' * .6= '+b);
}
*/
function fncGridResize(gridIndex) { // toggle grid collapse/expand mode plus update button bar state

    var ua = window.navigator.userAgent.toLowerCase();
	var br=document.getElementById('btnResize_'+gridIndex)
	var g=document.getElementById('tblGrid_'+gridIndex)

    if (g) {  // grid has been loaded, just show it or  hide it
		if (g.style.display=='none') {    // not presently displayed
			br.title='Collapse Grid';
			br.value='^';
            br.src='/images/ClassIcons/ArrowUp.png';
            if ((i = ua.indexOf('msie')) != -1){
                g.style.display='block';
            }else{
                g.style.cssText = getComputedStyle(g,null).cssText;
            }
		} else {
			br.title='Expand Grid';
			br.value='v';
            br.src='/images/ClassIcons/ArrowDown.png';
			g.style.display='none';
		}
	} else { // grid has not been loaded, so load it
		top.frames.hiddenFrame.document.location.href="/includes/forms/loadGrid.php?gi="+gridIndex;
        if(br){
		    br.title='Collapse Grid';
		    br.value='^';
            br.src='/images/ClassIcons/ArrowUp.png';
        }
	}
}


function fncGridAction(gridIndex, action) { // launch popup for record adding or removal, make sure grid is expanded with updated button bar state
	// the value of action must be a string that specifies the name of the popup php file to call - * case sensitive *
	var w=popupW('/includes/forms/popup'+action+'.php?gi='+gridIndex);
	var e=fncGridIsExpanded(gridIndex);
}

function fncLoadBCG() { // module 2210-Forecasting - This is first called in the body onload event of csimBarChart.php. Subsequent calls are made from the onclick event of the "generate chart" button
    if (top.frames.mainFrame.document.width) { /* moz */
        var a = (top.frames.mainFrame.document.width * .96);
    } else if (screen.width) { /* ie */
        var a  = (screen.width * .81);
    } else {
        var a  = 700;
    }
    return Math.round(a);
}
	     
// progress bar   
function showProg() {
    var x = 3;  //  THis doesn't do anything...get rid of it later
// ignore until the freeze frame effect is resolved.
   /* leftPos = 300;    
    topPos  = 300;
    if (screen) {     
        leftPos = (screen.width/2)-210;   
        topPos  = (screen.height/2)-100;
    }
    pbs = document.getElementById('progressBar').style; 
    pbs.top=topPos;  
    pbs.left=leftPos;  
    pbs.display='block';       */   
}
function hideProg() {if (document.getElementById('progressBar')) {document.getElementById('progressBar').style.display='none'}}


// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table! (http://www.dagblastit.com/dhtml/)
// just pass the element you want the left or top value of example: alert(getAbsX(this))
function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,'Left'); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,'Top'); }
function getAbsPos(elt,which) {
 iPos = 0;
 while (elt != null) {
  iPos += elt['offset' + which];
  elt = elt.offsetParent;
 }
 return iPos;
}

// Gives ability to change the style of a specified class
// Will accept border as an attribute but not border-left.
// Will accept color names but not hex.
// Example usage:   setStyleClass(\"btRow\").style.border=\"1px solid gray\";
function setStyleClass (className) { 
if (document.all) { // ie
    for (var s = 0; s < document.styleSheets.length; s++)
    for (var r = 0; r < document.styleSheets[s].rules.length; r++)
    if (document.styleSheets[s].rules[r].selectorText == '.' + 
    className)
    return document.styleSheets[s].rules[r];
}
else if (document.getElementById) {
    for (var s = 0; s < document.styleSheets.length; s++)
    for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
    if (document.styleSheets[s].cssRules[r].selectorText == '.' + 
    className)
    return document.styleSheets[s].cssRules[r];
  }
  return null;
}

function select_deselect_all(control_name, se_de, invert){
    // this function will select all/deselect all
    // control name is the name of the control
    // se_de is select or deselect, by default it is select
    var sel_des = true;
    var inverted = false;

    if(se_de == false){
        sel_des = false;
    }

    if(invert == true){
        inverted = true;
    }

    cName = document.getElementById(control_name);

    for(var i = 0;i < cName.length;i++){
        if(inverted == true){
            if(cName.options[i].selected == true){
                sel_des = false;
            } else if(cName.options[i].selected == false){
                sel_des = true;
            }
        }
        cName.options[i].selected = sel_des;
    }
}


function enterToTab(event){
	if(!window.event){
		key = event.which;
		elem = event.target;
	}else{
		key = window.event.keyCode;
		elem = window.event.srcElement;
	}
	next = null;
	if(key == 13){
		f = elem.form;
		if(f){
			least = null;
			next = null;
			cidx = 0;
			for(x=0;x<f.length;x++){
				if(elem === f[x]){
					cidx = x;
				}
				if(f[x].tabIndex > elem.tabIndex){
					if(!next || f[x].tabIndex < next.tabIndex){
						next = f[x];
					}
				}
			}
			if(!next){
				if(cidx + 1 < f.length){
					next = f[cidx + 1];
				}else if(!(elem === f[0])){
					next = f[0];
				}
			}
		}else{
			inps = document.getElementsByTagName('INPUT');
			for(x=0;x<inps.length;x++){
				if(elem === inps[x]){
					if(x + 1 < inps.length){
						next = inps[x + 1];
						break;
					}
				}
			}
		}

		if((!next) || (elem === next)){
			elem.blur();
		}else{
            next.focus();
		}
		return false;
	}
}

function syncXY(num){
	// woopie - a whole 4 lines of code to do this...
	// take the main objects scrollLeft and scrollRight property and
	// make the elements that you want to align have the same values
	var xLF = document.getElementById("g" + num + "_zDta").scrollLeft;
	document.getElementById("g" + num + "_xHdr").scrollLeft= xLF;
	//
	var yTP = document.getElementById("g" + num + "_zDta").scrollTop;
	document.getElementById("g" + num + "_yHdr").scrollTop= yTP;
	//
}

function check_date(field, datefmt, oldvalue){
    var checkstr = "0123456789";
    var DateField = field;
    var DateValue = "";
    var DateTemp = "";
    var seperator = "-";
    var day;
    var month;
    var year;
    var leap = 0;
    var err = 0;
    var i;


    if (!oldvalue) {oldvalue='';}

    if (!datefmt) {
        datefmt='%Y-%m-%d';
    }  /*else {
        switch (datefmt) {
            case 'MM-DD-YY':
                datefmt = '%m-%d-%y';
                break;
            case 'MM-DD-YYYY':
                datefmt = '%m-%d-%Y';
                break;
            case 'MM/DD/YY':
                datefmt = '%m/%d/%y';
                break;
            case 'MM/DD/YYYY':
                datefmt = '%m/%d/%Y';
                break;
            case 'YYYY-MM-DD':
                datefmt = '%Y-%m-%d';
                break;
            case 'YYYY/MM/DD':
                datefmt = '%Y/%m/%d';
                break;
        }
    } */
    seperator = datefmt.substring(2,3);

       err = 0;
       DateValue = DateField.value;
       /* Delete all chars except 0..9 */
       for (i = 0; i < DateValue.length; i++) {
    	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
    	     DateTemp = DateTemp + DateValue.substr(i,1);
    	  }
       }
       DateValue = DateTemp;
       /* Date entered should be of the form yyyy-mm-dd
       /* Always change date to 8 digits - string*/
       /* if year is entered as 2-digit / always assume 20xx */

       if (DateValue.length<8) {
            err = 31;
       }

       /*
       if (DateValue.length == 6) {
          DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
       if (DateValue.length != 8) {
          err = 19;}
       */

       switch (datefmt) {
            case '%m-%d-%Y':
                year = DateValue.substr(4,4);
                month = DateValue.substr(0,2);
                day = DateValue.substr(2,2);
                DateForm = 'MM' + seperator + 'DD' + seperator + 'YYYY';
                break;
            case '%Y-%m-%d':
                year = DateValue.substr(0,4);
                month = DateValue.substr(4,2);
                day = DateValue.substr(6,2);
                DateForm = 'YYYY' + seperator + 'MM' + seperator + 'DD';
                break;
            case '%d-%m-%Y':
                year = DateValue.substr(4,4);
                month = DateValue.substr(2,2);
                day = DateValue.substr(0,2);
                DateForm = 'DD' + seperator + 'MM' + seperator + 'YYYY';
                break;
       }

       //alert(DateValue + '\n' + 'year = ' + year + '\n' + 'month = ' + month + '\n' + 'day = ' + day + '\n' + datefmt);

       /* year is wrong if year = 0000 */
       //year = DateValue.substr(0,4);
       if (year == 0) {
          err = 20;
       }
       /* Validation of month*/
       //month = DateValue.substr(4,2);
       if ((month < 1) || (month > 12)) {
          err = 21;
       }
       /* Validation of day*/
       //day = DateValue.substr(6,2);
       if (day < 1) {
         err = 22;
       }
       /* Validation leap-year / february / day */
       if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
          leap = 1;
       }
       if ((month == 2) && (leap == 1) && (day > 29)) {
          err = 23;
       }
       if ((month == 2) && (leap != 1) && (day > 28)) {
          err = 24;
       }
       /* Validation of other months */
       if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
          err = 25;
       }
       if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
          err = 26;
       }
       /* if 00 ist entered, no error, deleting the entry */
       if ((day == 0) && (month == 0) && (year == 00)) {
          err = 0; day = ""; month = ""; year = ""; seperator = "";
       }
       /* if no error, write the completed date to Input-Field (e.g. 2001-12-31) */
       if (err == 0) {
          //DateField.value = day + seperator + month + seperator + year;
          //DateField.value = year + seperator + month + seperator + day;
          switch (datefmt) {
            case '%m-%d-%Y':
                DateField.value = month + seperator + day + seperator + year;
                break;
            case '%Y-%m-%d':
                DateField.value = year + seperator + month + seperator + day;
                break;
            case '%d-%m-%Y':
                DateField.value = day + seperator + month + seperator + year;
                break;
          }
          return true;
       }
       /* Error-message if err != 0 */
       else {
          //alert("Date is incorrect! " + err);
          alert('Invalid Date.' + '\n' + 'Enter a valid date of the form ' + DateForm + '.');
          DateField.value = oldvalue;
          DateField.select();
    	  DateField.focus();
          return false;
       }
}


function addFormCtl(thisForm, name, value, event){
// adds three inputs to a form to support our hidden frame control handling
// also has optional arguments
// fifth   is method
// sixth   is action
// seventh is target
// eighth  is encoding
//  ninth is sArrayKey => This is for those times that a control is to be built outside of our
                            //  standard $_SESSION['Controls'] array. 
// any of the optionals that are missing or not a string are set to defaults
//   method   = POST
//   action   = /includes/forms/HandleControls.php
//   target   = hiddenFrame
//   encoding = multipart/form-data

    var created = false;

    // find the form if a string was passed in
    if(thisForm == null || 'object' != typeof(thisForm)){
        created = true;
        var formName = '';
        if(!thisForm) var thisForm;
        if('string' == typeof(thisForm) && thisForm != ''){
            var formName = thisForm;
            var tmpThisForm = document.getElementById(thisForm);
            // if this form already exists, remove it and create a new one
            if(tmpThisForm){
                tmpThisForm.parentNode.removeChild(tmpThisForm);
                thisForm = null;
            }
        }
        thisForm = document.createElement('form');
        if(formName){
            thisForm.name = formName;
            thisForm.id = formName;
        }

        // use default (or pre-existing) values if no extra arguments were passed
        var extraArgs = ['method', 'action',                             'target',      'encoding'];
        var extraDefs = ['POST',   '/includes/forms/HandleControls.php', 'hiddenFrame', 'multipart/form-data'];
        var b;
        for(var a = 0; a < extraArgs.length; a++){
            b = a + 4;  // number of args to skip
            if('string' == typeof(arguments[b])){
                // assign this arg to the property
                thisForm[extraArgs[a]] = arguments[b];
            }else{
                // fill in missing or non-valid arguments for form properties with defaults
                thisForm[extraArgs[a]] = extraDefs[a];
            }
        }
        //  We are only gonna' use this last one if it was passed in.  So let's deal with it special-like.  -  JW
        var sArrayKey = arguments[8];
    }

    if(typeof(thisForm) != 'object'){
        return null;
    }

    // add default controls to the form for use with HandleControls.php
    addFormVal(thisForm, 'control', name);
    addFormVal(thisForm, 'event'  , event);
    addFormVal(thisForm, 'value'  , value);
    if(sArrayKey){
        addFormVal(thisForm, 'sArrayKey', sArrayKey);
    }

    // hook the form to the document
    if(created){
        document.body.appendChild(thisForm);
    }

    return thisForm;
}

function addFormVal(thisForm, name, value){
    // is there another argument for input type
    if(arguments.length > 3 && (typeof arguments[4] == 'string')){
	    var type = arguments[4];
    }else{
	    var type = 'hidden';
    }

    // if a string was passed in try to get a form from it
    if('string' == typeof(thisForm) && thisForm != ''){
        thisForm = top.document.getElementById(thisForm);
    }

    // no form to hang inputs from
    if('object' != typeof(thisForm)){
        return null;
    }

    // see if this input is already on this form
    var frmval;
    if('string' == typeof(name)){
        frmval = thisForm[name];
    }

    // if this input exists, remove it and recreate
    if('object' == typeof(frmval)){
        thisForm.removeChild(frmval);
        frmval = null;
    }

    // set the attributes and value
    frmval = document.createElement('input');
    frmval.setAttribute('id', name);
    frmval.setAttribute('name', name);
    frmval.setAttribute('type', type);
    frmval.value = value;
    thisForm.appendChild(frmval);

    return frmval;
}

function multiSelectToString(control){
    var str = '';
    var i;

    if(!control || !control.options){
        return '';
    }

    for(i in control.options){
        if(control.options[i].selected){
            str += ','+escape(control.options[i].value);
        }
    }

    if(str != ''){
        str = str.substring(1);
    }

    return escape(str);
}

function treeToPHP(vals){
    var ret = '';
    for(x in vals){
        ret += ",rawurldecode('"+escape(x.substr(1))+"')=>rawurldecode('"+escape(vals[x].substr(1))+"')";
    }
    if(ret){
        ret = "array("+ret.substr(1)+");";
    }
    return ret;
}

function getStyle(htmlElement,styleElement,mainFrame){

	var e = (mainFrame  ? top.frames.mainFrame.document.getElementById(htmlElement)
                        : document.getElementById(htmlElement));
	if (e.currentStyle)
		var r = e.currentStyle[styleElement];
	else if (window.getComputedStyle)
		var r = (mainFrame  ? top.frames.mainFrame.document.defaultView.getComputedStyle(e,null).getPropertyValue(styleElement)
                            : document.defaultView.getComputedStyle(e,null).getPropertyValue(styleElement));
	return r;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

/*
*@FUNCTION checkHeight
*@PARAM oHTMLObj    OBJ html object to check the height of
*@PARAM iHeight     INT Integer of desired height
*@PARAM bOverFlow   BOL True of False
*@DESC  Checks the height of an object and adds a scroll bar if the item is too large
        min-width would be nice, but oh well
*/

function checkHeight(oHTMLObj, iHeight, bOverFlow, bReturn){
    var op = '';
    if(bReturn == false){
        if(oHTMLObj.offsetHeight >= iHeight){
            oHTMLObj.style.height = iHeight + 'px';
            if(bOverFlow) oHTMLObj.style.overflow = 'auto';
        } else {
            oHTMLObj.style.height = oHTMLObj.offsetHeight + 'px';
            if(bOverFlow) oHTMLObj.style.overflow = 'hidden';
        }
    } else {
        if(oHTMLObj.offsetHeight > iHeight){
            op = iHeight;
        } else {
            op = oHTMLObj.offsetHeight;
        }
        return op;
    }
}

function filterHelper(val, desr, reg, tmp, htmlObject, testVal){
    des = unescape(String(desr).replace(/\+/g, " "));
    if(des.match(reg)){
        var newEle = document.createElement('a');           // Create the div
            newEle.setAttribute('id',val);
            newEle.setAttribute('href','#');
            newEle.onmouseover = function(){this.focus()};
            // the return string is searched for html entities and replaced with the equivalent. - SA
            newEle.onclick = function(){eval('var x="' + htmlObject.id+'"; var str = this.innerHTML; document.getElementById(x).value=decodeEntities(str); document.getElementById("SBR_" + x).style.left="-9999999999999px"; myform = addFormCtl(null, unescape(x), "' + val + '",unescape("onchange")); myform.submit();')};
            newEle.appendChild(document.createTextNode(des)); // Append the text
            tmp.appendChild(newEle);
    }
}

function filterData(dataObject, objectFilter, htmlObject){
    /*
        filterData recieves an object, an objectFilter, a value to filter on and a displayTemplate to out put the results
    */
    var hob = document.getElementById(htmlObject + '');
    var val = hob.value + '';
    var iDataLen = dataObject.length;
    var div = '';
    var rgx = new RegExp(val,"i");
    var hld = document.getElementById('SBR_' + hob.id);
        hld.removeChild(document.getElementById('RES_' + hob.id));
    var tmp = document.createElement('div');

    var objHld = new Array();

    var i = iDataLen;
    var testVal=0;

    do {
        filterHelper(String(dataObject[testVal].v), String(dataObject[testVal].d), rgx, tmp, hob, testVal);testVal++;
    } while (--i);

    var rep = hld.appendChild(tmp);
        rep.id = 'RES_' + hob.id;

    if(rep.childNodes.length < 1){
        var non = rep.appendChild(document.createElement('a'));
        non.appendChild(document.createTextNode('No options matched your search.'));
        non.className = ' selOptError';
    }

    hld.style.height = checkHeight(rep, '150', false, true) + 'px';
    checkHeight(hld, '150', true, false);


    var xPos = hob.offsetLeft;
    var yPos = (hob.offsetHeight);
    var fPos = findPos(hob);

    hld.style.position='absolute';
    hld.style.left= fPos[0] + 'px';
    hld.style.top = (fPos[1] + yPos) + 'px';
}

function cbg(obj,prop,val){
    /*
        CBG = CHANGE BACKGROUND COLOR
        perhaps it would make more sense to write a function that you could modify any CSS property, but we
        need a BG color changer for now

        you could seasily set this up so that the objects is an array and the prop and val gets set to all


    */
    if(typeof(obj) == 'object'){
        if(obj.length){
            var len = obj.length;
            for(var i=0; i<len; i++){
                var x = document.getElementById(obj[i]);
                if(x){
                    x[prop] = val;
                }
            }
        } else {
            obj[prop] = val;
        }
    } else if(typeof(obj) == 'string'){
        var x = document.getElementById(obj+'');
        if(x) x[prop] = val;
    }

}


function decodeEntities(str)
// decodes html entities in a string - SA
// param: encoded string
// return: unencoded string
{
    // if another html entity needs decoding, add the entitiy to entityArr and the equivalent to replaceArr - SA

    // add html entities to this array as needed - SA
    entityArr = new Array('&amp;');
    // add html entity equivalent to this array as needed - SA
    replaceArr = new Array('&');

    for(var i=0; i < entityArr.length; i++)
    {
        str = str.replace(entityArr[i], replaceArr[i]);
    }

    return str;
}


function P(iMilliseconds){
//  Pauses .  Purposely written so calling it would be a minimum of characters as every
    //  on-screen control has this call in its event that effectively submits to our
    //  server-side control handeling.  -  JW  10-25-2007
    iMilliseconds = (iMilliseconds
                        ?  iMilliseconds
                        :  250);
    sTimer  = new Date();
    sEnd    = sTimer.getTime() + iMilliseconds;
    while(sTimer.getTime() < sEnd){
        sTimer = new Date();
    }
}