1
// Core javascript helper functions
3
// basic browser identification & version
4
var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion);
5
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
7
// Cross-browser event handlers.
8
function addEvent(obj, evType, fn) {
9
if (obj.addEventListener) {
10
obj.addEventListener(evType, fn, false);
12
} else if (obj.attachEvent) {
13
var r = obj.attachEvent("on" + evType, fn);
20
function removeEvent(obj, evType, fn) {
21
if (obj.removeEventListener) {
22
obj.removeEventListener(evType, fn, false);
24
} else if (obj.detachEvent) {
25
obj.detachEvent("on" + evType, fn);
32
// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
33
function quickElement() {
34
var obj = document.createElement(arguments[0]);
35
if (arguments[2] != '' && arguments[2] != null) {
36
var textNode = document.createTextNode(arguments[2]);
37
obj.appendChild(textNode);
39
var len = arguments.length;
40
for (var i = 3; i < len; i += 2) {
41
obj.setAttribute(arguments[i], arguments[i+1]);
43
arguments[1].appendChild(obj);
47
// ----------------------------------------------------------------------------
48
// Cross-browser xmlhttp object
49
// from http://jibbering.com/2002/4/httprequest.html
50
// ----------------------------------------------------------------------------
53
/*@if (@_jscript_version >= 5)
55
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
58
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
66
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
67
xmlhttp = new XMLHttpRequest();
70
// ----------------------------------------------------------------------------
71
// Find-position functions by PPK
72
// See http://www.quirksmode.org/js/findpos.html
73
// ----------------------------------------------------------------------------
74
function findPosX(obj) {
76
if (obj.offsetParent) {
77
while (obj.offsetParent) {
78
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
79
obj = obj.offsetParent;
81
// IE offsetParent does not include the top-level
82
if (isIE && obj.parentElement){
83
curleft += obj.offsetLeft - obj.scrollLeft;
91
function findPosY(obj) {
93
if (obj.offsetParent) {
94
while (obj.offsetParent) {
95
curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
96
obj = obj.offsetParent;
98
// IE offsetParent does not include the top-level
99
if (isIE && obj.parentElement){
100
curtop += obj.offsetTop - obj.scrollTop;
108
//-----------------------------------------------------------------------------
109
// Date object extensions
110
// ----------------------------------------------------------------------------
111
Date.prototype.getCorrectYear = function() {
112
// Date.getYear() is unreliable --
113
// see http://www.quirksmode.org/js/introdate.html#year
114
var y = this.getYear() % 100;
115
return (y < 38) ? y + 2000 : y + 1900;
118
Date.prototype.getTwoDigitMonth = function() {
119
return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);
122
Date.prototype.getTwoDigitDate = function() {
123
return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
126
Date.prototype.getTwoDigitHour = function() {
127
return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
130
Date.prototype.getTwoDigitMinute = function() {
131
return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
134
Date.prototype.getTwoDigitSecond = function() {
135
return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
138
Date.prototype.getISODate = function() {
139
return this.getCorrectYear() + '-' + this.getTwoDigitMonth() + '-' + this.getTwoDigitDate();
142
Date.prototype.getHourMinute = function() {
143
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
146
Date.prototype.getHourMinuteSecond = function() {
147
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
150
// ----------------------------------------------------------------------------
151
// String object extensions
152
// ----------------------------------------------------------------------------
153
String.prototype.pad_left = function(pad_length, pad_string) {
154
var new_string = this;
155
for (var i = 0; new_string.length < pad_length; i++) {
156
new_string = pad_string + new_string;
161
// ----------------------------------------------------------------------------
162
// Get the computed style for and element
163
// ----------------------------------------------------------------------------
164
function getStyle(oElm, strCssRule){
166
if(document.defaultView && document.defaultView.getComputedStyle){
167
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
169
else if(oElm.currentStyle){
170
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
171
return p1.toUpperCase();
173
strValue = oElm.currentStyle[strCssRule];