var spotxclear = new Array();var spotyclear = new Array();spotxclear.push("-5150");spotyclear.push("2800");var width = 300;var height = 200;var bpx = -1225.25494585;var bpy = -116.975748947;
var move = 0;
var StartxPos;
var StartyPos;
var xPos;
var yPos;

var spotx = new Array();
var spoty = new Array();


spotx.push("1325.25494585");spoty.push("216.975748947");
function outputposofdot(){
document.getElementById("statusfield").value= " selected dot:  x " + spotxclear[0] + " / y: " + spotyclear[0];
}

function markall(){
	for (i = 0; typeof(spotx[i]) != 'undefined'; i++){
		if(spotx[i] < (width-bpx) && spotx[i] > (-bpx)){
			if(spoty[i] < (height-bpy) && spoty[i] > (-bpy)){
			document.getElementById("dot" + i).style.visibility='visible';
			document.getElementById("dot" + i).style.left=((parseInt(spotx[i]) + parseInt(bpx) + parseInt(10))-5) + "px";
			document.getElementById("dot" + i).style.top=((parseInt(spoty[i]) + parseInt(bpy) + parseInt(10))-5) + "px";
			} else {
			document.getElementById("dot" + i).style.visibility='hidden';
			}
		} else {
		document.getElementById("dot" + i).style.visibility='hidden';
		}
	}
}

function movex(x) {
bpx = bpx+x;
document.getElementById('map').style.backgroundPosition = bpx + "px " + bpy + "px";
}

function movey(y) {
bpy = bpy+y;
document.getElementById('map').style.backgroundPosition = bpx + "px " + bpy + "px";
}

function startmoving(evt) {
move = 1;
StartxPos=(evt.x || evt.layerX);
StartyPos=(evt.y || evt.layerY);
document.getElementById('map').style.borderColor = "red";
}

function mousemove(evt){
	if(move==1){
	xPos=(evt.x || evt.layerX);
	yPos=(evt.y || evt.layerY);
	
	movex(xPos-StartxPos);
	movey(yPos-StartyPos);
	/*document.getElementById('statusbar').firstChild. nodeValue = bpx + " / " + bpy + " ///// " + width + " / " + height  + " ///// " + (-bpx) + " / " + (-bpy) + " ///// " + (width-bpx) + " / " + (height-bpy);*/
	/*document.getElementById('statusbar').firstChild. nodeValue = (-bpx) + " / " + (-bpy) + " ///// " + (width-bpx) + " / " + (height-bpy) + " ///// " + (parseInt(spotx[0]) + parseInt(bpx) + parseInt(10));*/
	
	StartxPos = xPos;
	StartyPos = yPos;
	
	markall();
	}
	
	if(move2==1){
	xPos=(evt.x || evt.layerX);
	yPos=(evt.y || evt.layerY);
	
	curx = (((bpx+2183)*(-1))+(xPos-8))*5.9988457503
	cury = ((((bpy+684)*(-1))+(yPos-8))*5.991452991)*(-1)
	
	curx = Math.round(curx);
	cury = Math.round(cury);

	document.getElementById("statusfield").value= " mouseposition:  x " + curx + " / y: " + cury;

	}
}

function showcurxy(status){
	if(status==0){
	move2 = 0;
	}
	
	if(status==1){
	move2 = 1;
	}
	
	
}

function mouseup(){
move = 0;
document.getElementById('map').style.borderColor = "black";
}

function showxy(form){
var showx = form.x.value;
var showy = form.y.value;

spotxclear[0] = showx;
spotyclear[0] = showy;

showy = showy*(-1);
showx = showx*(1);

showx += 13100;
showy += 4100;

showx = (showx/5.9988457503);
showy = (showy/5.991452991);

spotx[0] = showx;
spoty[0] = showy;

bpx = (showx-(200/2))*(-1);bpy = (showy-(200/2))*(-1);



document.getElementById('map').style.backgroundPosition = bpx + "px " + bpy + "px";


markall();
}
