var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;

function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}  
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}  

// limit size of variables (divide by two) & round to whole number
posX = (tempX / 2).toFixed(0);
posY = (tempY / 2).toFixed(0);
posZ = (Math.sqrt(posX) * Math.sqrt(posY)).toFixed(0); // get hypotenues for 3rd variable

// modify each variable for desired color range area
//posX = (posX).toFixed(0);
//posY = (posY / 2).toFixed(0);
//posZ = (posZ / 4).toFixed(0);
posY = (255 - posY).toFixed(0);
posZ = (255 - posZ).toFixed(0);

// limit range to actual RGB values
if (posX < 0) { posX = 0;}
if (posY < 0) { posY = 0;}
if (posZ < 0) { posZ = 0;}
if (posX > 255) { posX = 255;}
if (posY > 255) { posY = 255;}
if (posZ > 255) { posZ = 255;}

// output values to testing form
document.rgbpicker.rr_num.value = posX;
document.rgbpicker.gg_num.value = posY;
document.rgbpicker.bb_num.value = posZ;

// convert RGB values to HEX values
function RGBtoHex(posX,posY,posZ) 
{return toHex(posX)+toHex(posY)+toHex(posZ)}

function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}

// change background colour
bgcolours=getCookie('bgcolours');

elem = document.getElementById("bg");


if (bgcolours == 'yes' || bgcolours == '' || bgcolours == null)
{
//document.bgColor = '#' + RGBtoHex(posX,posY,posZ);
elem.style.background = '#' + RGBtoHex(posX,posY,posZ);
}

return true;

}