	var dragging=false;
	var x=0,y=0,dx=450,dy=425;
	var win=this;

	function startDrag() {
		dragging=true;
		x=event.clientX;
		y=event.clientY;
	}
	function stopDrag() {
		dragging=false;
	}
	function movePix() {
		win.scrollBy(x-event.clientX,y-event.clientY);
//		top.status=count+":"+win.document.body.scrollLeft+","+win.document.body.scrollTop;
		x=event.clientX;
		y=event.clientY;
	}
	var count = 0;
	var mapImg=new Array;
	mapImg[0]=new Image;
	mapImg[0].src="images/map.tour3.jpg";
	mapImg[1]=new Image;
	mapImg[1].src="images/map.tour.jpg";
	mapImg[2]=new Image;
	mapImg[2].src="images/map.tour2.jpg";
	mapImg[3]=new Image;
	mapImg[3].src="images/map.large.jpg";

	function wheel() {
		count = wheelCounting(count);
		wheelResize(count);
		return false;
	}
	function wheelCounting(count) {
		if (event.wheelDelta >= 120)
			count=zoomIn();
		else if (event.wheelDelta <= -120)
			count=zoomOut();
		return count;
	}
	var pixScreenWidth=0,pixScreenHeight=0;
	function wheelResize(count){
		pix.src=mapImg[count].src;
//		pixScreenWidth=parseInt(mapImg[count].offsetWidth);
//		pixScreenHeight=parseInt(mapImg[count].offsetHeight);
		pixScreenWidth=pix.offsetWidth;
		pixScreenHeight=pix.offsetHeight;
		destResize(count);
//		win.scrollTo((pixScreenWidth-win.document.body.clientWidth)/2,(pixScreenHeight-win.document.body.clientHeight)/2);
		destFocusNow();
	}
	function initWheel() {
		pixScreenWidth=pix.offsetWidth;
		pixScreenHeight=pix.offsetHeight;
		wheelResize(count);
	}

	function zoomAuto() {
		if (event.button==1)
			zoomIn();
		else if (event.button==2)
			zoomOut();
		return false;
	}

	function zoomIn() {
		count++;
		if (count>=mapImg.length) count=mapImg.length-1;
		wheelResize(count);
		return count;
	}

	function zoomOut() {
		count--;
		if (count<0) count=0;
		wheelResize(count);
		return count;
	}

	function zoomTo(s,t,l) {
		count=s;
		if (count<0) count=0;
		if (count>=mapImg.length) count=mapImg.length-1;
		pix.src=mapImg[count].src;
//		pixScreenWidth=parseInt(mapImg[count].offsetWidth);
//		pixScreenHeight=parseInt(mapImg[count].offsetHeight);
		pixScreenWidth=pix.offsetWidth;
		pixScreenHeight=pix.offsetHeight;
		destResize(count);
		win.scrollTo(t,l);
	}

	function zoomReset(c) {
		wheelResize(c);
	}

	function destResize(c) {
		if (!dest || !win.dest) return;
		pixScreenWidth=pix.offsetWidth;
		pixScreenHeight=pix.offsetHeight;
		w=pixScreenWidth*0.125;
		if (w<32) w=32;
//		w=125/(4-c);
		dest.style.width=w;
		dest.style.height=w;
		l=dx*((pixScreenWidth*1.0)/1000.0);
		t=dy*((pixScreenHeight*1.0)/1000.0);
		mw=parseInt(pix.offsetWidth);
		mh=parseInt(pix.offsetHeight);

		if (l+w>mw) l=mw-w;
		if (t+w>mh) t=mh-w;
		
		dest.style.left=l;
		dest.style.top=t;
	}

	var dfc=0;

	function destFocus() {
		var dt=parseInt(dest.style.top);
		var dl=parseInt(dest.style.left);
		var dw=parseInt(dest.style.width);
		var dh=parseInt(dest.style.height);
		var dx=dt+dh/2;
		var dy=dl+dw/2;
		var st=parseInt(document.body.scrollTop);
		var sl=parseInt(document.body.scrollLeft);
		var sw=parseInt(document.body.scrollWidth);
		var sh=parseInt(document.body.scrollHeight);
		var bw=parseInt(document.body.offsetWidth);
		var bh=parseInt(document.body.offsetHeight);
		var cw=parseInt(document.body.clientWidth);
		var ch=parseInt(document.body.clientHeight);
		var mw=parseInt(pix.offsetWidth);
		var mh=parseInt(pix.offsetHeight);
//		var cx=st;
//		var cy=sl;
		var ft=st;
		var fl=sl;

		if (dt<st) ft=dt;
		if (dl<sl) fl=dl;
		if (dt+dh>st+bh) ft=st+bh-dh;
		if (dl+dw>sl+bw) fl=sl+bw-dw;
		if (ft<0) ft=0;
		if (fl<0) fl=0;
		if (ft>mh-ch) ft=mh-ch;
		if (fl>mw-cw) fl=mw-cw;
//		top.status="ft="+ft+",fl="+fl+",mh="+mh+",ch="+ch+",mw="+mw+",cw="+cw;
		win.scrollTo(fl,ft);
	}

	function destFocusNow() {
		for (i=1;i<20;i++) 
			setTimeout("destFocus()",100*i);
	}


	function destRelocate() {
		destResize(count);
		setTimeout("destRelocate()",100);
	}

	function setDest(nx,ny) {
		dx=nx;
		dy=ny;
		destResize(count);
	}

	var scrollByTimer=null;
	var scrollImageWeight=10;
	var scrollPadding=2;
	var scrollStep=5;
	var scrollSpeed=50;

	function itResized() {
		initPositions();
		initWheel();
		scrollByJust();
	}

	function initPositions() {
		l=parseInt(document.body.scrollLeft);
		t=parseInt(document.body.scrollTop);
		w=parseInt(document.body.clientWidth);
		h=parseInt(document.body.clientHeight);
		r=l+w;
		b=t+h;
		setPosition(getObj("corner1"),l,t);
		setPosition(getObj("corner2"),l+w-10,t);
		setPosition(getObj("corner3"),l,t+h-10);
		setPosition(getObj("corner4"),l+w-10,t+h-10);
		initArrows();
	}

	function initArrows() {
		l=parseInt(document.body.scrollLeft);
		t=parseInt(document.body.scrollTop);
		w=parseInt(document.body.clientWidth);
		h=parseInt(document.body.clientHeight);
		r=l+w;
		b=t+h;
		setPosition(getObj("arrowN"),l+w/2-(scrollImageWeight+scrollPadding),t+scrollPadding);
		setPosition(getObj("arrowE"),r-(scrollImageWeight+scrollPadding),t+h/2-(scrollImageWeight+scrollPadding));
		setPosition(getObj("arrowS"),l+w/2-(scrollImageWeight+scrollPadding),b-(scrollImageWeight+scrollPadding));
		setPosition(getObj("arrowW"),l+scrollPadding,t+h/2-(scrollImageWeight+scrollPadding));
	}

	function scrollByNow(t,l) {
		scrollByStop();
		scrollTimer=scrollByThis(l,t);
	}

	function scrollByThis(t,l) {
		scrollBy(t,l);
		scrollByJust();
		scrollByTimer=setTimeout("scrollByThis("+t+","+l+")",scrollSpeed);
	}

	function scrollByJust() {
		sl=parseInt(document.body.scrollLeft);
		st=parseInt(document.body.scrollTop);
		sw=parseInt(document.body.scrollWidth);
		sh=parseInt(document.body.scrollHeight);
		w=parseInt(document.body.clientWidth);
		h=parseInt(document.body.clientHeight);
		if (st<=0) setVisible(getObj("arrowN"),"hidden");
		else setVisible(getObj("arrowN"),"visible");
		if (sl+w>=sw) setVisible(getObj("arrowE"),"hidden");
		else setVisible(getObj("arrowE"),"visible");
		if (st+h>=sh) setVisible(getObj("arrowS"),"hidden");
		else setVisible(getObj("arrowS"),"visible");
		if (sl<=0) setVisible(getObj("arrowW"),"hidden");
		else setVisible(getObj("arrowW"),"visible");
	}

	function scrollByStop() {
		if (scrollByTimer) clearTimeout(scrollByTimer);
	}

	function getCenterLeft(w) {
		c=parseInt(document.body.clientWidth);
		x=(c-w)/2;
		if (x<0) x=0;
		return x;
	}

	function getCenterTop(h) {
		c=parseInt(document.body.clientHeight);
		y=(c-h)/2;
		if (y<0) y=0;
		return y;
	}