<!--
/*
    Modification History
    When        Who             Why
    5 Jan 2009  Steve Hind      Added setInvocationTimer so we do not have
                                to create in individual scripts. Now made
                                generically and allows user to supply their
                                own wait time valie in milli seconds.
    16 Jun 2009  Steve Hind     Added getElementPosition to obtain the left
                                and top of any control, this is acheived
                                by scanning back through the parent control list
                                obtaining the control.offsetLeft / Top and
                                adding them up to determine the location of
                                the control.
*/
var isCSS, isW3C, isIE4, isNN4, isIE6CSS, isFireFox, isIE;
var commonInitExecuted = false;
function commonInit()
{
    if(document.images)
    {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
		isFireFox = navigator.userAgent.indexOf("Firefox") > -1;
		isIE = navigator.userAgent.indexOf("Microsoft Internet Explorer") > -1;
		commonInitExecuted = true;
    }
}

// Set the z-order of an object
function setZIndex(obj, zOrder) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.zIndex = zOrder;
    }
}

// Set the background color of an object
function setBGColor(obj, color) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isNN4) {
            theObj.bgColor = color;
        } else if (isCSS) {
            theObj.backgroundColor = color;
        }
    }
}

// Set the visibility of an object to visible
function show(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "visible";
    }
}

// Set the visibility of an object to hidden
function hide(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "hidden";
    }
}

//Convert object name string or object reference
//into a valid style (or NN4 layer) reference
function getObject(obj)
{
    var object = getRawObject(obj);
    if(object && isCSS)
    {
        object = object.style;
    }
    
    return object;
}

//retrieve the x coordinate of a positional object
function getObjectLeft(obj)
{
    //alert("getObjectLeft");
    var elem = getRawObject(obj);
    var result = 0;
    if( document.defaultView)
    {
        var style = document.defaultView;
        result = getComputedCSSStyle(elem,"");
        //firefox no properties result = cssDecl.getPropertyValue("left");
    }
    else if( elem.currentStyle )
    {
        result = elem.currentStyle.left;
    }
    else if( elem.style )
    {
        result = elem.style.left;
    }
    else if( isNN4 )
    {
        result = elem.left;
    }
    //alert("getObjectLeft complete: " + result);
    return parseInt(result);
}

function getTop(element)
{
    return getElementTop(element);
}
function getElementTop (elemRef)
{
	var elem = this.getRawObject(elemRef);
	var result = null;
	if (isCSS || isW3C)
	{
		result = parseInt(getComputedCSSStyle(elem, "top"));
	} 
	else if (isNN4)
	{
		result = elem.top;
	}
	return result;
}
function getLeft(element)
{
    return getElementLeft(element);
}
function getElementLeft (elemRef)
{
	var elem = this.getRawObject(elemRef);
	var result = null;
	if (isCSS || isW3C)
	{
		result = parseInt(getComputedCSSStyle(elem, "left"));
	} 
	else if (isNN4)
	{
		result = elem.left;
	}
	return result;
}
function getWidth(element)
{
    return getElementWidth(element);
}

function getElementWidth (elemRef)
{
	var elem = this.getRawObject(elemRef);
	var result = null;
	if (isCSS || isW3C)
	{
		result = parseInt(getComputedCSSStyle(elem, "width"));
	} 
	else if (isNN4)
	{
		result = elem.width;
	}
	return result;
}

function getHeight(element)
{
    return getElementHeight(element);
}
function getElementHeight(elem)
{
	elem = this.getRawObject(elem);
    if(elem.offsetHeight)
    { 
         return elem.offsetHeight;
    } 
    else if(elem.style.pixelHeight)
    { 
         return elem.style.pixelHeight;
    }

    return elem.height;
/* found an alternative which seems to work for IE and FF
	var elem = this.getRawObject(elemRef);
	var result = null;
	if (isCSS || isW3C)
	{
		result = parseInt(getComputedCSSStyle(elem, "height"));
	} 
	else if (isNN4)
	{
		result = elem.height;
	}
*/
	return result;
}


function getElementPosition(elm) 
{
    if( typeof(elm) == "string")
    {
        elm = getElement(elm);
    }
     var offsetLeft = 0;
     var offsetTop = 0;
     
     while (elm) 
     {
         offsetLeft += elm.offsetLeft;
         offsetTop += elm.offsetTop;
         elm = elm.offsetParent;
     }
     return { left: offsetLeft, top: offsetTop };
 }

//From http://shiriru.blogspot.com/2007/10/setting-html-element-style-thru.html
function camelize(val) 
{
         return val.replace(/-(.)/g, function(m, l){return l.toUpperCase()});
}
//From http://shiriru.blogspot.com/2007/10/setting-html-element-style-thru.html
function setOpacity(elm,val) 
{
          elm.style.zoom = 1;
          elm.style.filter = "alpha(opacity=" + parseFloat(val*100) + ")";
          elm.style.opacity  = parseFloat(val); 
    return elm;
}
//From http://shiriru.blogspot.com/2007/10/setting-html-element-style-thru.html
function setCSSStyle(elm,prop,val) 
{
    //alert("typeof(elm)==" + typeof(elm));
    if(typeof(elm) == "string")
    {
        elm = getElement(elm);
    }
    if(prop=='opacity')
    {
        return setOpacity(elm,parseFloat(val));
    }
    if(prop=='float')
    {
        prop = (window.attachEvent) ? 'styleFloat' : 'cssFloat';
    }
    prop = camelize(prop);
    unit=(prop=='zIndex'||prop=='zoom'||/olor/.test(prop)) ? '':'px';
    elm.style[prop] = (typeof val=='string') ? val : val+unit;
    
    return elm;
}

/*
	This was re-named from getComputedStyle
	to getComputedCSSStyle as it caused a recursive
	loop
*/
function getComputedCSSStyle(elemRef, CSSStyleProp) 
{
    var elem = getRawObject(elemRef);
    var styleValue, camel;
    if (elem) 
    {
        if (document.defaultView && document.defaultView.getComputedStyle)
        {
            // W3C DOM version
            var compStyle = document.defaultView.getComputedStyle(elem, null);
            styleValue = compStyle.getPropertyValue(CSSStyleProp);
        } 
        else if (elem.currentStyle)
        {
            // make IE style property camelCase name from CSS version
            var IEStyleProp = CSSStyleProp;
            var re = /-\D/;
            while (re.test(IEStyleProp))
            {
                camel = IEStyleProp.match(re)[0].charAt(1).toUpperCase();
                IEStyleProp = IEStyleProp.replace(re, camel);
            }
            styleValue = elem.currentStyle[IEStyleProp];
        }
    }
    return (styleValue) ? styleValue : null;
}
 
//retrieve the y coordinate of a positional object
function getObjectTop(obj)
{
	return getElementTop(obj);
/*
    //alert("getObjectTop");
    var elem = getRawObject(obj);
    var result = 0;
    if( document.defaultView)
    {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem,"");
        result = cssDecl.getPropertyValue("top");
    }
    else if( elem.currentStyle )
    {
        result = elem.currentStyle.top;
    }
    else if( elem.style )
    {
        result = elem.style.top;
    }
    else if( isNN4 )
    {
        result = elem.top;
    }
    
    //debug("getObjectTop complete: " + parseInt(result));
    return parseInt(result);
*/
}

//retrieve the rendered height of an element
function getObjectHeight(obj)
{
    //alert("getObjectTop");
    var elem = getRawObject(obj);
    var result = 0;
    if( elem.offsetHeight)
    {
        result = elem.offsetHeight;
    }
    else if( elem.clip && elem.clip.height )
    {
        result = elem.clip.height;
    }
    else if( elem.style && elem.style.pixelHeight)
    {
        result = elem.style.pixelHeight;
    }    
    //alert("getObjectTop complete: " + result);
    return parseInt(result);
}

//retrieve the rendered width of an element
function getObjectWidth(obj)
{
    var elem = getRawObject(obj);
    var result = 0;
    if( elem.offsetWidth)
    {
        result = elem.offsetWidth;
    }
    else if( elem.clip && elem.clip.width )
    {
        result = elem.clip.width;
    }
    else if( elem.style && elem.style.pixelWidth)
    {
        result = elem.style.pixelWidth;
    }    
    //alert("getObjectTop complete: " + result);
    return parseInt(result);
}

//Retrieve the available content width space in browser window
function getInsideWindowWidth()
{
    if( window.innerWidth )
    {
        return window.innerWidth;
    }
    else if( isIE6CSS )
    {
        // measure the html elements client Width
        return document.body.parentElement.clientWidth;
    }
    else if( document.body && document.body.clientWidth )
    {
        return document.body.clientWidth;
    }
    
    return 0;
}

//Retrieve the available content width space in browser window
function getInsideWindowHeight()
{
    if( window.innerHeight )
    {
        return window.innerHeight;
    }
    else if( isIE6CSS )
    {
        // measure the html elements client Height
        return document.body.parentElement.clientHeight;
    }
    else if( document.body && document.body.clientHeight )
    {
        return document.body.clientHeight;
    }
    
    return 0;
}

//position an object to a specific pixel coordinate
function shiftTo( obj, x, y)
{
    var object = getObject(obj);
    if(object)
    {
        if( isCSS )
        {
            //equalise incorrect numeric value type
            var units = (typeof(object.left) == "string") ? "px" : 0;
            object.left = x + units;
            object.top = y + units;
        }
        else if( isNN4 )
        {
            object.moveTo(x,y);
        }
    }
}

//position an object to a specific pixel coordinate
function setTop( obj, y)
{
    var object = getObject(obj);
    if(object)
    {
        if( isCSS )
        {
            //equalise incorrect numeric value type
            var units = (typeof(object.left) == "string") ? "px" : 0;
            object.top = y + units;
        }
        else if( isNN4 )
        {
            object.moveTo(getObjectLeft(obj),y);
        }
    }
}

//position an object to a specific pixel coordinate
function setLeft( obj, x)
{
    var object = getObject(obj);
    if(object)
    {
        if( isCSS )
        {
            //equalise incorrect numeric value type
            var units = (typeof(object.left) == "string") ? "px" : 0;
            object.left = x + units;
        }
        else if( isNN4 )
        {
            object.moveTo(x,getObjectTop(obj));
        }
    }
}

//position an object to a specific pixel coordinate
function setWidth( obj, width)
{
    var object = getObject(obj);
    if(object)
    {
        if( isCSS )
        {
            //equalise incorrect numeric value type
            var units = (typeof(object.left) == "string") ? "px" : 0;
            object.width = width + units;
        }
        else if( isNN4 )
        {
            object.width = width;
        }
    }
}
//position an object to a specific pixel coordinate
function setHeight( obj, height)
{
    var object = getObject(obj);
    if(object)
    {
        if( isCSS )
        {
            //equalise incorrect numeric value type
            var units = (typeof(object.height) == "string") ? "px" : 0;
            object.height = height + units;
        }
        else if( isNN4 )
        {
            object.height = height;
        }
    }
}

//position an object to a specific pixel coordinate
function shiftBy( obj, deltaX, deltaY)
{
    var object = getObject(obj);
    if(object)
    {
        if( isCSS )
        {
            //equalise incorrect numeric value type
            var units = (typeof(object.left) == "string") ? "px" : 0;
            object.left = getObjectLeft(obj) + deltaX + units;
            object.top = getObjectTop(obj) + deltaY + units;
        }
        else if( isNN4 )
        {
            object.moveBy(deltaX,deltaY);
        }
    }
}

// Seek nested NN4 layer from string name
function seekLayer( doc, name)
{
    var object;
    for( var i = 0 ; i < doc.layers.length ; ++i )
    {
        if(doc.layers[i].name == name)
        {
            object = doc.layers[i];
            break;
        }
        // dive into nested layers if required
        if( doc.layers[i].document.layers.length > 0 )
        {
            object = seekLayer(doc.layers[i].document, name);
        }
    }
}

function getElementStyle(elemID, IEStyleAttr, CSSStyleAttr)
{
    var elem = getElement(elemID);
    if(elem.currentStyle)
    {
        return elem.currentStyle[IEStyleAttr];
    }
    else if(window.getComputedStyle)
    {
        return getComputedCSSStyle(elem,CSSStyleAttr);
        //return compStyle;
        //return compStyle.getPropertyValue(CSSStyleAttr);
    }
    return "";
}

//will resize the current browser to screen size
//if you supply a 'ifAvailWidthLessThan' then
//the resize will only occur if the screen width
//is less than that supplied.
function maximiseWindow(ifAvailWidthLessThan)
{
    var offset = (navigator.userAgent.indexOf("Mac") != -1
        || navigator.userAgent.indexOf("Gecko") != -1
        || navigator.userAgent.indexOf("Netscape") != -1) ? 0 : 4;
    
    if(typeof(ifAvailWidthLessThan) != "undefined")
    {
        //alert("Current avail width:" + screen.availWidth + " - " + ifAvailWidthLessThan);
        if(screen.availWidth > ifAvailWidthLessThan)
        {
            return;
        }
    }
    window.moveTo(-offset, -offset);
    window.resizeTo(screen.availWidth + (2 * offset), screen.availHeight + (2 * offset));
}

var formDirty = false;

function setFormDirty()
{
	formDirty = true;
}
function clearFormDirty()
{
	formDirty = false;
}

function isFormDirty()
{
	return formDirty;
}

function isUnloadAllowed()
{
	return !formDirty;
}

function onBodyUnload()
{
	return confirmNotSaving();
}

function onDataChanged()
{
	setFormDirty();
}

function onSaveClicked()
{
	clearFormDirty();
}

function confirmNotSaving()
{
	if(isUnloadAllowed())
	{
		return true;
	}
	var yesNo = confirm('Your changes have not been saved, are you sure you want leave this page without saving?');
	if (yesNo)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function confirmDelete( message )
{
	return confirm(message);
}



//Convert object name string or object reference
//into a valid element object reference
//*************************************
//              WARNING
//*************************************
//do not call debug() from here
//as it uses this method to gain access to the
function getRawObject(obj)
{
    var object;
    if( typeof(obj) == "string")
    {
        //alert("isW3C=" + isW3C + ", isIE4=" + isIE4 + ", isNN4=" + isNN4);
        if(isW3C)
        {
            object = document.getElementById(obj);
        }
        else if( isIE4 )
        {
            object = document.all(obj);
        }
        else if( isNN4 )
        {
            object = seekLayer(document, obj);
        }
        else if( commonInitExecuted == false )
        {
            commonInit();
            return getRawObject(obj);
        }
        
    }
    else
    {
        object = obj;
    }
    
    return object;
}
/*
	Cross browser function to access elements of the form
*/
function getElement( element, allowSearchByName )
{
    return getRawObject(element);
/*
	if(typeof(element)=='string')
	{
		if(typeof(allowSearchByName) == 'undefined')
		{
			allowSearchByName = false;
		}
		
		//See if this browser supports getElementById (generally Microsoft)
		if(document.getElementById)
		{
			element=document.getElementById(element);
			if((element == null || typeof(element) == 'undefined')
				&& allowSearchByName)
			{
				alert('Searching by name');
				element=document.all[element];
				alert('Found ' + element);
			}
		}
		//Other browser types
		else if(document.all)
		{
			element=document.all[element];
		}
		else
		{
			//Unknown
			alert('getElement was unable to locate element: ' + element);
			element=null;
		}
	}
	return element;
*/
}

function getInteger( value, defaultValue)
{
    if( isNaN(value))
    {
		return defaultValue;
	}
	else
	{
		return parseInt(value);
	}
}

function filteredCopy( sourceCombo, destCombo, filter )
{
    destCombo.options = new Array();
	var listSize = sourceCombo.options.length;
	
    for ( var i = 0; i < listSize; i++ )
    {
		var opt = sourceCombo.options[i];
		
		if( opt.text.indexOf(filter) > -1 )
		{
		    destCombo.options[destCombo.options.length] = new Option(opt.text,opt.value,false,false);
		}
	}    
}

function copyComboContents( sourceCombo, destCombo)
{
    //destCombo.options = new Array();
	var listSize = sourceCombo.options.length;
	
    for ( var i = 0; i < listSize; i++ )
    {
		var opt = sourceCombo.options[i];
		
        destCombo.options[destCombo.options.length] = new Option(opt.text,opt.value,false,false);
	}    
}

//Required: a div with id of debug
var traceLines = new Array();
function debug(msg)
{
    var d = getElement("debug");
    if( d == null || typeof(d) == "undefined")
    {
        alert('debug javascript function called without a "div" id of debug accessible\nNOTE: you need to call commonInit() from the onload event!'); 
    }
    else
    {
        traceLines.push("<tr><td>" + buildTime(new Date()) + "</td><td>" + msg + "</td></tr>");
        var html = '';
        for(var i = traceLines.length-1; i >= 0 ; --i)
        {
            html += traceLines[i];
        }
        
        d.innerHTML = "<p><table><thead><th>Time</th><th>Message</th></thead><tbody>" 
            + html 
            + "</tbody></table></p>";
    }
}

function buildTime( dt )
{
    return right("0" + dt.getHours(),2) 
        + ":" + right("0" + dt.getMinutes(),2) 
        + ":" + right("0" + dt.getSeconds(),2) 
        + "." + right("000" + dt.getMilliseconds(),3);
}

function getTimeAsString(date)
{
	//return date.parse("hh:mm:ss.fff");
	return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "." + date.getMilliseconds();
}
/* example clipboard access
clipboardData.setData("Text","My Data");
var data = clipboardData.getData("Text");
alert("Data from clipboard: " + data);
*/
function object2String(obj, level)
{ 
    if(typeof level == 'undefined')
    {
        level = 0;
    }
    else
    {
        level++;
    }
    if( level > 10 )
    {
        return "";
    }
    var val, output = ""; 
    if (obj) { 
        output += "{"; 
        for (var i in obj) { 
            val = obj[i]; 
            switch (typeof val)
            { 
                case ("object"): 
                    if (val == null)
                    {
                        output += i + ":null,";
                    }
                    else if(typeof val.length != 'undefined' && val.length > 0)
                    { 
                        output += i + ":" + array2String(val, level) + ","; 
                    }
                    else
                    { 
                        output += i + ":" + val + ","; 
                    } 
                    break; 
                case ("string"): 
                    output += i + ":'" + encodeURI(val) + "',"; 
                    break; 
                default: 
                    output += i + ":" + val + ","; 
            } 
        } 
        if(output.length > 1 )
        {
			output = output.substring(0, output.length-1) + "}"; 
		}
		else if(output.length == 1)
		{
			output = "";
		}
    } 
    return output; 
} 

function array2String(array, level) { 
    if(typeof level == 'undefined')
    {
        level = 0;
    }
    else
    {
        level++;
    }
    if( level > 10 )
    {
        return "";
    }
    var output = ""; 
    if (array) { 
        output += "["; 
        for (var i in array) { 
            val = array[i]; 
            switch (typeof val) { 
                case ("object"): 
                    if (val == null)
                    {
                        output += i + ":null,";
                    }
                    else if(typeof val.length != 'undefined' && val.length > 0)
                    { 
                        output += i + ":" + array2String(val, level) + ","; 
                    }
                    else
                    { 
                        output += val + ","; 
                    } 
                    break; 
                case ("string"): 
                    output += "'" + encodeURI(val) + "',"; 
                    break; 
                default: 
                    output += val + ","; 
            } 
        } 
        if(output.length > 1)
        {
			output = output.substring(0, output.length-1) + "]"; 
		}
		else if( output.length == 1 )
		{
			output = "[]";
		}
		
    } 
    return output; 
} 

/*
	Expecting a color string like: 0,255,0
	will return 00FF00
*/
function convertRGBtoHEX( RGBColor )
{
	var values = RGBColor.split(",");
	var result = "";
	
	for( var i = 0 ; i < values.length ; ++i )
	{
		result += decimalToHEX(values[i]);
	}	
	return result;
}

/*
	Expecting a 20 (decimal value)
	will return 14 (a hex value)
*/
function decimalToHEX(value)
{
	var d = parseInt(value,10);
	if(!isNaN(d))
	{
		hexChars = "0123456789ABCDEF";
		if( d > 255 )
		{
			return d + " - out of range";
		}
		var i = d % 16;
		var j = (d - i) / 16;
		result = hexChars.charAt(j) + hexChars.charAt(i);
		return result;
	}
	else
	{
		return NaN;
	}
}

function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function hideElement( elm )
{
    setElementClass(elm,"hidden");
	elm.style.visibility="hidden";
	elm.style.display = "none";
}
function showElement( elm )
{
    setElementClass(elm,"show");
	elm.style.visibility = "visible";		
	elm.style.display = "block";
}
function hideShowElement( elm )
{
    var e = getElement(elm);
    if( e.className == "hidden")
    {
        setElementClass(e,"show");
    }
    else
    {
        setElementClass(e,"hidden");
    }
}

function setElementClass( elm, className)
{
    var e = getElement(elm);
    e.className = className;
}
/*
    Firefox passes the event object with
    the function being invoked from an event
    happening. This requires passing the event
    object to the getEventElement. This will
    be undefined for IE as you reference the
    event via the window.event object.
    
    This type of activity is only required
    when you are dynamically attaching events
    to your html objects (via attachEventsToControl
    or attachEventToControl).
*/
function getEventElement(e)
{
    var t;
    if( !e )
    {
        e = window.event;
    }
    if (e.target)
    {
        t = e.target;
    }
    else if (e.srcElement)
    {
        t = e.srcElement;
    }
    
    if (typeof(t) != 'undefined' && t.nodeType == 3) // defeat Safari bug
    {
	    t = t.parentNode;
	}
    return t;
}

/* 
    an example of dynamically attaching events
    to your html objects
    
   
var eventArray = new Array();
var t = new Array();
t[0] = "focus";
t[1] = gotFocusSetBackgroundColor;
eventArray[eventArray.length] = t;

var t = new Array();
t[0] = "focus";
t[1] = filterView;
eventArray[eventArray.length] = t;

t = new Array();
t[0] = "keyup";
t[1] = filterView;
eventArray[eventArray.length] = t;

t = new Array();
t[0] = "blur";
t[1] = lostFocusSetBackgroundColor;
eventArray[eventArray.length] = t;
*/
function attachEventsToControl( element, eventArray)
{
    var e = getElement(element);
    if( typeof e == "undefined")
    {
        alert("Element " + element + " not found; unable to attach events");
        return;
    }
    
    for(var i = 0 ; i < eventArray.length ; ++i )
    {
        attachEventToControl( e, eventArray[i][0], eventArray[i][1]);
    }
}

function attachEventToControl(element, eventName, eventCode)
{
    if( eventName.substring(0,2) == "on")
    {
        eventName = eventName.substring(2);
    }
    if(element.addEventListener)
    {
        element.addEventListener(eventName, eventCode, false);
    }
    else
    {
        element.attachEvent("on" + eventName, eventCode);
    }
}

function Replace( source, find, replaceWith)
{
    var saReplace = source.split(find);
    return saReplace.join(replaceWith);
}
var getComboContentsArray = new Array();
function getComboContents( src, allowCaching )
{
    if(allowCaching)
    {
        var list = getComboContentsArray[src];
        if(typeof(list) != "undefined")
        {
            return list;
        }
    }
    var s = getElement(src);
    var result = "";
    
    for(var i = 0 ; i < s.options.length ; ++i )
    {
        result += "<option value='" + s.options[i].value + "'>" + s.options[i].text + "</option>\n";
    }
    
    if(allowCaching)
    {
        getComboContentsArray[src] = result;
    }
    
    return result;
}



/*
    functions added in attempt to allow new browsers (FF v3+ and IE7+)
    to access attributes of an element.
*/
function getAttributeValue(element, attName )
{
    //in case for older browsers we need to back
    //to using element.value
    if(element.getAttribute)
    {
        return element.getAttribute(attName);
    }
    else
    {
        debug("eval=" + element.id + '.' + attName + "=" + eval(element.id + '.' + attName));
        return eval(element.id + '.' + attName);
    }
}
function setAttributeValue(element, attName, value )
{
    //in case for older browsers we need to back
    //to using element.value
    if(element.setAttribute)
    {
        element.setAttribute(attName, value);
    }
    else
    {
        eval(element.id + '.' + attName + '=' + value);
    }
}

/*
    return the char code of the key pressed
    
    other useful event properies are:
    evt.shiftKey || evt.ctrlKey || evt.altKey
*/
function getKeyPressedASCII(evt)
{
    //String.fromCharCode(evt.which);
    if(window.event)
    {
        return evt.keyCode;
    }
    else if( evt.which)
    {
        return evt.which;
    }
    return null;
}

function getNumerics(value)
{
    var result = "";
    
    for(var i = 0 ; i < value.length ; ++i )
    {
        var c = value.charAt(i);
        if( c > '/' && c < ':')
        {
            result += c;
        } 
    }
    
    return result;
}
function noNumerics(value)
{
    var result = "";
    
    for(var i = 0 ; i < value.length ; ++i )
    {
        var c = value.charAt(i);
        if( c <= '/' || c >= ':')
        {
            result += c;
        } 
    }
    
    return result;
}
var lastInvokedMilliseconds = new Date();
var setInvocationTimerTimer = null;
function setInvocationTimer( func, timerIntervalMilliseconds )
{
    //if the user is keying keys, wait till they finish
    var now = new Date();
    var diff = (now - lastInvokedMilliseconds);
    if(diff < timerIntervalMilliseconds)
    {
        //still keying, clear the timer so we do not invoke
        //the func
        window.clearTimeout(setInvocationTimerTimer);
        
        //now continue and set the func to fire in timerIntervalMilliseconds 
    }

    //more than timerIntervalMilliseconds, set the func to fire shortly
    setInvocationTimerTimer = setTimeout(func,timerIntervalMilliseconds);

    //log when were last invoked so we know if they
    //are keying reapeatedly
    lastInvokedMilliseconds = new Date();
}

-->


