// Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.
// This is free software with ABSOLUTELY NO WARRANTY.
// You can redistribute it and/or modify it under the terms of the GNU GPL2.

// This file is automatically generated.
// PLEASE DO NOT EDIT THIS FILE.

function getById(id) {
  if (document.getElementById) {
    elem = document.getElementById(id);
    return elem;
  }
  if (document.all) return document.all(id);
  return null;
}
function getByName(name) {
  if (document.getElementsByTagName)
  return document.getElementsByTagName(name);
  if (document.all) return document.all.tags(name);
  return null;
}
function qwik_onload() {
  if (typeof wema_init != 'undefined') {
    wema_init();
  }
  if (typeof g_toc == 'undefined') {
    g_toc = new TOC();
    g_toc.init();
  }
  if (typeof g_niftypp != 'undefined') {
    g_niftypp.applyAll();
  }
}
document.getDivList = function() {
  if (document.getElementsByTagName)
  return document.getElementsByTagName("div");
  if (document.all) return document.all.tags("div");
  if (document.layers) return document.layers;
  return null;
}
document.getDivListByClass = function(cn) {
  var div = document.getDivList();
  var n = [];
  for (var i=0; i < div.length; i++)
    if (div[i].className == cn) n.push(div[i]);
  return n;
}
var g_toc;
function TOC() {
  this.init = function() {
    var t = getById("toc");
    if (!t) return;
    var h = t.firstChild;
    if (!h) return;
    if (h.nodeName != "H5") return;
    h.onmousedown = this.toggle;
    this.toggle();
  }
  this.toggle = function() {
    var t = getById("toc");
    if (!t) return;
    var i = getById("tocinside");
    if (!i) return;
    if (i.style.display == "none"){
      i.style.display = "block";
    }else{
      var w = t.clientWidth;
      i.style.display = "none";
      t.style.width = w+"px";
    }
  }
}
function Debug() {
  this.html = "";
  this.hWin = null;
  this.bDebug = true;
  this._alerted = false;
  this._width  = 400;
  this._height = 200;
  this.setDebug = function(flag) {
    this.bDebug = flag;
  }
  this.print = function(html) {
    this.html += ("<tt>" + html + "</tt><br\n/>");
  }
  this.flush = function() {
    if (this.bDebug == false) return;
    if (this.hWin == null || this.hWin.closed) {
      var opt = "menubar=yes,scrollbars=yes,resizable=yes";
      if (this._width)  opt += ",width=" +this._width;
      if (this._height) opt += ",height="+this._height;
      opt += "menubar=yes,scrollbars=yes,resizable=yes"
      this.hWin = window.open("", "debug", opt);
    }
    if (!this.hWin && !this._alerted) {
      alert("Please do not block debug window.");
      this._alerted = true;
      return;
    }
    if (!this.hWin) return;
    this.hWin.document.open("text/html", "replace");
    this.hWin.document.write(this.html);
    this.hWin.document.close();
    this.hWin.focus();
  }
  this.clear = function() {
    this.html = "";
    this.flush();
  }
  this.inspect = function(obj) {
    var delimiter = ", <br>";
    if (typeof obj == "number") {
      return ""+obj;
    } else if (typeof obj == "string") {
      return "\""+obj+"\"";
    } else if (typeof obj == "function") {
      return ""+obj;
    } else if (typeof obj == "object") {
      var str = "{";
      var added = false;
      for (key in obj) {
	var value = obj[key];
	if (value) {
	  if (added) str += delimiter;
	  added = true;
	  if (typeof value == "number") {
	    str += ""+key+"=>"+value+"";
	  } else if (typeof value == "string") {
	    str += ""+key+"=>\""+value+"\"";
	  } else if (typeof value == "function") {
	    str += ""+key+"()";
	  } else if (typeof value == "object") {
	    str += ""+key+"=>"+value+"";
	  } else {
	    str += ""+key+"=><"+(typeof value)+":"+value+">";
	  }
	}
      }
      return str+"}";
    } else {
      return "<"+(typeof obj)+":"+obj+">";
    }
  }
  this.p = function(elem) {
    var str = this.inspect(elem)
    this.print(str);
    this.flush();
  }
}
if (typeof g_debug == 'undefined') {
  var g_debug = new Debug();
}
document.getElementsBySelector = function(selector) { 
  var s=[];
  var selid="";
  var selclass="";
  var tag=selector;
  var objlist=[];
  if(selector.indexOf(" ")>0){  
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
  }
  if(selector.indexOf("#")>0){ 
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
  }
  if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
  }
  if (selector.indexOf(".") == 0) { 
    tag = "*";
    selclass = selector.slice(1, selector.length);
  } else if (selector.indexOf(".") > 0) {  
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
  }
  var v=document.getElementsByTagName(tag);  
  if(selclass=="")
  return(v);
  for(var i=0;i<v.length;i++){
    if(v[i].className==selclass){
      objlist.push(v[i]);
    }
  }
  return(objlist);
};
document.getElementsByClassName = function(klass) {
  var all = document.getElementsByTagName("*");
  var ar = [];
  for (var i = 0; i < all.length; i++) {
    if (all[i].className == klass)
      ar.push(all[i]);
  }
  return ar;
};
document.getCssRules = function() {
  var ar = [];
  var sheets = document.styleSheets;
  for (var i=0; i < sheets.length; i++) {
    var rules = document.styleSheets[i].rules;
    if (!rules) rules = document.styleSheets[i].cssRules;
    for (var j=0; j < rules.length; j++) {
      ar.push(rules[j]);
    }
  }
  return ar;
};
function NiftyCornerRule(position, selector, background, border, radius) {
  this.position = position;
  this.selector = selector;
  this.background = background;
  this.border = border;
  this.radius = radius; 
  this.makeLine = function(margin, height, bg) {
    var x = document.createElement("span");
    x.style.display = "block";
    x.style.height = ""+height+"px";
    x.style.margin = "0 "+margin+"px";
    x.style.overflow = "hidden";
    x.style.backgroundColor = bg;
    return x;
  };
  this.makeContainer = function(border) {
    var d = document.createElement("span");
    d.style.display = "block";
    d.style.backgroundColor = border;
    return d;
  };
  this.makeTop = function(bg, border) {
    var d = this.makeContainer(border);
    d.appendChild(this.makeLine(5, 1, bg));
    d.appendChild(this.makeLine(3, 1, bg));
    d.appendChild(this.makeLine(2, 1, bg));
    d.appendChild(this.makeLine(1, 2, bg));
    return d;
  };
  this.makeBottom = function(bg, border) {
    var d = this.makeContainer(border);
    d.appendChild(this.makeLine(1, 2, bg));
    d.appendChild(this.makeLine(2, 1, bg));
    d.appendChild(this.makeLine(3, 1, bg));
    d.appendChild(this.makeLine(5, 1, bg));
    return d;
  };
  this.applyToElement = function(el) {
    var bg     = this.background;
    var border = this.border;
    if (this.position == "both" || this.position == "top")
    el.insertBefore(this.makeTop(bg, border), el.firstChild);
    if (this.position == "both" || this.position == "bottom")
    el.appendChild(this.makeBottom(bg, border), el.firstChild);
  };
  this.apply = function() {
    var sel = this.selector;
    var els = document.getElementsBySelector(sel);
    if (!els) return;
    for (var i=0; i < els.length; i++) {
      var el = els[i];
      this.applyToElement(el);
    }
  };
}
function NiftyPP() {
  this.check = function() { 
    if (!document.getElementById || !document.createElement)
    return (false);
    var b = navigator.userAgent.toLowerCase();
    if (b.indexOf("msie 5") > 0 && b.indexOf("opera") == -1)
    return (false);
    return (true);
  };
  this.getNiftyCornerRules = function() {
    var ar = [];
    var rules = document.getCssRules();
    for (var i=0; i < rules.length; i++) {
      var rule   = rules[i];
      var selt   = rule.selectorText;
      var sel    = String(selt).toLowerCase();
      var style  = rule.style;
      var bg     = style.backgroundColor;
      var nc;
      var done = false;
      nc = style["moz-border-radius"];
      if (nc) {
	var border = style.borderColor;
	var obj = new NiftyCornerRule("both", sel, bg, border, nc);
	ar.push(obj);
	done = true;
      }
      if (!done) {
	nc = style["moz-border-radius-topleft"];
	if (nc) {
	  var border = style.borderTopColor;
	  var obj = new NiftyCornerRule("top", sel, bg, border, nc);
	  ar.push(obj);
	  done = true;
	}
      }
      if (!done) {
	nc = style["moz-border-radius-bottomleft"];
	if (nc) {
	  var border = style.borderBottomColor;
	  var obj = new NiftyCornerRule("bottom", sel, bg, border, nc);
	  ar.push(obj);
	  done = true;
	}
      }
      if (!done) {
	nc = style.MozBorderRadiusTopleft;
	if (nc) {
	  var border = style.borderTopColor;
	  var obj = new NiftyCornerRule("top", sel, bg, border, nc);
	  ar.push(obj);
	}
	nc = style.MozBorderRadiusBottomleft;
	if (nc) {
	  var border = style.borderBottomColor;
	  var obj = new NiftyCornerRule("bottom", sel, bg, border, nc);
	  ar.push(obj);
	}
      }
    }
    return ar;
  };
  this.applyAll = function() {
    var ncs = this.getNiftyCornerRules();
    for (var i=0; i < ncs.length; i++) {
      var nc = ncs[i];
      nc.apply();
    }
    return false;
  };
}
var g_niftypp;
if (typeof g_niftypp == 'undefined') {
  g_niftypp = new NiftyPP();
}
