/*
Script by RoBorg
RoBorg@geniusbug.com
http://javascript.geniusbug.com
Please do not remove or edit this message
*/


hintArray = new Array();

myHint = new hint(false, '#FFFF99', 500);
myHint2 = new hint(true);


function hint(moveWithMouse, bgColour, delay)
{
	this.id = hintArray.length;
	hintArray[this.id] = this;
	this.CSS = '#hintDiv' + this.id + ' {position:absolute; border:1px #000000 solid; visibility:hidden;}';
	this.HTML = '<div id="hintDiv' + this.id + '"> </div>';
	this.div = new divObject('hintDiv' + this.id, 'document.');
	this.activate = new Function("this.div.activate(); this.div.setBgColour(this.backgroundColour);");
	this.show = hintShow;
	this.shown = false;
	this.backgroundColour = bgColour!=null?bgColour:'#FFFFE1';
	this.delay = delay!=null?delay:0;
	this.showTimer = false;
	this.setBackgroundColour = new Function("bgColour", "this.backgroundColour = bgColour; this.div.setBgColour(bgColour);");
	this.move = hintMove;
	this.moveTimer = setInterval('if(hintArray[' + this.id + '].moveWithMouse) hintArray[' + this.id + '].move();', 50);
	this.moveWithMouse = moveWithMouse;
	this.width = 0;
}


function hintShow(message)
{
	if(typeof(message) == 'undefined')
	{
		if(this.showTimer) clearTimeout(this.showTimer);
		this.showTimer = false;
		this.div.hide();
		this.shown = false;
		return;
	}

	this.div.write('<nobr>' + message + '</nobr>');
	this.move();

	if(browserVars.type.ns4) this.width = this.div.div.clip.width;
	else this.width = this.div.baseDiv.offsetWidth;

	this.showTimer = setTimeout('hintArray[' + this.id + '].div.show(); hintArray[' + this.id + '].shown = true;', this.delay);
}


function hintMove()
{
	browserVars.updateVars();
	var screenRight = browserVars.scrollLeft + browserVars.width - 18;
      if (browserVars.type.ie) screenRight = screenRight - 30;
	var screenBot = browserVars.scrollTop + browserVars.height;
	var x = browserVars.mouseX - 16; // by zsv 16 moz -38 ie6 ch from + 16 to move left
	var y = browserVars.mouseY + 16 - 40; // by zsv 16-18 moz  -40 ie6

	if((x + this.width) > screenRight)
	{
		x = screenRight - this.width;
		// y += 16;
	}

	if((y + this.height) > screenBot)
	{
		y = screenBot - this.height;
//		y += 16;
	}


	if(x < 0) x = 0;
	if(y < 0) y = 0;

	this.div.moveTo(x, y);
}


function writeHints()
{
	var CSS = '';
	var HTML = ''
	for(var x=0; x<hintArray.length; x++)
	{
		CSS += hintArray[x].CSS;
		HTML += hintArray[x].HTML;
	}
	return '<style>' + CSS + '</style>' + HTML;
}


function activateHints()
{
	for(var x=0; x<hintArray.length; x++)
		hintArray[x].activate();
}


