tooltip = {
        name : "js-tooltipDiv",	// div pop-up ID
        offsetX : 0,
        offsetY : 20,
        tip : null
};
tooltip.init = function () {
	var body = document.getElementsByTagName('body').item(0);
	var div = document.createElement('div');
	div.id = this.name;
	body.appendChild(div);

	if (!document.getElementById) return;
	
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	/*- <a title> -*/
	var anchors = document.getElementsByTagName ("a");
	for (var i = 0; i < anchors.length; i ++) {
			a = anchors[i];
			if (a.getAttribute('title')) {
				a.setAttribute('nicetitle',a.getAttribute('title'));
				a.removeAttribute('title');
				a.onmouseover = function () {tooltip.show (this.getAttribute('nicetitle'))};
				a.onmouseout = function () {tooltip.hide ()};
			}
	}
	/*- <img longdesc> -*/
	var images = document.getElementsByTagName ("img");
	for (var i = 0; i < images.length; i ++) {
			i = images[i];
			if (i.getAttribute('longdesc')) {
				i.onmouseover = function () {tooltip.show (this.getAttribute('longdesc'))};
				i.onmouseout = function () {tooltip.hide ()};
			}
	}

	/*- <label title> -*/
	var labels = document.getElementsByTagName ("label");
	for (var i = 0; i < labels.length; i ++) {
		l = labels[i];
		if (l.getAttribute('title')) {
			l.setAttribute('nicetitle',l.getAttribute('title'));
			l.removeAttribute('title');
			l.onmouseover = function () {tooltip.show (this.getAttribute('nicetitle'))};
			l.onmouseout = function () {tooltip.hide ()};
		}
	}

};
tooltip.move = function (evt) {
        var x=0, y=0;
        if (document.all) {

                x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
                y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
                x += window.event.clientX;
                y += window.event.clientY;
                
        } else {
                x = evt.pageX;
                y = evt.pageY;
        }
        this.tip.style.left = (x + this.offsetX) + "px";
        this.tip.style.top = (y + this.offsetY) + "px";
};
tooltip.show = function (text) {
        if (!this.tip) return;
        this.tip.innerHTML = text;
        this.tip.style.visibility = "visible";
        this.tip.style.display = "block";
};
tooltip.hide = function () {
        if (!this.tip) return;
        this.tip.style.visibility = "hidden";
        this.tip.style.display = "none";
        this.tip.innerHTML = "";
};


function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
