function findPos(el)
{
	var xPos=0;
	var yPos=0;
	
	if(document.layers)
	{
		xPos=el.x;
		yPos=el.y;
	}
	else
	{
		while(el)
		{
			xPos+=el.offsetLeft;
			yPos+=el.offsetTop;
			el=el.offsetParent;
		}
	}
	return {xPos: xPos, yPos: yPos};
}

function echo()
{
	fieldY=100;
	
	x=(xpos-findPos(document.getElementById('img')).xPos);
	y=(ypos-findPos(document.getElementById('img')).yPos);			
	
	if(navigator.appName=='Microsoft Internet Explorer')
	{
		y-=2;
		x-=2;
	}
	
	xcol=x*5;
	
	diff=xcol%255;
	
	if(xcol<255)
	{
		r=255;
		g=diff;
		b=0;
	}
	else if(xcol<255*2)
	{
		r=255-diff;
		g=255;
		b=0;
	}
	else if(xcol<255*3)
	{
		r=0;
		g=255;
		b=diff;
	}
	else if(xcol<255*4)
	{
		r=0;
		g=255-diff;
		b=255;
	}
	else if(xcol<255*5)
	{
		r=diff;
		g=0;
		b=255;
	}
	else if(xcol<255*6)
	{
		r=255;
		g=0;
		b=255-diff;
	}
	
	if(y<(fieldY/2))
	{
		r=Math.round(r+(255-r)/(fieldY/2)*(fieldY/2-y));
		g=Math.round(g+(255-g)/(fieldY/2)*(fieldY/2-y));
		b=Math.round(b+(255-b)/(fieldY/2)*(fieldY/2-y));
	}
	else
	{
		r=Math.round(r+(-r)/(fieldY/2)*(y-fieldY/2));
		g=Math.round(g+(-g)/(fieldY/2)*(y-fieldY/2));
		b=Math.round(b+(-b)/(fieldY/2)*(y-fieldY/2));
	}
	
	if(r>255) r=255;
	if(g>255) g=255;
	if(b>255) b=255;
	
	if(r<0) r=0;
	if(g<0) g=0;
	if(b<0) b=0;
	
	document.getElementById('colorPreview').style.backgroundColor="rgb("+r+", "+g+", "+b+")";
	
	if(document.form['colorNr'][0].checked) colorField=1;
	else colorField=2;
	
	if(document.form['colorNr'][0].checked)
	{
		document.form.text_r1.value=r;
		document.form.text_g1.value=g;
		document.form.text_b1.value=b;
	}
	else
	{
		document.form.text_r2.value=r;
		document.form.text_g2.value=g;
		document.form.text_b2.value=b;
	}
}