// Funciones de Pizarrón --------------------
function Pizarron(archivo){
	document.all.SLN.src = archivo
}
function Pizarron_Archivos(htm){
	PizarronActual=	PizarronActual-1
	Pizarron(htm)
}
// Funciones de Preguntas --------------------
function Pregunta_Busco(i){
	var CurrentPosition =document.all.WMPlay.CurrentPosition*1000
	var lap
	if (i-1 == PreguntaActual) { 
		if (CurrentPosition >= TPreguntas[i]) { // El tiempo está bien coordinado
			PreguntaActual=i
			ActualizarPregunta(i)
		}
		else {									// La movie está atrazada, espera tiempo extra
			lap = (TPreguntas[i]-CurrentPosition)
			if (lap > 0) TimerPizarrones = window.setTimeout("Pregunta_Busco("+i+")",lap)
			return
		}
	}
	lap = (TPreguntas[i+1]-TPreguntas[i])
	if (lap > 0) TimerPreguntas = window.setTimeout("Pregunta_Busco("+(i+1)+")",lap)
}

function ActualizarPregunta(i){
	var vBGColor 
	if(Fondo1) vBGColor='#CCCCCC'
	else vBGColor='#FFFFFF'
	Fondo1= !(Fondo1)
	if ( document.all.Preguntas!= null && LPreguntasQue[i] !=null && LPreguntasRESP[i] !="" )	document.all.Preguntas.innerHTML =("<table  border=0 width=100% cellspacing=0 cellpadding=0><tr bgcolor="+vBGColor+"><td width=60 class=h4><b>"+LPreguntasQuien[i]+ ": </b></td><td class=h4>"+LPreguntasQue[i]+"</td><td valign=middle width=14><img src='../botones/ofrespuesta.gif' alt='Respuesta' hspace=2 onMouseOver=bover_on(this,nrespuesta) onMouseOut=bover_off(this,nrespuesta) width=14 height=14 class=boton onclick=Respuesta("+i+")></td></tr></table>"+document.all.Preguntas.innerHTML)
	if ( document.all.Preguntas!= null && LPreguntasQue[i] !=null && LPreguntasRESP[i] =="" )	document.all.Preguntas.innerHTML =("<table  border=0 width=100% cellspacing=0 cellpadding=0><tr bgcolor="+vBGColor+"><td width=60 class=h4><b>"+LPreguntasQuien[i]+ ": </b></td><td class=h4>"+LPreguntasQue[i]+"</td><td valign=middle width=14></td></tr></table>"+document.all.Preguntas.innerHTML)
}

function Preguntar2(){
	var vBGColor 
	if(Fondo1) vBGColor='#CCCCCC'
	else vBGColor='#FFFFFF'
	Fondo1= !(Fondo1)

	var vMiPregunta = document.form.MiPregunta.value
	var vQuien = document.form.Quien.value
	var CurrentPosition =document.all.WMPlay.CurrentPosition
	vMiPregunta=ArreglaTextos2(vMiPregunta)
	if (vMiPregunta.length  >6000 ) {
		alert('La PREGUNTA no debe superar los 6000 caracteres, ingresados '+vMiPregunta.length +' \n')
		return
	}
	if ( document.all.Preguntas!= null && vMiPregunta !=null)	{
		document.all.Preguntas.innerHTML =("<table  border=0 width=100% cellspacing=0 cellpadding=0 ><tr bgcolor="+vBGColor+"><td width=60 class=h4><b>"+vQuien+ ": </b></td><td class=h4>"+document.form.MiPregunta.value+"</td></tr></table>"+document.all.Preguntas.innerHTML)
		magic('SLNDPreguntaG',vArguments1+',-A'+vMiPregunta+',-A'+SecToMin(CurrentPosition))
	}
	document.form.MiPregunta.value=''
}
function ArreglaTextos(campo) {
	vAux=campo.value
	while ((aux=vAux.indexOf('"'))!=-1) vAux=vAux.substr(0,aux)+"'"+vAux.substr(aux+1)
	while ((aux=vAux.indexOf(','))!=-1) vAux=vAux.substr(0,aux)+"|"+vAux.substr(aux+1)
	while ((aux=vAux.indexOf('&'))!=-1) vAux=vAux.substr(0,aux)+"•"+vAux.substr(aux+1)
	while ((aux=vAux.indexOf(String.fromCharCode(13,10)))!=-1) vAux=vAux.substr(0,aux)+"<br>"+vAux.substr(aux+2)
	campo.value=vAux
}	
function ArreglaTextos2(campo) {
	vAux=campo
	while ((aux=vAux.indexOf('"'))!=-1) vAux=vAux.substr(0,aux)+"'"+vAux.substr(aux+1)
	while ((aux=vAux.indexOf(','))!=-1) vAux=vAux.substr(0,aux)+"|"+vAux.substr(aux+1)
	while ((aux=vAux.indexOf('&'))!=-1) vAux=vAux.substr(0,aux)+"•"+vAux.substr(aux+1)
	while ((aux=vAux.indexOf(String.fromCharCode(13,10)))!=-1) vAux=vAux.substr(0,aux)+"<br>"+vAux.substr(aux+2)
	campo=vAux
	return (vAux)
}	

// Funciones Varias --------------------

function ReSize(){
	//get current browser resolution
	iCurrentResWidth = window.document.body.clientWidth;
	iCurrentResHeight = window.document.body.clientHeight;
	document.all.l_preguntas.style.width =252;
	document.all.l_archivos.style.width = 252
	document.all.Preguntas.style.width = 252;
	if (iCurrentResHeight-230 >0)	{
			document.all.l_preguntas.style.height = (iCurrentResHeight-230);
//			document.all.Preguntas.style.height = (iCurrentResHeight-220);
			document.all.l_archivos.style.height = (iCurrentResHeight-230);
			}
	else 	{
			document.all.l_preguntas.style.height = 50;
			document.all.Preguntas.style.height = 20;
			document.all.l_archivos.style.height = 50;
			}
}
function Mostrar(vcual){
	if (vcual==1) {	
			document.all.l_preguntas.style.display=""
			document.all.l_archivos.style.display="none"
			}
	else 	{		
			Pizarron('mgrqispi94.dll?appname=GEducas2&prgname=SLNDArchivos&Arguments='+vArguments1+',-N2')
			document.all.l_preguntas.style.display="none"
			document.all.l_archivos.style.display=""
			}
}

function magic(PRG,ARGS) {
	var iMagic = document.all.ifMagic
	iMagic.src = 'mgrqispi94.dll?appname=GEducas2&prgname='+PRG+'&arguments='+ARGS
	return
}

function SecToMin (secs){
	var minutes;
	var seconds;
	minutes = Math.floor(secs / 60);
	seconds = Math.round(secs % 60);
	seconds = seconds.toString();
	if (seconds.length == 1){	
		seconds = "0" + seconds;
		}	
	return (minutes+":" + seconds);
}

function Busco_Info() { Intervalo=window.setInterval("Info()",100)}
function Info(){    
		var Duration        =document.all.WMPlay.Duration
		var CurrentPosition =document.all.WMPlay.CurrentPosition
		document.all.CurrentPosition.innerHTML = "Posición : (" +SecToMin(CurrentPosition)+" )";
		document.all.Duration.innerHTML = "Duración : ("+SecToMin(Duration)+")";
		if (CurrentPosition >= Duration && CurrentPosition>0 && eEvaluacion == 'OK') {
			Evaluacion();
			window.clearInterval(Intervalo)
		}
}

function WMControl (boton) {
	var lState = document.WMPlay.PlayState
	if (lState==1) {
		apaga(boton,npausa)
		document.WMPlay.Play()
		return
	} 
	if (lState==2) {
		prende(boton,npausa)
		document.WMPlay.Pause()
		return
	} 
}
function WMControl2 (est) {
	var lState = document.WMPlay.PlayState
	var boton= document.images['Control']

	if (est==1) {
		apaga(boton,npausa)
		document.WMPlay.Play()
		return
	} 
	if (est==2) {
		prende(boton,npausa)
		document.WMPlay.Pause()
		return
	} 
}

function Agenda() {
	document.location='mgrqispi94.dll?appname=GEducas2&prgname=Agenda&Arguments='+vArguments2
}
function ArchivosAdj() {
	tmp= new Date()
	Pizarron_Archivos('mgrqispi94.dll?appname=GEducas2&prgname=SLNDArchivos&Arguments='+vArguments1+',2')
}
function Evaluacion() {
	tmp= new Date()
	Pizarron_Archivos('mgrqispi94.dll?appname=GEducas2&prgname=SLNDEvaluacion&Arguments='+vArguments1)
}
function Respuesta(i){
	if ( LPreguntasRESP[i] ==null ||  LPreguntasRESP[i] =='') return //No hace nada ni no existe respuesta
	if ( LPreguntasURL[i] !='') location(LPreguntasURL[i])
	else {
		Pizarron_Archivos('mgrqispi94.dll?appname=GEducas2&prgname=SLNDRespuesta&Arguments='+vArguments1+',-N'+LPreguntasRESP[i]+',-N2')
		document.all.l_preguntas.style.display="none"
		document.all.l_archivos.style.display=""
		}
	return
}
function Foro() {
	document.location='mgrqispi94.dll?appname=GEducas2&prgname=AgendaForos&arguments='+vArguments3
	return
}
