function setDebug(value)
{
	var Debug = document.getElementById('debug');
	if(Debug) Debug.innerHTML += ";"+value;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}	
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent){
		curtop += obj.offsetHeight;
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y){
		curtop += obj.y;
		curtop += obj.height;
	}
	return curtop;
}
function getPosition(myel)
{
	posLeft = findPosX(myel);
	posTop = findPosY(myel)
	position=new Object();
	position.x=posLeft;
	position.y=posTop;
	return position; 
}

var Size = 0;
var txt = '';
var int = 1;
var obj = null;
var BoxCounter = 0;

function initErrorBox(myObj,myError)
{
	Size = 0;
	txt = myError;
	obj = myObj;
	int = 1;
}

function SizeBox()
{
	if(int==1)
	{
		if(Size<txt.length)
		{
			Size+=int;
			setSize();
		}
	}
	else
	{
		if(Size>0)
		{
			Size+=int;
			setSize();
		}
		else
		{
			if(Size<1) obj.style.display='none';
			initErrorBox(null,'');
		}
	}
}

function setSize()
{
	obj.innerHTML = txt.substring(0,Size);
	obj.style.width = '150px';
	window.setTimeout("SizeBox()",1);
}

function ShowErrorBox(myErrorObj,error)
{
	var OldObj = document.getElementById('ErrorBox'+BoxCounter);
	if(OldObj)	document.body.removeChild(OldObj);
	BoxCounter++;
	var myErrorBox = document.createElement('div');
	myErrorBox.setAttribute('id','ErrorBox'+BoxCounter);
	myErrorBox.className='myErrorBox';
	document.body.appendChild(myErrorBox);

	
	var isie = navigator.userAgent.search(/MSIE/);
	var isff = navigator.userAgent.search(/Firefox/);
	var ismz = navigator.userAgent.search(/Mozilla/);
	var isop = navigator.userAgent.search(/Opera/);
	var issf = navigator.userAgent.search(/Safire/);

	ParentObject = getPosition(myErrorObj);

	if(myErrorBox)
	{
		//myErrorBox.style.backgroundColor = '#FFFFFF';
		myErrorBox.style.position = 'absolute';
		myErrorBox.style.left =  ParentObject.x+20+"px";
		myErrorBox.style.top = ParentObject.y-15+"px";
		myErrorBox.style.display='';
		myErrorBox.style.visibility='visible';
		initErrorBox(myErrorBox,error);
		SizeBox();
	}
	
}
function FadeOutErrorBox()
{
	int=-2;
	SizeBox();
}
