$(document).ready(function(){
	$('#test_category').change( function() {
		indice=$(this).val();
		items=arTests[indice].length;
		
		testid = $('#test_id');
		testid.html("");
		
		for(i=0;i<items;i++){
			var thisOpt = document.createElement('option');
			
			thisOpt.value = arTests[indice][i][1];
			$(thisOpt).text(arTests[indice][i][0]);
			
			testid.append(thisOpt);
		}
	});
});

$(function () {
   $("#goprevious").click( function() {
		pregunta(-1);
	});
	$("#gonext").click( function() {
		pregunta(1);
	});
	$(".question").addClass("offleftjava");
	$("#question1").removeClass("offleftjava");
	$("#sendform").addClass("offleftjava");
});

function pregunta(antsig){
	radiochecked=false;
	radioObj=eval("document.testfrm.p"+preguntaanterior);

	radioLength = radioObj.length;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			radiochecked=true;
		}
	}

	if(radiochecked || antsig==-1){
		if(antsig==-1 && preguntaanterior > 1){
		showpregunta=preguntaanterior+antsig;
		nextbutton=document.getElementById("gonext").style.display;
		}
		else if(antsig==1 && preguntaanterior < totalpreguntas){
		showpregunta=preguntaanterior+antsig;
		previousbutton=document.getElementById("goprevious").style.display;
		}
		$("#question"+showpregunta).removeClass("offleftjava");
		$("#question"+preguntaanterior).addClass("offleftjava");
		if(showpregunta==1){
			$("#goprevious").css("display","none");
		}
		else if(showpregunta==totalpreguntas){
			$("#gonext").css("display","none");
			$("#sendform").removeClass("offleftjava");
		}
		if(showpregunta>1){
			$("#goprevious").css("display","block");
		}
		if(showpregunta<totalpreguntas){
			$("gonext").css("display","block");
		}
		preguntaanterior=showpregunta;
	}
	else{
		alert(replyquestion);
	}
}
