function toggleCaseStudies() {

	if (document.getElementById("moreCaseStudies").style.display == "") {
		
		document.getElementById("moreCaseStudies").style.display = "none";
		
	} else {
		
		document.getElementById("moreCaseStudies").style.display = "";
		
	}

}

function toggleMap(address) {

	isVisible = document.getElementById("caseStudyMap").style.display;
	
	if (isVisible == "none") {
		
		document.getElementById("caseStudyMap").style.display = "";
		document.getElementById("mapLink").innerHTML = "Hide map";

		if (GBrowserIsCompatible()) {
			
			var map = new GMap2(document.getElementById("caseStudyMap"));
			var geocoder = new GClientGeocoder();
			
			geocoder.getLatLng(
				address,
				function(point) {
					if (!point) {
						alert("Location not found...");
					} else {
			
						map.setCenter(point, 6);
						map.setUIToDefault();
						map.setMapType(G_PHYSICAL_MAP);
						map.removeMapType(G_NORMAL_MAP);
					//	map.removeMapType(G_SATELLITE_MAP);
						map.disableScrollWheelZoom();
						
						var marker = new GMarker(point);
						map.addOverlay(marker);

					}
				}
			);
		}
		
	} else {
		
		document.getElementById("caseStudyMap").style.display = "none";
		document.getElementById("mapLink").innerHTML = "Show map";
		
	}

}

function toggleAddImg() {
	
	document.getElementById("addImageDiv").style.display = "";
	document.getElementById("addImageButtonDiv").style.display = "none";

}

function delImage(id) {
	
	if (confirm("Are you sure you wish to delete this image?")) {
		$("#delImageID").val(id);
		$("#delImageForm").submit();
	}
	
}

function delManagement(id) {
	
	if (confirm("Are you sure you wish to delete this Management page?")) {
		$("#delManagementID").val(id);
		$("#delManagementForm").submit();
	}
	
}

function delCaseStudy(id) {
	
	if (confirm("Are you sure you wish to delete this Case Study?")) {
		$("#delCaseStudyID").val(id);
		$("#delCaseStudyForm").submit();
	}
	
}

function delTreatmentType(id) {
	
	if (confirm("Are you sure you wish to delete this Treatment?")) {
		$("#delTreatmentTypeID").val(id);
		$("#delTreatmentTypeForm").submit();
	}
	
}

function delRoadUserType(id) {
	
	if (confirm("Are you sure you wish to delete this Road User?")) {
		$("#delRoadUserTypeID").val(id);
		$("#delRoadUserTypeForm").submit();
	}
	
}

function delCrashType(id) {
	
	if (confirm("Are you sure you wish to delete this Crash Type?")) {
		$("#delCrashTypeID").val(id);
		$("#delCrashTypeForm").submit();
	}
	
}

function selectRelCaseStudy(id) {

	var thisID = '#casestudies_' + id;
	var thisImgID = '#casestudiesimg_' + id;
	
	if ($(thisID).is(':checked') == true) {
	
		$(thisID).attr('checked',false);
		$(thisImgID).attr('src', 'images/icons/cross.png');
	
	} else {
	
		$(thisID).attr('checked',true);
		$(thisImgID).attr('src', 'images/icons/tick.png');
		
	}
	
}

function selectRelRoadUser(id) {

	var thisID = '#roadusers_' + id;
	var thisImgID = '#roadusersimg_' + id;
	
	if ($(thisID).is(':checked') == true) {
	
		$(thisID).attr('checked',false);
		$(thisImgID).attr('src', 'images/icons/cross.png');
	
	} else {
	
		$(thisID).attr('checked',true);
		$(thisImgID).attr('src', 'images/icons/tick.png');
		
	}
	
}

function selectRelCrashType(id) {

	var thisID = '#crashtypes_' + id;
	var thisImgID = '#crashtypesimg_' + id;
	
	if ($(thisID).is(':checked') == true) {
	
		$(thisID).attr('checked',false);
		$(thisImgID).attr('src', 'images/icons/cross.png');
	
	} else {
	
		$(thisID).attr('checked',true);
		$(thisImgID).attr('src', 'images/icons/tick.png');
		
	}
	
}

function selectRelTreatment(id) {

	var thisID = '#treatments_' + id;
	var thisImgID = '#treatmentsimg_' + id;
	
	if ($(thisID).is(':checked') == true) {
	
		$(thisID).attr('checked',false);
		$(thisImgID).attr('src', 'images/icons/cross.png');
	
	} else {
	
		$(thisID).attr('checked',true);
		$(thisImgID).attr('src', 'images/icons/tick.png');
		
	}
	
}
