// Mouse coordinates
var xPos, yPos;
var sleft1, sleft2, sleft3, sleft4;

var top1 = 206;
var top2 = 473;
var s_height = 125;
var left1;// = 456;
var s_width = 143;
var scale_x = 0;

var scroller_is_running = false;
 
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

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
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  xPos = tempX
  yPos = tempY
  //scale_x = document.getElementById("center_gallery_up").offsetLeft;
  
	if(IE){
		scale_x = document.getElementById('page').offsetLeft +310;
		//alert(document.getElementById('page').offsetLeft + ' ' +scale_x);
	}

  
  if(document.getElementById('gallery_thumb_pics_1')){
	left1 = document.getElementById('gallery_thumb_pics_1').offsetLeft;
  }
  sleft1 = left1 + scale_x;
  
  // scrolling up
  if( xPos > sleft1 && yPos > top1 && xPos < sleft1+s_width && yPos < top1+s_height ){
	  scrolling("top");
	  scroller_is_running = true;
  }
  // scrolling down
  if( xPos > sleft1 && yPos > top2 && xPos < sleft1+s_width && yPos < top2+s_height ){
	  scrolling("bottom");
	  scroller_is_running = true;
  }
  
  if(
		  (xPos > sleft1+s_width) || // jobbra
		  (xPos < sleft1) || // balra
		  (yPos < top2 && yPos > top1+s_height) || // második fölött és első alatt
		  (yPos < top1) || // első fölött
		  (yPos > top2+s_height) //második alatt
	)
	{
		stopinterval();
	}
  
  return true
}
