// Copyright 2004-2008 Stephane Lavergne <www.imars.com>
// Free software under <http://www.gnu.org/licenses/gpl-3.0.txt>
// Modules below: imars.js imars.dom.js imars.dom.altsrc.js imars.dom.zebra.js
// Appended enrich.js by hand
if (!window['min']) {
window.min = function (a, b) {
return ((a<b) ? a : b);
};
};
if (!window['max']) {
window.max = function (a, b) {
return ((a>b) ? a : b);
};
};
var imars = {
base: document.getElementsByTagName ? (document.getElementsByTagName("base")[0] ? document.getElementsByTagName("base")[0].href : '') : null,
head: document.getElementsByTagName ? document.getElementsByTagName('head')[0] : null,
jsbase: '/lib/',
includes: [],
loaded: false,
require: function(s) { return false; },
use: function(base, that) {
if (typeof(base) == 'object') {
if (!that) {
that = window;
};
for (var i in base) {
that[i] = base[i];
};
};
},
onLoad: function (hook, args) {
var ready = document.readyState;
if (imars.loaded || (ready && (ready == 4 || ready == 'complete' || ready == 'loaded'))) {
hook.apply(null, args);
} else {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
if (args && hook.apply) {
window.onload = function() { hook.apply(null, args); };
} else {
window.onload = function() { hook(); };
};
} else {
if (args && hook.apply) {
window.onload = function() { oldonload(); hook.apply(null, args); };
} else {
window.onload = function() { oldonload(); hook(); };
};
};
};
}
};
imars.onLoad(function(){ imars.loaded = true; });
imars.dom = {
getElementsByClassName: function (doc, tName, cName) {
var r = [];
var e = (tName == "*" && doc.all) ? doc.all : (doc.getElementsByTagName ? doc.getElementsByTagName(tName) : []);
cName = cName.replace(/\-/g, "\\-");
var re = new RegExp("(^|\\s)" + cName + "(\\s|$)");
var oe;
for (var i = 0, max = e.length; i < max; i++) {
oe = e[i];
if (re.test(oe.className)) {
r.push(oe);
};
};
return r;
},
getElementsById: function (doc, tName, idre) {
var r = [];
var e = (tName == "*" && doc.all) ? doc.all : (doc.getElementsByTagName ? doc.getElementsByTagName(tName) : []);
idre = idre.replace(/\-/g, "\\-");
idre = idre.replace(/\*/g, ".*");
var re = new RegExp("(^|\\s)" + idre + "(\\s|$)");
var oe;
for (var i = 0, max = e.length; i < max; i++) {
oe = e[i];
if (re.test(oe.id)) {
r.push(oe);
};
};
return r;
},
hide: function (el) {
var e = el;
if (!e.style && document.getElementById) e = document.getElementById(el);
if (e.style) e.style.display = 'none';
return false;
},
show: function (el) {
var e = el;
if (!e.style && document.getElementById) e = document.getElementById(el);
if (e.style) e.style.display = 'block';
return false;
},
toggle: function (el) {
var e = el;
if (!e.style && document.getElementByid) e = document.getElementById(el);
if (e.style) {
if (e.style.display == 'none') {
e.style.display = 'block';
} else {
e.style.display = 'none';
};
};
return false;
}
};
imars.require("imars.dom");
imars.dom.altsrc = function () {
var is = imars.dom.getElementsByClassName(document, 'img', 'altsrc');
var iCount = is.length;
for (var i=0; i < iCount; i++) {
var newsrc = is[i].alt;
var toks = newsrc.split(' ');
if (toks.length > 0) newsrc = toks[0];
if (toks.length > 0 && newsrc != is[i].src) is[i].src = newsrc;
};
};
imars.onLoad(imars.dom.altsrc);
imars.require("imars.dom");
imars.dom.zebra = function (doc) {
if (!doc) doc = document;
if (doc.getElementsByTagName) {
var bs = imars.dom.getElementsByClassName(doc, '*', 'zebra');
var bCount = bs.length;
var rns = [ 'tr', 'dt', 'dd' ];
var rnCount = rns.length;
for (var i=0; i < bCount; i++) {
for (var j=0; j < rnCount; j++) {
var rs = bs[i].getElementsByTagName(rns[j]);
var rCount = rs.length;
for (var k=0; k < rCount; k++) {
if (k % 2) rs[k].className = 'odd';
};
};
};
};
};
imars.onLoad(imars.dom.zebra);
imars.onLoad(function(){
var days = imars.dom.getElementsByClassName(document, 'p', 'day');
for (var i=0; i < days.length; i++) {
days[i].className = 'day_' + (i+1);
};
});
