/*
AddEvent Manager (c) 2005 Angus Turnbull http://www.twinhelix.com
Free usage permitted as long as this credit notice remains intact.
*/
if (typeof aeOL == 'undefined') {
 var aeOL = [];
 var addEvent = function(o, n, f, l) {
  var d = 'addEventListener', h = 'on' + n, t, a;
  if (o[d] && !l) return o[d](n, f, false);
  if (!o.aE) { o.aE = aeOL.length || 1; aeOL[o.aE] = { o:o } }
  t = aeOL[o.aE][n] || (aeOL[o.aE][n] = []);
  for (var i = 0; i < t.length; i++)
   for (var j = 0; j < t[i].length; j++)
    if (t[i][j] == f) return;
  if (o[h] && o[h]._ae) {
   a = t[t.length - 1];
   a[a.length] = f;
  } else {
   t[t.length] = o[h] ? [o[h], f] : [f];
   o[h] = new Function('e', 'var r = true, i = 0, o = aeOL[' + o.aE + '].o,' +
    'a = aeOL[' + o.aE + ']["' + n + '"][' + (t.length - 1) + '];' +
    'for (; i < a.length; i++) { ' +
	 'o._f = a[i]; r = o._f(e||window.event) != false && r; o._f = null;' +
    '} return r');
   o[h]._ae = 1;
  }
 };

 var removeEvent = function(o, n, f, l) {
  var d = 'removeEventListener', t, a, i, j, s;
  if (o[d] && !l) return o[d](n, f, false);
  if (!o.aE || !aeOL[o.aE]) return;
  t = aeOL[o.aE][n];
  i = t.length;
  while (i--) {
   a = t[i];
   j = a.length;
   s = 0;
   while (j--) {
    if (a[j] == f) s = 1;
    if (s) a[j] = a[j + 1];
   }
   if (s) { a.length--; break }
  }
 };

 function cancelEvent(e, c) {
  e.returnValue = false;
  if (e.preventDefault) e.preventDefault();
  if (c) {
   e.cancelBubble = true;
   if (e.stopPropagation) e.stopPropagation();
  }
 };
}