// JavaScript Document for Vascularweb.org CRC application


function validateln(){
	form = document.lnsearch;
	error = "";
	//required form variables
	lastnameValue = form.lastname.value;
	//Last name is required
	if (lastnameValue == ""){
		error += "Last name is a required field\n";
	}
	//output error or submit form
	if (error == ""){
		form.submit();
                form.submit.disabled = true;
	}
	else{
		alert(error);
		return;
	}
}

function validatecr(){
	form = document.crsearch;
	error = "";
	//required form variables
	categoryValue = form.category.value;
	subcategoryValue = form.subcategory.value;
	//Category and sub-category is required
	if (categoryValue == ""){
		error += "Please select a category\n";
	}
	if(subcategoryValue==""){
		error += "Please select a sub-category\n";
	}
	//output error or submit form
	if (error == ""){
		form.submit();
                form.submit.disabled = true;
	}
	else{
		alert(error);
		return;
	}
}

function setOptions(chosen) {
var selbox = document.crsearch.subcategory;
selbox.options.length = 0;
if (chosen == " ") {
	  selbox.options[selbox.options.length] = new Option('Please select one of the categories above first',' ');
	 
	}
	if (chosen == "crcerebrovascular") {
	  selbox.options[selbox.options.length] = new Option('Non-invasive imaging','q7a1');
	  selbox.options[selbox.options.length] = new Option('Carotid Endarterectomy','q7b1');
	  selbox.options[selbox.options.length] = new Option('Carotid Stenting','q7c1');
	  selbox.options[selbox.options.length] = new Option('Stenting of Arch Vessels','q7d1');
	  selbox.options[selbox.options.length] = new Option('Acute Stroke','q7e1');
	}
	if (chosen == "crlowerextremity") {
	  selbox.options[selbox.options.length] = new Option('Non-Invasive Imaging','q8a1');
	  selbox.options[selbox.options.length] = new Option('Aorto-iliac Endovascular','q8b1');
	  selbox.options[selbox.options.length] = new Option('SFA/Pop Endovascular','q8c1');
	  selbox.options[selbox.options.length] = new Option('Tibial Endovascular','q8d1');
	  selbox.options[selbox.options.length] = new Option('Aorto-iliac Bypass','q8e1');
	  selbox.options[selbox.options.length] = new Option('Infrainguinal Bypass','q8f1');
	  selbox.options[selbox.options.length] = new Option('Lytic Therapy','q8g1');
	  selbox.options[selbox.options.length] = new Option('Diabetic Ulcers','q8h1');
	  selbox.options[selbox.options.length] = new Option('Gene Therapy','q8i1');
	  selbox.options[selbox.options.length] = new Option('Stem Cell Therapy','q8j1');
	  selbox.options[selbox.options.length] = new Option('Pharmacology','q8k1');
	}
	if (chosen == "crhemodialysis") {
	  selbox.options[selbox.options.length] = new Option('HA Creation','q9a1');
	  selbox.options[selbox.options.length] = new Option('HA Endovascular','q9b1');
	}
	if(chosen=="crvisceralvessels"){
		selbox.options[selbox.options.length]=new Option('Renal Bypass','q10a1');
		selbox.options[selbox.options.length]=new Option('Renal Stenting','q10b1');
		selbox.options[selbox.options.length]=new Option('Mesenteric Stenting','q10c1');

	}
	if(chosen=="crabdominalaneurysms"){
		selbox.options[selbox.options.length]=new Option('Diagnosis','q11a1');
		selbox.options[selbox.options.length]=new Option('Surgical Repair','q11b1');
		selbox.options[selbox.options.length]=new Option('EVAR Repair','q11c1');
		selbox.options[selbox.options.length]=new Option('Ruptured AAA','q11d1');
	}
	if(chosen=="crthoracicaorta"){
		selbox.options[selbox.options.length]=new Option('Aneurysm Open Repair','q12a1');
		selbox.options[selbox.options.length]=new Option('Aneurysm Endo Repair','q12b1');
		selbox.options[selbox.options.length]=new Option('Thoracic Dissections','q12c1');
		selbox.options[selbox.options.length]=new Option('Thoracic Trauma','q12d1');
	}
	if(chosen=="crvenousdisease"){
		selbox.options[selbox.options.length]=new Option('Varicose Vein Stripping','q13a1');
		selbox.options[selbox.options.length]=new Option('Venous Laser/Radiofrequency','q13b1');
		selbox.options[selbox.options.length]=new Option('Venous Ulcer','q13c1');
		selbox.options[selbox.options.length]=new Option('Lymphedema','q13d1');
		selbox.options[selbox.options.length]=new Option('Venous Thromboembolism','q13e1');
	}
	if(chosen=="crmedicaltreatment"){
		selbox.options[selbox.options.length]=new Option('There is no sub-category for this research interest','q14a1');
	}
}


	// turn on the visibility of the category titles for returned results
	
	function toggleVisibility(e) {
		var e = document.getElementById(e);
		if(e.style.display == "none"){
			e.style.display = "block";
		}else{
			e.style.display = "block";
		}
	}




function validatemessage(thisform){
	error = "";
	//required form variables
	//username is required
	messageValue = thisform.message.value;
	fromemailValue = thisform.fromemail.value;
	if(fromemailValue == ""){
		error += "Please enter your email address\n";
	}
	if (messageValue == ""){
		error += "Please enter your message\n";
	}
	//output error or submit form
	if (error == ""){
		thisform.submit();
        thisform.submit.disabled = true;
	}
	else{
		alert(error);
		return;
	}
}