function change_made() {
	if (document.getElementById('save_button') != null) {
		document.getElementById('save_button').disabled = false;
	}
}


function change_status(oSelectX) {
	if (oSelectX.options[oSelectX.selectedIndex].text == "Found") {
		document.getElementById('FoundInfo').style.display = 'block';
		document.getElementById('FoundInfo').style.color = 'red';
		document.getElementById('MissingInfo').style.display = 'none';
	} else {
		document.getElementById('FoundInfo').style.display = 'none';
		document.getElementById('MissingInfo').style.display = 'block';
	}
}


function change_page(sNewTab) {
	sCurrentTab = document.getElementById('CurrentTab').value;
	
	document.getElementById(sCurrentTab).className = 'content';
	document.getElementById(sNewTab).className = 'selected_content';
	
	document.getElementById('CurrentTab').value = sNewTab;
}


function change_icon(action,oWhat) {
	if(action == "over" || action == "up") {
		oWhat.style.border = "1px outset";
		oWhat.style.padding = "0px";
	} else if(action == "down") {
		oWhat.style.border = "1px inset";
		oWhat.style.padding = "0px";
	} else {
		oWhat.style.borderWidth = "0px";
		oWhat.style.padding = "1px";
	}
}


function show_hide(sText) {	
	if (document.getElementById(sText).style.display == "none") {
		document.getElementById(sText).style.display = 'inline';
	} else {
		document.getElementById(sText).style.display = 'none';
	}
	
	build_search_types();
}

function build_search_types() {
	sDropdown = '';
	sDropdown += '<select name="Photo_RelatedTopic_0" style="width:220px;">';
	
	aPossibleTypes = new Array("Amputations", "Deformities", "Scars And Marks", "Tattoos", "Piercings", "Medical Implants", "Foreign Objects", "Skeletal Information", "Organ Absent", "Prior Surgery", "Medication Drug History");
	sDropdown += '<option>Facial/Case ID</option>'
			   + '<option>Fingerprint Card</option>'
			   + '<option>Dental Chart</option>'
			   + '<option>Dental Radiograph</option>'
			   + '<option>Other Radiograph</option>';
			   
	for (i=0; i<aPossibleTypes.length; ++i) {
		sField = aPossibleTypes[i].replace(/ /g, '') + 'Chk_box';
		if (document.getElementById(sField).checked == true) {
			sDropdown += '<option>' + aPossibleTypes[i] + '</option>';
		}
	}
	
	sDropdown += '<option>Other</option>';
	sDropdown += '</select>';
	
	document.getElementById('SearchType').innerHTML = sDropdown;
}

function confirm_delete() {
	sMessage = "Are you sure you want to delete this photo?\nClick \"OK\" to continue.\nClick \"Cancel\" to stop.";
	if (!confirm(sMessage)) {
		return false;
	}
}

function confirm_delete_case() {
	sMessage = "WARNING : All data will be lost!\nAre you sure you want to delete this case?\n\nClick \"OK\" to continue.\nClick \"Cancel\" to stop.";
	if (!confirm(sMessage)) {
		return false;
	}
}

function confirm_approval(sUserName) {
	sMessage = "I \"" + sUserName + "\" approve this case for public viewing.\n\nClick \"OK\" to approve.\nClick \"Cancel\" to stop.";
	if (!confirm(sMessage)) {
		return false;
	}
}

function confirm_move(sPath) {
	if (document.getElementById('save_button')  != null && document.getElementById('save_button').disabled == false) {
		sMessage = "All changes to this case will be lost if you continue.\nClick \"OK\" to continue.\nClick \"Cancel\" to stop and then click \"Save\".";
		if (!confirm(sMessage)) {
			return false;
		}
	}
	
	window.location = sPath;
}

function confirm_save() {
	//if (document.getElementById('FirstName').value == "" || 
	//	document.getElementById('LastName').value == "" || 
	//	document.getElementById('Height').value == "" || 
	//	document.getElementById('Height').value == "0" || 
	//	document.getElementById('Weight').value == "" || 
	//	document.getElementById('Weight').value == "0" || 
	//	document.getElementById('AgeLKA').value == "" || 
	//	document.getElementById('Sex').selectedIndex == "0" || 
	//	document.getElementById('DateLKA').value == "-Not Recorded-" || 
	//	document.getElementById('StateLKA').value == "" || 
	//	document.getElementById('CreatorName').value == "" || 
	//	document.getElementById('CreatorEmail').value == "" || 
	//	document.getElementById('CreatorPhone').value == "" )
	//{
	//	alert('You must fill in the First Name, Last Name, Height, Weight, Age, Sex, Date of Disappearance, State Last Seen, and ALL Creator Information to save.');
	//	return false;
	//}
}

function dental_check(e, box) {
	var key = window.event ? e.keyCode : e.which;
	
	if (key > 20)
	{
		var keychar = String.fromCharCode(key);
		if (box.value == "")
		{
			if (keychar == "n" || keychar == "f" || keychar == "c" || keychar == "b" || keychar == "a" || keychar == "p" || keychar == "i" || keychar == "o"
				|| keychar == "N" || keychar == "F" || keychar == "C" || keychar == "B" || keychar == "A" || keychar == "P" || keychar == "I" || keychar == "O")
			{
				return true;
			}
			else
			{
				alert("You entered an invalid code.\nN, F, C, B, A, P, I, and O are the only valid codes.");
				return false;
			}
		}
		else
		{
			if (box.value == "n" || box.value == "N")
			{
				if (keychar == "o" || keychar == "i" || keychar == "O" || keychar == "I")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"N\" can only be matched with O or I");
					return false;
				}
			}
			else if (box.value == "o" || box.value == "O")
			{
				if (keychar == "n" || keychar == "f" || keychar == "c" || keychar == "b" || keychar == "a" || keychar == "p" || keychar == "i"
					|| keychar == "N" || keychar == "F" || keychar == "C" || keychar == "B" || keychar == "A" || keychar == "P" || keychar == "I")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"O\" can only be matched with N, F, C, B, A, P, or I");
					return false;
				}
			}
			else if (box.value == "f" || box.value == "F")
			{
				if (keychar == "o" || keychar == "O")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"F\" can only be matched with O");
					return false;
				}
			}
			else if (box.value == "c" || box.value == "C")
			{
				if (keychar == "o" || keychar == "O")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"C\" can only be matched with O");
					return false;
				}
			}
			else if (box.value == "b" || box.value == "B")
			{
				if (keychar == "o" || keychar == "O")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"B\" can only be matched with O");
					return false;
				}
			}
			else if (box.value == "a" || box.value == "A")
			{
				if (keychar == "o" || keychar == "O")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"A\" can only be matched with O");
					return false;
				}
			}
			else if (box.value == "p" || box.value == "P")
			{
				if (keychar == "o" || keychar == "O")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"P\" can only be matched with O");
					return false;
				}
			}
			else if (box.value == "i" || box.value == "I")
			{
				if (keychar == "o" || keychar == "O" || keychar == "n" || keychar == "N")
				{
					return true;
				}
				else
				{
					alert("You entered an invalid code.\nCode \"I\" can only be matched with O or N");
					return false;
				}
			}
			else
			{
				return false;
			}
		}
	}
}