// (c) 2007 KystAtlas AS (Hans Martin Mohn)

gtToolPan.prototype=new gtTool();gtToolPan.prototype.constructor=gtTool;gtToolPan.superclass=gtTool.prototype;var g_click_limit=5;function gtToolPan()
{this.m_map=null;this.m_start_x=0;this.m_start_y=0;this.m_button_down=false;}
gtToolPan.prototype.select=function(map)
{this.m_map=map;this.m_map.setCursor("move");};gtToolPan.prototype.buttonDown=function(evt)
{this.m_button_down=true;this.m_start_x=evt.gtX;this.m_start_y=evt.gtY;gtPreventDefault(evt);};gtToolPan.prototype.mouseMove=function(evt)
{if(this.m_button_down)
{var dx=evt.gtX-this.m_start_x;var dy=evt.gtY-this.m_start_y;gtSetLeft(this.m_map.m_img,dx);gtSetTop(this.m_map.m_img,dy);}
gtCancelBubble(evt);return gtPreventDefault(evt);};gtToolPan.prototype.buttonUp=function(evt)
{if(!this.m_button_down)
return;this.m_button_down=false;var dx=evt.gtX-this.m_start_x;var dy=evt.gtY-this.m_start_y;if(Math.abs(dx)>g_click_limit||Math.abs(dy)>g_click_limit)
{this.m_map.m_url.setParam("map.x",this.m_map.m_img.width/2-dx);this.m_map.m_url.setParam("map.y",this.m_map.m_img.height/2-dy);}
else
{this.m_map.m_url.setParam("map.x",evt.gtX);this.m_map.m_url.setParam("map.y",evt.gtY);}
this.m_map.m_url.setParam("cmd","center");this.m_map.showMap(this.m_map.m_url);gtCancelBubble(evt);return gtPreventDefault(evt);};this.canHandleSelection=function(selection){return true;}