$(document).ready(function(){

	function disableBack() { window.history.forward() }

        window.onload = disableBack();
        window.onpageshow = function(evt) { if (evt.persisted) disableBack() }

	$('#submitbuttonhsq').click(function() {
		var icero = 0;
		var re = 0;
		var sf = 0;
		
		$("select").each(function(index){
			rspt = $(this).val();
			if(rspt == "") {
			//RE 
				if (index == 16 || index == 17 ||index == 18){
					re = re + 1;
				}
			//SF
				if (index == 19 || index == 31){
					sf = sf + 1;
				}
			icero = icero + 1;
			}
		});
		
		if( icero >= 3 || re == 2 || sf == 2) {
			alert('The Questionnaire has many "Unknown" items.\nPlease answer each item.');
			return false
		}else{
			$('#HsqScoreAddForm').submit();
		}
	});	
	
	$('#submitbuttonaddhsq').click(function() {
		var icero = 0;
		var re = 0;
		var sf = 0;
		
		$("select").each(function(index){
			rspt = $(this).val();
			if(rspt == "") {
			//RE 
				if (index == 16 || index == 17 ||index == 18){
					re = re + 1;
				}
			//SF
				if (index == 19 || index == 31){
					sf = sf + 1;
				}
			icero = icero + 1;
			}
		});
		
		if( icero >= 3 || re == 2 || sf == 2) {
			alert('The Questionnaire has many "Unknown" items.\nPlease answer each item.');
			return false
		}else{
			$('#HsqScoreAddHsqForm').submit();
		}

	});		
  
});