// JavaScript Document
var appear = 1.0; //5.0;
var delay = 2.0; //1.0;
var fade = 1.0; //5.0;
var renewtime = 1500; //700;

var factor = 6;		// pixel size

var hoehe = -1;
var breite = -1;

var divPrefix = "area";
var bmain = null;
var div0 =null;
var div1 = null;
var div2 = null;

var anzPixel = 11;

var imgPath = "fileadmin/images";
var imgPrefix = "p_";
var imgSuffix = "gif";

var pix_count =0;

function start()
{
	return 0;
	setHeightWidth();						// set possible Height and Width
	
	div0 = createArea("0", 256, 95);
	div1 = createArea("1", breite - 888, hoehe);
	div2 = createArea("2", 256, hoehe - 360);
	
	run();
}

function run()	{
	var whichDiv = Math.floor(Math.random()*(9))+1;
	whichDiv = (whichDiv == 5)	?	0	:	((whichDiv % 3) == 0)	?	2	:	1;
	var pixel=insertPixel(++pix_count, eval(divPrefix+whichDiv));
	Effect.Appear(pixel, { duration: appear, queue: { scope:pixel.id, position:'end' } });
	Effect.Fade(pixel, { delay: delay, duration: fade,queue: { scope:pixel.id, position:'end' }, afterFinish: function(effect)	{	effect.element.remove();}  });
	
	var aktiv = window.setTimeout("run()", renewtime);
}

function insertPixel (nr, area)	{
	area.insert('<div id="pixel_' + nr + '" style="display:none;position:absolute;left:'+ Math.floor(Math.random()*area.raster.x)*factor +'px;top:' + Math.floor(Math.random()*(area.raster.y))*factor + 'px;width:' + factor + 'px;height:' + factor + 'px;">	\
				<div><img src="' + imgPath + '/p_' + ((Math.floor(Math.random()*(anzPixel-1)))+1) + '.' + imgSuffix + '" border="0"></div></div>');				 
	return $("pixel_"+nr);
}

function setHeightWidth()
{	
	bmain = $("bmain");
	hoehe = bmain.offsetHeight - 18;
	breite = bmain.offsetWidth - 18;
}

function createArea(o, w, h)	{
	var div = $(divPrefix + o);
	div.width 		= w;
	div.height		= h;
	div.raster = new Object();
	div.raster.x = (div.width-(div.width % factor)) / factor;
	div.raster.y = (div.height-(div.height % factor)) / factor;	
	
	return div;
}
