var tempodecorrido = 0;
var q = 0;

function init(quantquest){

		if( document.all ){
		 AlertaAguarde.style.display = "none";
		 alerta_1.style.visibility = "visible";
	   document.all( "Relogio" ).SetVariable( "executar", 1 );
		 }
		else{
		 document.getElementById( "AlertaAguarde" ).style.display = "none";
		 document.getElementById( "alerta_1" ).style.visibility = "visible";

		 	//Call for flash embed/object named movie:
			var flashObject=getFlashMovieObject("Relogio");
			flashObject.SetVariable("executar",1);
			}

			redim();
			q = quantquest;
	}





function getFlashMovieObject(movieName)
{
        if(document.embeds[movieName]){
                return document.embeds[movieName];
								}
        if(window.document[movieName])
				{
					alert("Faça sua prova");

                return window.document[movieName];
								}
        if(window[movieName]){
                return window[movieName];
								}
        if(document[movieName]){
                return document[movieName];
								}

        return null;
}






function redim()
{
		if( document.all ){
			BodyWidth = document.body.scrollWidth;
			BodyHeight = document.body.clientHeight; // IE6

			BodyHeight = ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight );

			document.all( "alerta_1" ).style.left = ( BodyWidth -  360 ) / 2;
			document.all( "alerta_1" ).style.top = ( BodyHeight -  314 ) / 2;

			document.all( "alerta_2" ).style.left = ( BodyWidth -  360 ) / 2;
			document.all( "alerta_2" ).style.top = ( BodyHeight -  194 ) / 2;


			document.all( "PopAlerta10" ).style.left = ( BodyWidth -  360 ) / 2;
			document.all( "PopAlerta10" ).style.top = ( BodyHeight -  172 ) / 2;

			document.all( "PopAlertaFim" ).style.left = ( BodyWidth -  360 ) / 2;
			document.all( "PopAlertaFim" ).style.top = ( BodyHeight -  180 ) / 2;
		 }
		else{
			BodyWidth = document.body.scrollWidth;
			BodyHeight = document.documentElement.clientHeight;


		 	document.getElementById( "alerta_1" ).style.left = ( BodyWidth -  360 ) / 2 + "px";
			document.getElementById( "alerta_1" ).style.top = ( BodyHeight -  314 ) / 2 + "px";

		 	document.getElementById( "alerta_2" ).style.left = ( BodyWidth -  360 ) / 2 + "px";
			document.getElementById( "alerta_2" ).style.top = ( BodyHeight -  194 ) / 2 + "px";

		 	document.getElementById( "PopAlerta10" ).style.left = ( BodyWidth -  360 ) / 2 + "px";
			document.getElementById( "PopAlerta10" ).style.top = ( BodyHeight -  172 ) / 2 + "px";

		 	document.getElementById( "PopAlertaFim" ).style.left = ( BodyWidth -  360 ) / 2 + "px";
			document.getElementById( "PopAlertaFim" ).style.top = ( BodyHeight -  180 ) / 2 + "px";

			}

}







function JanHabil()
{
		if( document.all ){
		 //AlertaAguarde.style.display = "none";

			BodyWidth = document.body.scrollWidth;
			BodyHeight = document.body.clientHeight; // IE6

			BodyHeight = ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight );

			document.all( "DivHabilidades" ).style.left = ( BodyWidth - 470 ) / 2;
			document.all( "DivHabilidades" ).style.top = ( BodyHeight -  314 ) / 2;

		 }
		else{
		// document.getElementById( "AlertaAguarde" ).style.display = "none";
			BodyWidth = document.body.scrollWidth;
			BodyHeight = document.documentElement.clientHeight;


		 	document.getElementById( "DivHabilidades" ).style.left = ( BodyWidth -  470 ) / 2 + "px";
			document.getElementById( "DivHabilidades" ).style.top = ( BodyHeight -  314 ) / 2 + "px";
			}
}


function ExibeHab(){

		if( document.all ){
		 document.all( "DivHabilidades" ).style.visibility = "visible";
		 }
		else{
		 document.getElementById( "DivHabilidades" ).style.visibility = "visible";
			}
}



function OcultaHab(){

		if( document.all ){
		 document.all( "DivHabilidades" ).style.visibility = "hidden";
		 }
		else{
		 document.getElementById( "DivHabilidades" ).style.visibility = "hidden";
			}
}















function alerta1(){

		if( document.all ){
		 PopAlerta10.style.visibility = "visible";
		 }
		else{
		 document.getElementById( "PopAlerta10" ).style.visibility = "visible";
			}
}

function alerta2(){

		if( document.all ){
		 PopAlertaFim.style.visibility = "visible";
		 }
		else{
		 document.getElementById( "PopAlertaFim" ).style.visibility = "visible";
			}
}

function cancela(){
		if( document.all ){
      document.all( "cancelar" ).style.visibility = "hidden"; }
		else{
		  document.getElementById( "cancelar" ).style.visibility = "hidden"; }
}


	function enviar(F){

		if( document.all ){
     botaoenviar.style.visibility = "hidden";
		 PopAlertaFim.style.visibility = "hidden";
		 alerta_2.style.visibility = "visible";  }
		else{
		 document.getElementById( "botaoenviar" ).style.visibility = "hidden";
		 document.getElementById( "PopAlertaFim" ).style.visibility = "hidden";
		 document.getElementById( "alerta_2" ).style.visibility = "visible";  }
		}


	function tempo( z ){
		 tempodecorrido = z;
		 	//alert( tempodecorrido  );

		Hora   = ( tempodecorrido/3600);
		HoraInt = Math.floor( Hora );
		Minutos = (Hora-HoraInt)*60;
		MinutosInt = Math.floor(Minutos);
		Segundos = (Minutos-MinutosInt)*60;
		SegundosInt = Math.round(Segundos);
		if( SegundosInt == 60 ){ SegundosInt = 0 }

		Hora     = "0" + HoraInt;
		Minutos  = "0" + MinutosInt;
		Segundos = "0" + SegundosInt;

		Hora = Hora.substr( Hora.length - 2, 2 );
		Minutos = Minutos.substr( Minutos.length - 2, 2 );
		Segundos = Segundos.substr( Segundos.length - 2, 2 );

		//alert(  Hora + ":" + Minutos + ":" + Segundos )

				document.formprova.Ftempo.value = Hora + ":" + Minutos + ":" + Segundos;
				document.formprova.action = "rprova.asp";
				document.formprova.submit();
	}

	function enviar2(F){

		if( document.all ){
   		document.all( "Relogio" ).SetVariable( "executar", 0 );
			document.all( "Principal" ).style.visibility = "hidden"; }
		else{
   		document.getElementById( "Relogio" ).SetVariable( "executar", 0 );
			document.getElementById( "Principal" ).style.visibility = "hidden";
			 }

    }



function ocultaalerta( dv ){
		if( document.all ){
		 document.all( dv ).style.visibility = "hidden";
		 }
		else{
		 document.getElementById( dv ).style.visibility = "hidden";
			}

}



function exibeinstr(){
     if( document.all ){
 				 instrucoes.style.visibility = "visible"; }
		 else{
				 document.getElementById( "instrucoes" ).style.visibility = "visible";
		 }

	}

function ocultainstr(){
     if( document.all ){
         instrucoes.style.visibility = 'hidden' }
		 else{
				 document.getElementById( "instrucoes" ).style.visibility = "hidden";
		 }

	}


function fechar(){
				 cancelar.style.visibility = "visible";
	}



function certificado( num ){
			url = "certificado.asp?mgz=" + num
			certif = window.open( url , 'certif', 'width=710,height=510,resizable=0,scrollbars=0,menubar=no,status=0' );
      certif.moveTo( ( screen.availWidth - 710 ) / 2, ( screen.availHeight - 510  ) /2 )
	}




  function contar()
  {

		 if( document.all)
		 {


		 c = 0
	 			for( i = 0; i < q; i++ )
	 			{
	 							NumQ = i+1;
	 							if( NumQ < 10 ){ NumQ = "0" + NumQ; }

	 							var marcado = 0;

	 												for (a=0; a < document.formprova( 'Q' + NumQ ).length; a++)
	 												{
	 														if ( document.formprova( 'Q' + NumQ )[a].checked )
	 														{
	 														  marcado = 1;
	 														  break; //exist for loop, as target acquired.
	 														}
	 												}

  							c += marcado;
	 			}

			  document.all("prog").SetVariable( "numQuestoesConc", c );
		 }else
		 {



		 c = 0
	 			for( i = 0; i < q; i++ )
	 			{
	 							NumQ = i+1;
	 							if( NumQ < 10 ){ NumQ = "0" + NumQ; }

	 							var marcado = 0;

	 												for (a=0; a < document.getElementsByName( 'Q' + NumQ ).length; a++)
	 												{
	 														if ( document.getElementsByName( 'Q' + NumQ )[a].checked )
	 														{
	 														  marcado = 1;
	 														  break; //exist for loop, as target acquired.
	 														}
	 												}

  							c += marcado;
	 			}

			  document.getElementById("prog").SetVariable( "numQuestoesConc", c );



		 }


  }
