function fx_graftal_init( time, extraArguments )
{
	document.fx_graftal_graftalCount	= 15
	var
		graftalsHandle	= document.createElement( 'DIV' ),
		bla				= ""

	graftalsHandle.id = "graftal"
	graftalsHandle.style.display = "none"
	for( var graftalIndex=0; graftalIndex<document.fx_graftal_graftalCount; graftalIndex++ )
		bla += '<div id="graftal'+ graftalIndex +'"><img /></div>'
	graftalsHandle.innerHTML = bla
	additionalNodesHandle.appendChild( graftalsHandle )

	document.fx_graftal_graftalHandleArray = []
	for( graftalIndex=0; graftalIndex<document.fx_graftal_graftalCount; graftalIndex++ )
		document.fx_graftal_graftalHandleArray[ graftalIndex ] = document.getElementById('graftal'+graftalIndex)



	progressBarIndex++
}


function fx_graftal_update( time, extraArguments )
{
	var
		graftalCount			= document.fx_graftal_graftalCount,
		graftalHandleArray		= document.fx_graftal_graftalHandleArray,
		an = time/1024,
		renderAreaHandleOffsetWidth	= renderAreaHandle.offsetWidth,
		renderAreaScaling			= renderAreaHandleOffsetWidth/384,
		graftalInfos				= [],
		spreadRatio					= 3+1.5*Math.cos( time/1304 ),
		graftalOverAnythingRatio	= .5+.5*Math.cos( time/924 ),
		graftalAngleFreedom			= Math.PI/12*(2+Math.cos( time/384))

	document.getElementById('graftal').style.display = ""
	for( graftalIndex=0; graftalIndex<graftalCount; graftalIndex++ )
	{
		var
			X = ((graftalIndex*987^133)&127)-63,
			Y = ((graftalIndex*523^727)&127)-63,
			side = ((graftalIndex*76^647)&31)*2+32,
			angle = an+graftalIndex,
			c =Math.cos( angle )*spreadRatio,
			s =Math.sin( angle )*spreadRatio,
			x = renderAreaHandleOffsetWidth/2+X*c+Y*s,
			y = renderAreaHandleOffsetWidth/3+X*s-Y*c

			if( graftalIndex )
			{
				graftalParentIndex = (graftalIndex-1)>>1
				gangle	= graftalInfos[ graftalParentIndex ][ 3 ]+(1-2*(graftalIndex&1))*graftalAngleFreedom
				gside	= graftalInfos[ graftalParentIndex ][ 2 ]*.7
				gx		= graftalInfos[ graftalParentIndex ][ 0 ]+gside*Math.cos( gangle )*.97
				gy		= graftalInfos[ graftalParentIndex ][ 1 ]+gside*Math.sin( gangle )*.97
			}
			else
			{
				gangle	= -Math.PI/3-graftalAngleFreedom*2
				gside	= renderAreaHandleOffsetWidth/6
				gx		= (renderAreaHandleOffsetWidth/2)*(1+.25*Math.cos(time/486))
				gy		=	(renderAreaHandleOffsetWidth/2)*(1+.25*Math.sin(time/589))
			}

			graftalInfos[ graftalIndex ] = [ gx,gy,gside,gangle ]

		x		+= (gx-x)*graftalOverAnythingRatio
		y 		+= (gy-y)*graftalOverAnythingRatio
		side	+= (gside-side)*graftalOverAnythingRatio
		angle	+= (gangle-angle)*graftalOverAnythingRatio

		//* 	// update sample code
		var g = graftalHandleArray[ graftalIndex ];
		if( !g.firstChild.src || g.firstChild.src=="" )
			g.firstChild.src = imagesPreloaded['squares.gif'].src

		var s = g.style;
        s.left	= Math.round( (x-side/2)*renderAreaScaling ) +"px"
        s.top	= Math.round( (y-side/2)*renderAreaScaling ) +"px"
		s.width	= s.height	= Math.round( side*renderAreaScaling ) +"px"
        g.firstChild.style.top	= -((-angle/Math.PI*32)&15)+"00%;"
		//*/

	}
}


function fx_graftal_destroy()
{
	document.getElementById('graftal').style.display = "none"
}

