// JavaScript Document
//****************************************************
//*   Idea: Help Object                              *
//*   Methods: o.show(object,e), o.hide(object)      *
//*            o.addItem('text1')                    *
//*   Procedure: hideAll()                           *
//****************************************************

function helpObject()
{
        this.layerList = new Array();
        this.formList = new Array();
        this.width=300; //width of helpbox;
        this. height=100; //height of helpbox
        this.zindex = 101;
        helpObject.prototype.showHelp = showHelp;
        helpObject.prototype.hideHelp = hideHelp;
        helpObject.prototype.hideAll = hideAll;
        helpObject.prototype.AddHelp = AddHelp;
        helpObject.prototype.DelHelp = DelHelp;
        helpObject.prototype.hideForms = hideForms;
        helpObject.prototype.showForms = showForms;
        Array.prototype.IsInArray = IsInArray;
        Array.prototype.arraySeek = arraySeek;

function showHelp(object,e) {

var coords = new getCoords(e);
var scr = new getScreenDim()

if ((coords.posx + this.width)>scr.maxX)
{
	x = scr.maxX - this.width - 0
}
else
{
	x = coords.posx - 0
}
if ((coords.posy + this.height)>scr.maxY)
{
	y = scr.maxY - this.height - 10
}else{
	y = coords.posy + 10
}


helpObject = new getObj(object);
helpObject.style.left = x+'px';
helpObject.style.top = y+'px';
helpObject = this.zindex;

    if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'visible';
    else if (document.getElementById)

        document.getElementById(object).style.visibility = 'visible';
        else if (parseInt(navigator.appVersion)>=5 && navigator.appName=="Netscape")
                document.getElementById(object).style.visibility = 'visible';
                this.hideForms();
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
function getCoords(e)
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		this.posx = e.pageX;
		this.posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		this.posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
		this.posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
}
function getScreenDim()
{
	var maxX,maxY;
	if (self.innerHeight) // all except Explorer
	{
	    this.maxX = self.innerWidth;
	    this.maxY = self.innerHeight;

	}
	else if (document.documentElement && document.documentElement.clientHeight)
	    // Explorer 6 Strict Mode
	{
	    this.maxX = document.documentElement.clientWidth;
	    this.maxY = document.documentElement.clientHeight;

	}
	else if (document.body) // other Explorers
	{
	    this.maxX = document.body.clientWidth;
	    this.maxY = document.body.clientHeight;

	}
}


function hideHelp(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all){
        document.all[object].style.visibility = 'hidden';
        }
        else if (parseInt(navigator.appVersion)>=5 && navigator.appName=="Netscape")
        {
                document.getElementById(object).style.visibility='hidden'
        }
}

function AddHelp()
{
        argc = arguments.length;
        argv = arguments;
        if (argc == 1)
        {
                if (this.layerList.IsInArray(argv[0]))
                {
                        alert('Item of this name already exists')
                }
                else
                {
                        this.layerList[this.layerList.length] = argv[0];
                }
        }
        if (argc == 2)
        {
                if (argv[1] == 'form')
                {
                        if (this.formList.IsInArray(argv[0]))
                        {
                                alert('Form of this name already exists')
                        }
                        else
                        {
                                this.formList[this.formList.length] = argv[0];
                        }
                }
        }
}
function DelHelp (Item)
{
        argc = arguments.length;
        argv = arguments;
        if (argc == 1)
        {
                if (!this.layerList.IsInArray(argv[0]))
                {
                        alert('Help item '+Item+' does not exist');
                        return(false)
                }
                else
                {
                        this.layerList.splice(this.layerList.arraySeek(argv[0]),1)
                }
        }
        if (argc == 2)
        {
                if(argv[1]=='form')
                {
                        if (!this.formList.IsInArray(argv[0]))
                        {
                                alert('Help item '+Item+' does not exist');
                                return(false)
                        }
                        else
                        {
                                this.formList.splice(this.formList.arraySeek(argv[0]),1)
                        }
                }
        }

}

{}
function hideAll()
{
        for (c=0;c<this.layerList.length;c++)
        {
                hideHelp(this.layerList[c])
        }
        this.showForms();
}

function hideForms()
{
        for (c=0;c<this.formList.length;c++)
        {
                hideHelp(this.formList[c])
        }
}
function showForms()
{
        for (c=0;c<this.formList.length;c++)
        {
                showObject(this.formList[c])
        }
}
function showObject(object)
{
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'visible';
    else if (document.all){
        document.all[object].style.visibility = 'visible';
        }
        else if (parseInt(navigator.appVersion)>=5 && navigator.appName=="Netscape")
        {
                document.getElementById(object).style.visibility='visible'
        }
}

function IsInArray(Item)
{
        var isIn = false;
        for (c=0;c<this.length;c++)
        {
                if (this[c] == Item)
                {
                        isIn = true;
                        break;
                }
        }
        return(isIn);
}
function arraySeek(Item)
{
        var index = -1;
        for (c=0;c<this.length;c++)
        {
                if (this[c] == Item)
                {
                        index = c;
                        break;
                }
        }
        return(index);
}
}
function noRtClick(e,msg)
{
        if (e.button == 2)
        {
                alert(msg);
        }
}
