
	
/* Survey Functions */

function updatequestiontype(section,base){
	var thistype = document.getElementById('questiontypeid');
	var thisname = gettypename(section);
	var thisdiv = thisname+'div';
	var thiscnt = thisname+'count';
	var thisrow = thisname+'row';
	var thisanswer = thisname+'answer';
	var thisvalue = thisname+'value';
	var thisquestion = thisname+"question";
	var thislist = thisname+'listtype';
	
	var arrBase = base.split( "," );

	for(var i = 0; i < arrBase.length; i++){
		$('#'+arrBase[i]+'div').hide();
		disablefields(arrBase[i]);
	}
	
	$('#'+thisdiv).show();
	var cnt = $('#'+thiscnt).val();
	enablefields(cnt,thisname);
	/*if(thisname == 'objective'){
		$('#'+thisquestion).val('Only used as a placeholder, Course Learning Objectives/Outcomes will provide the question');
		$('#'+thisquestion).attr('disabled','disabled');
		$('#'+thisquestion).attr('class','');
	}*/
	
/* Survey Engine updates*/	
	
	
}
function updateitemcount(cnt,base){
	
	
	if(cnt > 0){
	
		for(i=1; i <= 20; i++){
			$('#'+base+'row'+i).hide();
			//$('#'+base+'value'+i).attr("disabled", "disabled");
			//$('#'+base+'answer'+i).attr("disabled", "disabled");
			
		}
		for(i=1; i <= cnt; i++){
			$('#'+base+'row'+i).show();
			
		}
		disablefields(base);
		enablefields(cnt,base);
		
	}
	
}
function disablefields(base){
		$('#'+base+'question').attr("disabled", "disabled");
		$('#'+base+'count').attr("disabled", "disabled");
		$('#'+base+'listtype').attr("disabled", "disabled");
		
		for(i=1; i <= 20; i++){
			
			$('#'+base+'value'+i).attr("disabled", "disabled");
			$('#'+base+'answer'+i).attr("disabled", "disabled");
		}
}
function enablefields(cnt,base){
	$('#'+base+'question').removeAttr("disabled");
	$('#'+base+'count').removeAttr("disabled");
	$('#'+base+'listtype').removeAttr("disabled");
	for(i=1; i <= cnt; i++){
			$('#'+base+'row'+i).show();
			$('#'+base+'value'+i).removeAttr("disabled");
			$('#'+base+'answer'+i).removeAttr("disabled");
		}
}
function gettypename(tmp){
	var name;
	
	if(tmp == '1'){
	name = 'matrix';	
	}
	if(tmp == '2'){
	name = 'text';	
	}
	if(tmp == '3'){
	name = 'truefalse';	
	}
	if(tmp == '4'){
	name = 'mcone';	
	}
	if(tmp == '5'){
	name = 'mcmore';	
	}
	if(tmp == '6'){
	name = 'check';	
	}
	if(tmp == '7'){
	name = 'radio';	
	}
	if(tmp == '8'){
	name = 'objective';	
	}
return name
}

function flagtoggle(base,other){

if($('#'+base).is(':checked')){
	$('#'+other).attr('disabled','disabled');
	$('#'+other).removeAttr('checked');
	$('#'+other+'text').attr('class','dimtext');
	}else{
	$('#'+other).removeAttr('disabled');
	$('#'+other+'text').attr('class','');
}

	
}

/* Misc functions*/
if ('undefined' == typeof Array.prototype.findIndex) {
  Array.prototype.findIndex = function(value){
    var ctr = "";
    for (var i=0; i < this.length; i++) {
      if (this[i] == value) {
        return i;
      }
    }
    return ctr;
  }
}

