// JavaScript Document


function zoom(factor) {
	var diffWidth=mapWidth;
	mapWidth=Math.floor(mapWidth*factor);
	diffWidth-=mapWidth;
	var diffHeight=mapHeight;
	mapHeight=Math.floor(mapHeight*factor);
	diffHeight-=mapHeight;
	var emap=document.getElementById('earthMap');
	emap.style.width=mapWidth+'px';
	emap.style.height=mapHeight+'px';
	var img=document.getElementById('mover');
	img.style.top=(img.offsetTop+Math.floor(diffHeight/2))+'px'
	img.style.left=(img.offsetLeft+Math.floor(diffWidth/2))+'px'

	for (i in Airports) {
		var airp=Airports[i];
		if (airp && airp.domNode) {
			airp.domNode.style.left=lonToScale(airp.lon,offsetSizes[airp.domNode.className])+'px';
			airp.domNode.style.top=latToScale(airp.lat,offsetSizes[airp.domNode.className])+'px';
		}
	}

}

function zoomOut() {
	zoom(1/1.2);
}

function zoomIn() {
	zoom(1.2);
}







function HTTP() {
 var xmlhttp
 /*@if (@_jscript_version >= 5)
   try {
   xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
  } catch (e) {
   try {
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
   } catch (E) {
    xmlhttp=false
   }
  }
 @else
  xmlhttp=false
 @end @*/
 if (!xmlhttp) {
  try {
   xmlhttp = new XMLHttpRequest();
  } catch (e) {
		xmlhttp=false;
  }
 }
 return xmlhttp;
}
try {
	if (new HTTP()) {
		document.getElementById('scriptWarning').style.display="none";
	}
} catch (E) {}

function getDragParent(el) {
	var oldEl=el;
	while (el) {
		el=el.parentNode;
		if (el.id == "zoomContainer" || el.nodeName.toUpperCase() == 'BODY') {
			return oldEl;
		}
		oldEl=el;
	}
}

var offsetX,offsetY,draggingThing;
function startDrag(e) {
    draggingThing = getDragParent(e.srcElement || e.target);
   
    offsetX=e.clientX-draggingThing.offsetLeft;
	offsetY=e.clientY-draggingThing.offsetTop;
	document.body.onmousemove=moveDrag;
	document.body.onmouseup=endDrag;
	document.onselectstart=nullFunc;
}

function nullFunc(e) {
	return false;
}
function moveDrag(e) {
	e=e || event;
	if (draggingThing) {
		draggingThing.style.top=(e.clientY-offsetY)+'px';
		draggingThing.style.left = (e.clientX - offsetX) + 'px';
		
		return true;
	}
}
function endDrag(e) {
	draggingThing=null;
	document.body.onmousemove=null;
	document.body.onmouseend=null;
	document.onselectstart = null;
	//var tops = document.getElementById('mover').offsetTop; 
	
	//alert(tops);
	
	
}



