/**
 * CROWN COPYRIGHT
 * Glen Collins, OESR, Queensland Treasury, Australia
 * www.oesr.qld.gov.au
 * Do not remove this note.
**/

// changeImage(zoomin,over)

function changeImage(imgName,type) {
	if (top.mapPageLoaded == 0) {return;}
	//alert(top.mapPageLoaded);
	//alert(imgName);
	if(!INFO_BEAN) { return;}
	var imgNameOver = imgName + "_over.gif";
	var imgNameDown = imgName + "_down.gif";
	var IMAGES_ALIAS_ICONS = IMAGES_ALIAS + "icons/";
	document.mapcontrol.target = "_self";
	//Toggle off the image selected
	//alert(document.images[imgName].src.indexOf(imgNameDown));
	//alert(IMAGES_ALIAS_ICONS + imgName);
	//alert(type);


	if (type == "over") {
		if (document.images[imgName].src.indexOf(imgNameDown) != -1){
			return;
		} else {
			document.images[imgName].src = IMAGES_ALIAS_ICONS + imgNameOver;	
		}
	} else if (type == "out") {
		if (top.globalDowntoolname == imgName) {
			return;
		} else {
			document.images[imgName].src = IMAGES_ALIAS_ICONS + imgName + ".gif";
		}
	} else if (type == "unset") {
		if(document.images[imgName].src.indexOf(imgNameDown) != -1) {
			document.images[imgName].src = IMAGES_ALIAS_ICONS + imgName + ".gif";
			window.focus();
			DOWNTOOL = 0;
			top.globalDowntoolname	=	"none";
			if(INFO_BEAN) { INFO_BEAN.value="";	}
			return;
		} else {
			alert('Not true unset variable fail, contact Glen Collins at OESR 3405 5286');
		}
	} else if (type == "down") {
		//Turn off all of the images.
		if(document.zoomin) {
			document.zoomin.src = IMAGES_ALIAS_ICONS + "zoomin.gif";
		}
		if(document.zoomout) {
			document.zoomout.src = IMAGES_ALIAS_ICONS + "zoomout.gif";
		}
		if(document.recenter) {
			document.recenter.src = IMAGES_ALIAS_ICONS + "recenter.gif";
		}
		if(document.reset) {
			document.reset.src = IMAGES_ALIAS_ICONS + "reset.gif";
		}
		if(document.infoselectpointtool) {
			document.infoselectpointtool.src = IMAGES_ALIAS_ICONS + "infoselectpointtool.gif";
		}
		if(document.infoselectradiustool) {
			document.infoselectradiustool.src = IMAGES_ALIAS_ICONS + "infoselectradiustool.gif";
		}
		if(document.infoselectboxtool) {
			document.infoselectboxtool.src = IMAGES_ALIAS_ICONS + "infoselectboxtool.gif";
		}
		if (document.insetmaptool) {
			document.insetmaptool.src = IMAGES_ALIAS_ICONS + "insetmaptool.gif";
		}
		if (document.printpreview) {
			document.printpreview.src = IMAGES_ALIAS_ICONS + "printpreview.gif";
		}
		/***** ADD ADDITIONAL TOOLS HERE *****/
	
		//Turn on the image passed into this function
		document.images[imgName].src = IMAGES_ALIAS_ICONS + imgNameDown;
		top.globalDowntoolname = imgName;
		if(INFO_BEAN) { INFO_BEAN.value=imgName; }
		if (imgName == 'zoomin') {DOWNTOOL = 1}
		else if (imgName == 'zoomout') {DOWNTOOL = 2}
		else if (imgName == 'recenter') {DOWNTOOL = 3}
		else if (imgName == 'infoselectpointtool') {DOWNTOOL = 5}
		else if (imgName == 'infoselectradiustool') {DOWNTOOL = 6}
		else if (imgName == 'infoselectboxtool') {DOWNTOOL = 7}
		else if (imgName == 'insetmaptool') {DOWNTOOL = 8}
		else {DOWNTOOL = 0;}
		setRubberBandType(imgName);
		setWatch();
	} else {
		alert('Incorrect type passed, contact Glen Collins at OESR 3405 5286');
	}

}

