NN.Utils = {
debug: function () {
return;
if (typeof console == "undefined" || !console.firebug) return;
console.log.apply(console, arguments);
},
'g': function (id) {
return document.getElementById(id);
},
'chkbox': function (options) {
var o = document.getElementsByName(options.name);
if (o == null) return;
switch (o.length) {
case 0:
var chk = false;
var o = document.getElementById(options.name);
if (o == null) return false;
if (o.checked == true) var chk = true;
switch (options.mode) {
default:
return chk;
break;
case 'val':
return chk == true ? o.value : -1;
break;
}
return false;
break;
default:
for (var i = 0, stack = []; i < o.length; i++) {
switch (options.mode) {
default:
o[i].checked = !o[i].checked;
break;
case 'un':
o[i].checked = false;
break;
case 'all':
o[i].checked = true;
break;
case 'chk':
if (o[i].checked == true) var chk = true;
break;
case 'val':
if (o[i].checked == true) var val = i;
break;
case 'stack':
if (o[i].checked == true) stack.push(o[i].value);
break;
case 'key':
if (o[i].checked == true) var key = i;
break;
}
}
if (options.mode == 'chk' && chk != true) {
if (typeof options.msg != 'undefined') alert(options.msg);
return false;
}
else if (options.mode == 'val') {
if (typeof val == 'undefined') return -1;
return o[val].value;
}
else if (options.mode == 'stack') {
return stack;
}
else if (options.mode == 'key') {
if (typeof key == 'undefined') return -1;
return key;
}
break;
}
},
'getPageSize': function () {
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
}
else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
}
else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
}
else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
if (yScroll < windowHeight) {
pageHeight = windowHeight;
}
else {
pageHeight = yScroll;
}
if (xScroll < windowWidth) {
pageWidth = windowWidth;
}
else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight, xScroll, yScroll);
return arrayPageSize;
},
'getPageScroll': function () {
var yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop) {
yScroll = document.documentElement.scrollTop;
}
else if (document.body) {
yScroll = document.body.scrollTop;
}
return yScroll;
},
'getAbsolutePosition': function (element) {
var r = {
x: element.offsetLeft,
y: element.offsetTop
};
if (element.offsetParent) {
var tmp = NN.Utils.getAbsolutePosition(element.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
},
'prevent': function (e) {
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
if (e.preventDefault) {
e.preventDefault();
}
e.returnValue = false;
},
'disableSelect': function (obj) {
var bs = obj || document.body.style;
if (bs.MozUserSelect != undefined) {
bs.MozUserSelect = 'none';
}
else if (bs.KhtmlUserSelect != undefined) {
bs.KhtmlUserSelect = 'none';
}
else {
bs.unselectable = 'on';
}
},
'restoreSelect': function (obj) {
var bs = obj || document.body.style;
if (bs.MozUserSelect != undefined) {
bs.MozUserSelect = null;
}
else if (bs.KhtmlUserSelect != undefined) {
bs.KhtmlUserSelect = null;
}
else {
bs.unselectable = 'off';
}
},
'displayMultimedia': function (src, width, height, options) {
var defaults = {
wmode: 'transparent',
allowScriptAccess: 'sameDomain',
quality: 'high',
flashvars: '',
autostart: false,
movieType: 'url'
};
var params = Object.extend(defaults, options || {});
switch (params['movieType']) {
case 'url':
var autostart = (params.autostart && params.autostart != 'false') ? 'true' : 'false';
delete(params.autostart);
var
clsid = "",
codebase = "",
html = "";
if (/\.swf/i.test(src)) {
clsid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";
html = '';
}
else {
html = '