﻿// JavaScript Document
  var Obr1 = new Image();
  Obr1.src = "http://www.centrum-bagry.com/1.gif";
  var Obr2 = new Image();
  Obr2.src = "http://www.centrum-bagry.com/2.gif";
  var Obr3 = new Image();
  Obr3.src = "http://www.centrum-bagry.com/3.gif";
  function truebd(){
	if (
		document.compatMode
		&& document.compatMode!="BackCompat"
		&& (!window.opera)
	)
	{
		return document.documentElement;
	}
	else
	{
		return document.body;
	}
}
  function mouse(e){

	var xcoord= 20
	var ycoord= 20

	if (typeof e != "undefined"){
			xcoord += e.pageX;
			ycoord += e.pageY;
	}
	else if (typeof window.event !="undefined"){
			xcoord += truebd().scrollLeft+event.clientX
			ycoord += truebd().scrollTop + event.clientY;
	}
	document.getElementById("mouse").style.left=xcoord+"px";
	document.getElementById("mouse").style.top=ycoord+"px";
}
function visibility(x)
{
for(a=1;a<4;a++)
{
if(a == x)
document.getElementById("aa"+a).style.visibility = "visible";
else
document.getElementById("aa"+a).style.visibility = "hidden";
}
}
function processAnim()
{
var xPoint = new Number(document.getElementById("mouse").style.top.replace(/px/g,''));
var yPoint = new Number(document.getElementById("mouse").style.left.replace(/px/g,''));
var xBagr = new Number(document.getElementById("bagr").style.top.replace(/px/g,''));
var yBagr = new Number(document.getElementById("bagr").style.left.replace(/px/g,''));
if (Math.abs(xPoint - xBagr) == 0 && Math.abs(yPoint - yBagr) == 0)
visibility(1);
else if (Math.abs(xPoint - xBagr) > 30 || Math.abs(yPoint - yBagr) > 30)
visibility(3);
else
visibility(2);
if (Math.abs(xPoint - xBagr) > 8 )
xPoint = xBagr + (xPoint - xBagr)/8
else if (Math.abs(xPoint - xBagr) > 4 )
xPoint = xBagr + (xPoint - xBagr)/4
if (Math.abs(yPoint - yBagr) > 8)
yPoint = yBagr + (yPoint - yBagr)/8
else if (Math.abs(yPoint - yBagr) > 4)
yPoint = yBagr + (yPoint - yBagr)/4
document.getElementById("bagr").style.left = yPoint+'px';
document.getElementById("bagr").style.top = xPoint+'px';
}

function init()
{
document.onmousemove=mouse;
setInterval("processAnim();",5);
}

