function Utils()
{
} // Utils
Utils.H_POSITION_AUTO         = 'auto';
Utils.H_POSITION_CENTER       = 'center';
Utils.H_POSITION_CENTER_MOUSE = 'center_mouse';
Utils.H_POSITION_LEFT_MOUSE   = 'left_mouse';
Utils.H_POSITION_NONE         = 'none';
Utils.H_POSITION_RIGHT_MOUSE  = 'right_mouse';
Utils.V_POSITION_ABOVE_MOUSE  = 'above';
Utils.V_POSITION_AUTO         = 'auto';
Utils.V_POSITION_BELOW_MOUSE  = 'below';
Utils.V_POSITION_CENTER       = 'center';
Utils.V_POSITION_CENTER_MOUSE = 'center_mouse';
Utils.V_POSITION_NONE         = 'none';
Utils._browserInfoData = [
{
identity: 'omniweb',
string: navigator.userAgent,
subString: 'OmniWeb',
versionSearch: 'OmniWeb/'
},
{
identity: 'safari',
string: navigator.vendor,
subString: 'Apple',
versionSearch: 'Safari'
},
{
identity: 'opera',
prop: window.opera,
versionSearch: 'Opera'
},
{
identity: 'icab',
string: navigator.vendor,
subString: 'iCab',
versionSearch: 'iCab'
},
{
identity: 'konqueror',
string: navigator.vendor,
subString: 'KDE',
versionSearch: 'Konqueror'
},
{
identity: 'firefox',
string: navigator.userAgent,
subString: 'Firefox',
versionSearch: 'Firefox'
},
{
identity: 'camino',
string: navigator.vendor,
subString: 'Camino',
versionSearch: 'Camino'
},
{
identity: 'netscape',
string: navigator.userAgent,
subString: 'Netscape',
versionSearch: 'Netscape'
},
{
identity: 'ie',
string: navigator.userAgent,
subString: 'MSIE',
versionSearch: 'MSIE'
},
{
identity: 'mozilla',
string: navigator.userAgent,
subString: 'Gecko',
versionSearch: 'rv'
},
{
identity: 'netscape',
string: navigator.userAgent,
subString: 'Mozilla',
versionSearch: 'Mozilla'
}
];
Utils._browserInfoOs = [
{
identity: 'win',
string: navigator.platform,
subString: 'Win'
},
{
identity: 'mac',
string: navigator.platform,
subString: 'Mac'
},
{
identity: 'lin',
string: navigator.platform,
subString: 'Linux'
}
];
Utils._reloadTimeout = null;
Utils.autoReload = function(secs)
{
if (secs)
{
Utils._reloadTimeout = secs * 1000;
window.setTimeout("Utils._reload()", Utils._reloadTimeout);
} // if
} // autoReload
Utils.centerElem = function(elem)
{
Utils.positionElem(elem,
Utils.V_POSITION_CENTER,
Utils.H_POSITION_CENTER);
} // centerElem
Utils.changeOnConfirm = function(msg,
url)
{
if (confirm(msg))
{
document.location = url;
} // if
} // changeOnConfirm
Utils.changeTab = function(ids,
id)
{
for (var i = 0; i < ids.length; i++)
{
document.getElementById(ids[i]).style.display = 'none';
document.getElementById(ids[i] + 'Tab').className = '';
} // for
document.getElementById(id).style.display = 'block';
document.getElementById(id + 'Tab').className = 'active';
} // changeTab
Utils.cmp = function(a,
b)
{
if (a < b)
{
return (-1);
} // if
if (a > b)
{
return (1);
} // if
return (0);
} // cmp
Utils.createFlashObject = function(id,
classid,
src,
name,
width,
height,
params,
version,
extra)
{
var elem = document.getElementById(id);
if (elem)
{
var s = '<object classid="' + classid + '" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + '" width="' + width + '" height="' + height + '" id="' + name + '" name="' + name + '" ' + extra + '>';
s += '<param name="movie" value="' + src + '" />';
for (var i in params)
{
s += '<param name="' + i + '" value="' + params[i] + '" />';
} // for
s += '<embed src="' + src + '" width="' + width + '" height="' + height + '" id="' + name + '" name="' + name + '" swliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
for (var i in params)
{
s += i + '="' + params[i] + '" ';
} // for
s += extra + ' /></object>';
elem.innerHTML = s;
} // if
} // createFlashObject
Utils.execOnConfirm = function(msg,
fn)
{
if (confirm(msg))
{
fn();
} // if
} // execOnConfirm
Utils.formatFloat = function(value,
format)
{
value = '' + parseFloat(value);
var temp = format.split('.',
2);
var intPlaces = parseInt(temp[0]);
var decPlaces = parseInt(temp[1]);
var pos = value.indexOf('.');
if (pos == -1)
{
if (decPlaces > 0)
{
value += '.';
} // if
pos = value.length - 1;
} // if
while ((value.length - pos) <= decPlaces)
{
value += '0';
} // while
var len = intPlaces - pos;
for (var i = 0; i < len; i++)
{
value = '0' + value;
} // for
return (value);
} // formatFloat
Utils.formatPrice = function(value)
{
return ('$' + Utils.formatFloat(value, '1.2'));
} // formatPrice
Utils.getBrowserInfo = function()
{
var temp = Utils._searchBrowserString(Utils._browserInfoData);
if (temp)
{
var browser = temp[0];
var version = Utils._searchBrowserVersion(navigator.userAgent, temp[1]) || Utils._searchBrowserVersion(navigator.appVersion, temp[1]);
temp = Utils._searchBrowserString(Utils._browserInfoOs);
if (temp)
{
var os = temp[0];
} // if
else
{
var os = null;
} // else
return (new Array(browser, version, os));
} // if
return (null);
} // getBrowserInfo
Utils.getDaysInMonth = function(year,
month)
{
switch (month)
{
case 2:
if (Utils.isLeapYear(year))
{
return (29);
} // if
return (28);
case 4:
case 6:
case 9:
case 11:
return (30);
} // switch
return (31);
} // getDaysInMonth
Utils.getElementPosition = function(elem)
{
var left = 0;
var top = 0;
if (elem.offsetParent)
{
left = elem.offsetLeft;
top = elem.offsetTop;
while (elem = elem.offsetParent)
{
left += elem.offsetLeft;
top += elem.offsetTop;
} // while
} // if
return (new Array(left, top));
} // getElementPosition
Utils.getMonthString = function(m)
{
switch (m)
{
case 1:  return 'January';
case 2:  return 'February';
case 3:  return 'March';
case 4:  return 'April';
case 5:  return 'May';
case 6:  return 'June';
case 7:  return 'July';
case 8:  return 'August';
case 9:  return 'September';
case 10: return 'October';
case 11: return 'November';
default: return 'December';
} // switch
} // getMonthString
Utils.getWindowHeight = function()
{
if (typeof(window.innerHeight) == 'number')
{
return (window.innerHeight);
} // if
if ((document.documentElement) &&
(document.documentElement.clientHeight))
{
return (document.documentElement.clientHeight);
} // if
if ((document.body) &&
(document.body.clientHeight))
{
return (document.body.clientHeight);
} // if
return (0);
} // getWindowHeight
Utils.getWindowWidth = function()
{
if (typeof(window.innerWidth) == 'number')
{
return (window.innerWidth);
} // if
if ((document.documentElement) &&
(document.documentElement.clientWidth))
{
return (document.documentElement.clientWidth);
} // if
if ((document.body) &&
(document.body.clientWidth))
{
return (document.body.clientWidth);
} // else if
return (0);
} // getWindowWidth
Utils.getWindowXOffset = function()
{
if (typeof(window.pageXOffset) == 'number')
{
return (window.pageXOffset);
} // if
if ((document.documentElement) &&
(document.documentElement.scrollLeft))
{
return (document.documentElement.scrollLeft);
} // if
if ((document.body) &&
(document.body.scrollLeft))
{
return (document.body.scrollLeft);
} // else if
return (0);
} // getWindowXOffset
Utils.getWindowYOffset = function()
{
if (typeof(window.pageYOffset) == 'number')
{
return (window.pageYOffset);
} // if
if ((document.documentElement) &&
(document.documentElement.scrollTop))
{
return (document.documentElement.scrollTop);
} // if
if ((document.body) &&
(document.body.scrollTop))
{
return (document.body.scrollTop);
} // else if
return (0);
} // getWindowYOffset
Utils.hideChildren = function(elem)
{
for (var i = 0; i < elem.childNodes.length; i++)
{
if (elem.childNodes[i].style)
{
elem.childNodes[i].style.display = 'none';
} // if
} // for
} // hideChildren
Utils.isLeapYear = function(year)
{
if (!(year % 4))
{
return ((year % 100) || (!(year % 400)));
} // if
return (false);
} // isLeapYear
Utils.openWindow = function(url,
title)
{
window.open(url,
title,
'innerHeight=window.innerHeight,innerWidth=window.innerWidth,location=yes,menubar=yes,resizeable=yes,scrollbars=yes,titlebar=yes,toolbar=yes');
} // openWindow
Utils.parseDttm = function(dttm)
{
if (!dttm)
{
return (null);
} // if
var obj = new Object();
obj.year = dttm.substring(0, 4);
obj.month = dttm.substring(4, 6);
obj.day = dttm.substring(6, 8);
obj.hours24 = dttm.substring(8, 10);
var temp = parseInt(obj.hours24);
if (temp > 12)
{
obj.hours12 = temp - 12;
obj.amPm = 'pm';
} // if
else if (temp == 0)
{
obj.hours12 = 12;
obj.amPm = 'am';
} // else if
else if (temp == 12)
{
obj.hours12 = 12;
obj.amPm = 'pm';
} // else if
else
{
obj.hours12 = obj.hours24;
obj.amPm = 'am';
} // else
obj.minutes = dttm.substring(10, 12);
obj.seconds = dttm.substring(12, 14);
switch (parseInt(obj.month))
{
case 1:  obj.monthNameShort = 'Jan'; obj.monthNameLong = 'January'; break;
case 2:  obj.monthNameShort = 'Feb'; obj.monthNameLong = 'February'; break;
case 3:  obj.monthNameShort = 'Mar'; obj.monthNameLong = 'March'; break;
case 4:  obj.monthNameShort = 'Apr'; obj.monthNameLong = 'April'; break;
case 5:  obj.monthNameShort = 'May'; obj.monthNameLong = 'May'; break;
case 6:  obj.monthNameShort = 'Jun'; obj.monthNameLong = 'June'; break;
case 7:  obj.monthNameShort = 'Jul'; obj.monthNameLong = 'July'; break;
case 8:  obj.monthNameShort = 'Aug'; obj.monthNameLong = 'August'; break;
case 9:  obj.monthNameShort = 'Sep'; obj.monthNameLong = 'September'; break;
case 10: obj.monthNameShort = 'Oct'; obj.monthNameLong = 'October'; break;
case 11: obj.monthNameShort = 'Nov'; obj.monthNameLong = 'November'; break;
case 12: obj.monthNameShort = 'Dec'; obj.monthNameLong = 'December'; break;
default: obj.monthNameShort = '???'; obj.monthNameLong = '???'; break;
} // switch
return (obj);
} // parseDttm
Utils.positionElem = function(elem,
vpos,
hpos)
{
if ((vpos == null) ||
(vpos == undefined))
{
vpos = Utils.V_POSITION_CENTER;
} // if
if ((hpos == null) ||
(hpos == undefined))
{
hpos = Utils.H_POSITION_CENTER;
} // if
var top = Utils.getWindowYOffset();
var left = Utils.getWindowXOffset();
var w = Utils.getWindowWidth();
var h = Utils.getWindowHeight();
var x_changed = false;
var y_changed = false;
if (vpos != Utils.V_POSITION_NONE)
{
switch (vpos)
{
case Utils.V_POSITION_ABOVE_MOUSE:
var y = window.o3_y - elem.clientHeight - 20;
break;
case Utils.V_POSITION_AUTO:
case Utils.V_POSITION_CENTER_MOUSE:
var y = Math.round(window.o3_y - (elem.clientHeight / 2));
if (hpos == Utils.V_POSITION_AUTO)
{
if (y < (top + 10))
{
y = top + 10;
} // if
else if ((y + elem.clientWidth) > (h + top - 20))
{
y = h + top - elem.clientWidth - 20;
} // else if
if (y < 0)
{
y = 0;
} // if
} // if
break;
case Utils.V_POSITION_BELOW_MOUSE:
var y = window.o3_y + 10;
break;
case Utils.V_POSITION_CENTER:
var y = Math.round((h - elem.clientHeight) / 2);
if (y < 0)
{
y = 0;
} // if
y += top;
break;
default:
if (isNaN(vpos))
{
var temp = vpos.substr(0,
vpos.length - 2);
if ((vpos.substr(vpos.length - 2) == 'ab') &&
(!isNaN(temp)))
{
var y = parseInt(temp);
} // if
} // if
else
{
var y = window.o3_y + parseInt(vpos);
} // else
break;
} // switch
elem.style.top = y + 'px';
y_changed = true;
} // if
if (hpos != Utils.H_POSITION_NONE)
{
switch (hpos)
{
case Utils.H_POSITION_AUTO:
case Utils.H_POSITION_CENTER_MOUSE:
var x = Math.round(window.o3_x - (elem.clientWidth / 2));
if (hpos == Utils.H_POSITION_AUTO)
{
if (x < (left + 10))
{
x = left + 10;
} // if
else if ((x + elem.clientWidth) > (w + left - 20))
{
x = w + left - elem.clientWidth - 20;
} // else if
if (x < 0)
{
x = 0;
} // if
} // if
break;
case Utils.H_POSITION_LEFT_MOUSE:
var x = window.o3_x - elem.clientWidth - 20;
break;
case Utils.H_POSITION_RIGHT_MOUSE:
var x = window.o3_x + elem.clientWidth + 10;
break;
case Utils.H_POSITION_CENTER:
var x = Math.round((w - elem.clientWidth) / 2);
if (x < 0)
{
x = 0;
} // if
x += left;
break;
default:
if (isNaN(hpos))
{
var temp = hpos.substr(0,
hpos.length - 2);
if ((hpos.substr(hpos.length - 2) == 'ab') &&
(!isNaN(temp)))
{
var x = parseInt(temp);
} // if
} // if
else
{
var x = window.o3_x + parseInt(hpos);
} // else
break;
} // switch
elem.style.left = x + 'px';
x_changed = true;
} // if
var temp = Utils.getElementPosition(elem);
if (temp)
{
var left = temp[0];
var top = temp[1];
if (y_changed)
{
if (top != y)
{
elem.style.top = (y - top + y) + 'px';
} // if
} // if
if (x_changed)
{
if (left != x)
{
elem.style.left = (x - left + x) + 'px';
} // if
} // if
} // if
} // positionElem
Utils.removeCells = function(elem)
{
while (elem.cells.length > 0)
{
elem.removeChild(elem.firstChild);
} // while
} // removeCells
Utils.removeChildren = function(elem)
{
while (elem.childNodes.length)
{
elem.removeChild(elem.firstChild);
} // while
} // removeChildren
Utils.removeRows = function(elem)
{
while (elem.rows.length > 0)
{
elem.removeChild(elem.firstChild);
} // while
} // removeRows
Utils.rotateImage = function(id,
images,
interval)
{
if ((id) &&
(images) &&
(interval))
{
Utils._rotateImageId = id;
Utils._rotateImageImages = images;
Utils._rotateImageTimer = setInterval('Utils._timerRotateImage()',
interval * 1000);
} // if
} // rotateImage
Utils.trim = function(s)
{
var i = 0;
for (i = 0; i < s.length; i++)
{
if ((s[i] != ' ') && (s[i] != '\t') && (s[i] != '\n'))
{
break;
} // if
} // for
if (i >= s.length)
{
return ('');
} // if
var j;
for (j = s.length - 1; j > i; j--)
{
if ((s[j] != ' ') && (s[j] != '\t') && (s[j] != '\n'))
{
break;
} // if
} // for
s = s.substring(i,
j + 1);
return (s);
} // trim
Utils.updateTextInput = function(control,
id,
onlyIfEmpty)
{
if (onlyIfEmpty == undefined)
{
onlyIfEmpty = true;
} // if
var elem = document.getElementById(id);
if (elem)
{
if ((!onlyIfEmpty) ||
(!elem.value.length))
{
elem.value = control.value;
} // if
} // if
} // updateTextInput
Utils.urlEncode = function(url)
{
return (escape(url).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F'));
} // urlEncode
Utils.xmlToObject = function(xml)
{
if (!xml)
{
return (null);
} // if
if (!xml.documentElement)
{
return (null);
} // if
return (Utils._xmlElemToObj(xml.documentElement));
} // xmlToObject
Utils._reload = function()
{
document.location = document.location;
window.setTimeout("Utils._reload()", Utils._reloadTimeout);
} // _reload
Utils._searchBrowserString = function(data)
{
for (var i = 0; i < data.length; i++)
{
if (data[i].string)
{
if (data[i].string.indexOf(data[i].subString) != -1)
{
return (new Array(data[i].identity, data[i].versionSearch));
} // if
} // if
else if (data[i].prop)
{
return (new Array(data[i].identity, data[i].versionSearch));
} // else if
} // for
return (null);
} // _searchBrowserString
Utils._searchBrowserVersion = function(dataString,
versionString)
{
var index = dataString.indexOf(versionString);
if (index == -1)
{
return (null);
} // if
return (parseFloat(dataString.substring(index + versionString.length + 1)));
} // _searchBrowserVersion
Utils._timerRotateImage = function()
{
id = Utils._rotateImageId;
images = Utils._rotateImageImages;
if ((id) &&
(images))
{
var elem = document.getElementById(id);
} // if
if (!elem)
{
if (Utils._rotateImageTimer)
{
clearInterval(Utils._rotateImageTimer);
} // if
return;
} // if
var src = elem.src;
var temp = src.indexOf('/images/');
if (!temp)
{
if (Utils._rotateImageTimer)
{
clearInterval(Utils._rotateImageTimer);
} // if
return;
} // if
var idx = 0;
src = src.substr(temp);
for (var i = 1; i < images.length; i++)
{
if (src == images[i])
{
idx = i;
break;
} // if
} // for
idx++;
if (idx >= images.length)
{
idx = 0;
} // if
elem.src = images[idx];
} // _timerRotateImage
Utils._xmlElemToObj = function(elem)
{
var i;
if (elem.childNodes.length == 0)
{
return (null);
} // if
if ((elem.childNodes.length == 1) &&
(elem.firstChild.nodeType == 3))
{
return (elem.firstChild.nodeValue);
} // if
var ret = new Object();
for (i = 0; i < elem.childNodes.length; i++)
{
if (elem.childNodes[i].nodeName.substr(0, 5) == '_NUM_')
{
var name = elem.childNodes[i].nodeName.substr(5);
} // if
else
{
var name = elem.childNodes[i].nodeName;
} // else
ret[name] = Utils._xmlElemToObj(elem.childNodes[i]);
} // for
return (ret);
} // _xmlElemToObj
