// JavaScript Document

function DisableSubmit() {
	document.Form.Submit.disabled = true;
	return true;
}


function toggleVisible(id) {
  var item = document.getElementById(id);
  var value = item.style.display ? '' : 'none';
  item.style.display = value;
}


function popDialog(url, vars) {
	if(!document.getElementById('overlay')) { // Verify we don't already have the overlay
		Element.insert('MainTable', {'before':'	<div id="overlay" style="display:none;"></div>'});
	}
	
	if(!document.getElementById('popTable')) { // Checks to make sure the popup doesn't already exist
		Element.insert('MainTable', {'before':'<div id="popDiv" style="display:none"><table id="popTable" cellspacing="0" cellpadding="0"><tr><td id="popTableContents"><span class="Loading">Loading...</span></td></tr></table></div>'});
	}
	new Ajax.Updater('popTableContents', url + vars, {evalScripts: true});
	Effect.Appear('overlay',{duration:0.5, to:0.75});
	Effect.Appear('popDiv',{duration:0.5});
}

// Legacy support
function showOther(idToCheck, otherID)
{
	if(document.getElementById(idToCheck).value == 'Other')
	{
		document.getElementById(otherID).style.visibility = "visible";	
	} else {
		document.getElementById(otherID).style.visibility = "hidden";	
	}
}

// New forms use this one
/*function showOtherField(idToCheck, otherID)
{	
	if(idToCheck.value == 'Other')
	{
		document.getElementById(otherID).style.visibility = "visible";
		if((idToCheck.type == "checkbox") && (idToCheck.checked == false))
		{
			document.getElementById(otherID).style.visibility = "hidden";
		}
	} else {
		document.getElementById(otherID).style.visibility = "hidden";
	}
}*/

// RORS uses this one
function displayOtherField(idToCheck, otherID)
{	
	if(idToCheck.value == 'Other')
	{
		document.getElementById(otherID).style.display = "inline";
		if((idToCheck.type == "checkbox") && (idToCheck.checked == false))
		{
			document.getElementById(otherID).style.display = "none";
		}
	} else {
		document.getElementById(otherID).style.display = "none";
	}
}


/*function showConditional(idToCheck, valueToCheck, otherIDToShow)
{
	if(document.getElementById(idToCheck).value == valueToCheck)
	{
		document.getElementById(otherIDToShow).style.visibility = "visible";	
	} else {
		document.getElementById(otherIDToShow).style.visibility = "hidden";	
	}
}*/