//functions for pathology and phenotypes
//not included in Grails app because of AJAX security not allowing JS to be returned


//process the dropdown before submitting
function processPandp(theSelect) {

	//only submit if a value has been selected
	if(theSelect[theSelect.selectedIndex].value.length>0) {
	
	
	var theValue = theSelect[theSelect.selectedIndex].value;
	var arTheValue = theValue.split("~");
	
	var formType = arTheValue[0].split("=");
	var formValue = arTheValue[1].split("=");
	var formTop = arTheValue[2].split("=");
	
	var theForm = theSelect.form;
	
	theForm.pandpType.value = formType[1];
	theForm.pandpValue.value = formValue[1];
	theForm.pandpTop.value = formTop[1];
	
	//we call onsubmit instead of submit because calling submit bypasses code in onsubmit,
	//which is where Grails puts the AJAX calls. That wasted a day to figure out
		theSelect.form.onsubmit();
	}
	

}

//loading animation
function showWorking(theDivId) {

	var theDiv = document.getElementById(theDivId);
	
	theDiv.innerHTML = "<div style = 'font-weight: bold;'>";
    theDiv.innerHTML+= "Loading...<br/><img src = '/images/circle-ball-dark-antialiased.gif'/>";
    theDiv.innerHTML+= "</div>";

}