var scr1pt= "";
var scriptpos=0;
var len

function initDemo(s)
{	
	scr1pt = s;
	scriptpos = 0;
	doScript();

}
function doScript()
{
	if(scriptpos < scr1pt.length)
	{
		time = scr1pt[scriptpos][1];
		eval(scr1pt[scriptpos][0]);
		setTimeout("doScript()", time);
		scriptpos++;
	}
}

function loop()
{
	scriptpos=-1;
}

function fowardpage(x)
{
	document.location.href = x;
}

function fadeInNote(text, id, x,y)
{
	$(id).innerHTML = text;
	$(id).style.left = x;
	$(id).style.top = y;
	new Effect.Appear($(id));
}

function fadeInAnno(text, id, x,y)
{
	$(id).innerHTML = text  + '<img src="images/annoR.gif" style="position:absolute; top:58; left:70"/>';
	$(id).style.left = x;
	$(id).style.top = y;
//	new Effect.Appear($(id));
}


function fadeOut(id)
{
	new Effect.Fade($(id));
}

function fadeIn(id)
{
	new Effect.Appear($(id));
}


var x;
var y;

function setMouseImg(src)
{
	$("mouseimg").src = "images/" + src + ".gif";
}


function setMousePos(_x,_y)
{
	
	x = _x;
	y= _y;

	$("mouse").style.left = x;
	$("mouse").style.top = y;
}
function moveMouse(id, X,Y)
{
	if(id == '')
	{
		
	}
	else
	{
		X = X + getLeft($(id), 0);
		Y = Y + getTop($(id), 0);
	}

	dx = (X - x) / 10;
	dy = (Y - y) / 10;

	if(dx > 10) dx = 10;
	if(dy > 10) dy = 10;
	
	x += dx;
	y += dy;

	dx = (X - x);
	dy = (Y - y);

	$("mouse").style.left = x;
	$("mouse").style.top = y;

		if(dx*dx < 4 && dy*dy < 4)
		return;

	setTimeout( "moveMouse(''," + X + "," + Y + ")", 20);

}

function getTop(e, cum)
{
	
	if(e.offsetParent == null)
	{
		return cum + e.offsetTop;
	}

	cum += e.offsetTop;
	return getTop(e.offsetParent, cum);
}

function getLeft(e, cum)
{
	
	if(e.offsetParent == null)
	{
		return cum + e.offsetLeft;
	}

	cum += e.offsetLeft;
	return getLeft(e.offsetParent, cum);
}



function typeText(id, text)
{
	$(id).value += text.charAt(0);
	
	text = text.substring(1, text.length);

	if(text.length > 0)
		setTimeout('typeText("' + id + '","' + text + '")', 100);
}

