// Function to load the selected section/township after use of location map buttons
function loadSectionSVG () {
    if (section < 10)  {
	var targetId = township + "-" + range + "-0" + section;}
    else  {
	var targetId = township + "-" + range + "-" + section;}

	/* window.alert(targetId); */
	goto_Ref (targetId.toString());
	showData ('Called from loadSectionSVG');
}

function expand () {

	section_lcid = null;
	lastPropertyID = null;

	if (expLevel == 1)
	  {
	    /* Set expLevel 0 - County Map in Main Window */
	    expLevel = 0;
	    svgMapSrc = "./MCPHERSON_CO.svgz";
		locMapSrc = svgMapSrc;
	    loadSVGMap (svgMapSrc);
		loadLocMap ();
		var svgdoc = document.LOCMAP.getSVGDocument();
		if (hilite_id != null) hideSVG (svgdoc, hilite_id, false);
		tshp_lcid = null;
		hilite_id = null;
	  }
	if (expLevel == 2)
	  {
		/* Set expLevel 1 - Township Map in Main Window */
		expLevel = 1;
		svgMapSrc = baseURL + 'T' + township + 'S_R' + range + 'W/T' + township + 'S_R' + range + 'W.svgz';
		lastClickedID = null;
		var mapId = svgMapSrc.toString();
		loadSVGMap(mapId);
		locMapSrc = "./MCPHERSON_CO.svgz"
		loadLocMap ();
		hilite_id = 'T' + township + 'S_R' + range + 'W';
	  }
	showData ('Called from expand');
}

function township_up () {
	township = township - 1;
	if (township < 17) {township = 17;return false;}
	return true;
}

function township_dn () {
	township = township + 1;
	if (township > 21) {township = 21;return false;}
	return true;
}

function range_lt () {
	range = range + 1;
	if (range > 5) {range = 5;return false;}
	return true;
}

function range_rt () {
	range = range - 1;
	if (range < 1) {
		range = 1;
		return false;
		}
	return true;
}

function move_lt () {
if (expLevel == 2) {
  if (section< 7) {
    section= section+ 1;
    if (section> 6) {
	  if (range_lt()) {section= 1};
	  }
    }
  else if (section< 13) {
    section= section- 1;
    if (section< 7) {
	  if (range_lt()) {section= 12};
	  }
    }
  else if (section< 19) {
    section= section+ 1;
    if (section> 18) {
	  if (range_lt()) {section= 13};
	  }
    }
  else if (section< 25) {
    section= section- 1;
    if (section< 19) {
	  if (range_lt()) {section= 24};
	  }
    }
  else if (section< 31) {
    section= section+ 1;
    if (section> 30) {
	  if (range_lt()) {section= 25};
	  }
    }
  else if (section< 37) {
    section= section- 1;
    if (section< 31) {
	  if (range_lt()) {section= 36};
	  }
    }
  loadSectionSVG();
} /* expLevel == 2 */

}

function move_rt () {
if (expLevel == 2) {
	if ((section> 0) && (section< 7)) {
	section= section- 1;
	if (section< 1) {
			if (range_rt()) {section= 6};
			}
	}
	if ((section> 6) && (section< 13)) {
	section= section+ 1;
	if (section> 12) {
			if (range_rt()) {section= 7};
			}
	}
	if ((section> 12) && (section< 19)) {
	section= section- 1;
		if (section< 13) {
			if (range_rt()) {section= 18};
			}
		}
	if ((section> 18) && (section< 25)) {
	section= section+ 1;
		if (section> 24) {
			if (range_rt()) {section= 19};
			}
		}
	if ((section> 24) && (section< 31)) {
	section= section- 1;
		if (section< 25) {
			if (range_rt()) {section= 30};
			}
		}
	if ((section> 30) && (section< 37)) {
	section= section+ 1;
		if (section> 36) {
			if (range_rt()) {section= 31};
			}
		}
	loadSectionSVG();
	} /* expLevel == 2 */
}

// Navigation Functions to move to the next section or township UP
function move_up () {
if (expLevel == 2) {
	if (section< 7) {
		if (township_up()) {section= 37 - section;}
	}
	else if (section< 13) {section= 13 - section;}
	else if (section< 19) {section= 25 - section;}
	else if (section< 25) {section= 37 - section;}
	else if (section< 31) {section= 49 - section;}
	else if (section< 37) {section= 61 - section;}
	loadSectionSVG();
	} /* expLevel == 1 */
}

// Navigation Functions to move to the next section or township down
function move_dn () {
if (expLevel == 2) {
	if (section< 7) {section= 13 - section};
	else if (section< 13) {section= 25 - section;}
	else if (section< 19) {section= 37 - section;}
	else if (section< 25) {section= 49 - section;}
	else if (section< 31) {section= 61 - section;}
	else if (section< 37) {
		if (township_dn()) {section= 37 - section;}
		}
	loadSectionSVG();
	} /* expLevel == 2 */
}