// JavaScript Document
var xxx = 0; var yyy = 0;
var dist = distX = distY = 0;
var stepx = 2;
var stepy = 2;
function distance(s,e) {return Math.abs(s-e)}
function direction(s,e) {return s>e?-1:1}
function rate(a,b) {return a<b?a/b:1}

function nextEnd() {
var eX = Math.floor(Math.random()* (pageWidth()-objWidth('slnecnica')));
if (pageHeight() != 0) {
	var eY = Math.floor(Math.random()* (pageHeight()-objHeight('slnecnica')));
}
else {
	var eY = Math.floor(Math.random()* (screen.height-150-objHeight('slnecnica')));
}
dist = distX = distance(xxx,eX);
distY = distance(yyy,eY);
stepx = 1 * direction(xxx,eX) * rate(distX,distY);
stepy = 1 * direction(yyy,eY) * rate(distY,distX); 
}

function start() {
var w = pageWidth();
xxx = (pageWidth()-w-20);
yyy = 10;
nextEnd();
moveit();
setObjVis('slnecnica','visible');
mover();
}
function moveit() {
var x = (posLeft()+xxx) + 'px';
var y = (posTop()+yyy) + 'px';
moveObjTo('slnecnica',x,y);
}
function mover() {
if (dist > 0) {
xxx += stepx;
yyy += stepy;
dist -= Math.abs(stepx);}
else {nextEnd();}
 moveit(); setTimeout('mover()',25);
}
window.onload = start;
window.onscroll = moveit;