
//Called to launch coordinate getter in popup
function getCoordsFromMap(urlBase) {
//Open map as popup
 newWindow = window.open('IAGT/CoordinateAcquisitionTool/coordinateGetter.html','name','height=600,width=532,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
 newWindow.focus();
 //return false;
}

function setValues(elements, val) {
	var i = 0;
	for ( i=0; i < elements.length; i++ ) {
		elements[i].value = val;
	}
}

function limitPrecision(value) {
	var startIdx = value.indexOf( '.' );
	var endIdx = startIdx + 5;
	if ( endIdx > value.length ) {
		return value;
	}
	return value.substring(0,endIdx);
}

function enterCoords(north,south,east,west) {
		norths = document.getElementsByName("maxLat");
		setValues( norths, limitPrecision(north) );
        souths = document.getElementsByName("minLat");
		setValues( souths, limitPrecision(south) );
        easts = document.getElementsByName("maxLon");
        setValues( easts, limitPrecision(east) );
        wests = document.getElementsByName("minLon");
        setValues( wests, limitPrecision(west) );
}

function resetLatLon() {
		norths = document.getElementsByName("maxLat");
		setValues( norths, "" );
        souths = document.getElementsByName("minLat");
		setValues( souths, "" );
        easts = document.getElementsByName("maxLon");
        setValues( easts, "" );
        wests = document.getElementsByName("minLon");
        setValues( wests, "" );
}
