function load_index()
{
    Shadowbox.init();	
    ejecuta(['aviso','1'],['tipo','show'],['files_ajax/main.php?'],['rndarticulo'],1);	
    ejecuta(['aviso','2'],['tipo','show'],['files_ajax/main.php?'],['rndaviso'],1);		
    //ejecuta(['udafe','','1'],['tipo','codigo','carga_evento'],['files_ajax/calendar.php?'],['calendar'],1);	
    ejecuta(['UNIVERSIDAD DEL AZUAY'],['titulo'],['files_ajax/title.php?'],['titulo'],'false');		
    ejecuta([''],[''],['files_ajax/main_event.php'],['show_event'],'false');		
    ejecuta([''],[''],['files_ajax/main_event_title.php'],['event_title'],'false');		
}
function validar_inscripcion()
{
	var nombre=document.getElementById('nombre').value;
	var apellido=document.getElementById('apellido').value;
	var codigo=document.getElementById('codigo').value;
	var email=document.getElementById('email').value;
	var equipo=document.getElementById('equipo').value;	
	if(nombre=='' || apellido=='' || email=='' || codigo=='' || equipo==0)
	{
		var verificador=1;
		texto="<br>Por Favor ingrese todos los datos.<br><br>";
	}
	else
	{
		var verificador=2;
		texto='<br><br><br>';
	}
	ejecuta([nombre,apellido,codigo,email,equipo,verificador,texto],['nombre','apellido','codigo','email','equipo','verificador','texto'],['files_ajax/load_inscripcion.php?'],['modal_dep'],[false])			
}
function carga_equipo()
{
	var equipo=document.getElementById('equipo').value;	
	ejecuta([equipo],['equipo_x'],['files_ajax/load_player.php?'],['show_player'],[false]);			
}
function cambiar (name) 
{
	switch(name)
	{
		case 1:
			src="./images/event_fotox.gif";
		break;
		
		case 2:
			src="./images/event_infox.gif";			
		break;
		
		case 3:
			src="./images/event_fotosx.gif";				
		break;
		
		case 4:
			src="./images/event_videosx.gif";		
		break;		
		
		case 10:
			name=name/10;
			src="./images/event_foto.gif";		
		break;
		
		case 20:
			name=name/10;
			src="./images/event_info.gif";				
		break;
		
		case 30:
			name=name/10;
			src="./images/event_fotos.gif";				
		break;
		
		case 40:
			name=name/10;
			src="./images/event_videos.gif";				
		break;			
	}
	name="f"+name;
	document.images[name].src = src; 
}
function cambiarx (name) 
{
	switch(name)
	{
		case 1:
			src="./images/event_eventosx.gif";
		break;
		
		case 2:
			src="./images/event_avisosx.gif";			
		break;
		
		case 3:
			src="./images/event_bibliox.gif";				
		break;
		
		case 4:
			src="./images/event_videosx.gif";		
		break;		
		
		case 10:
			name=name/10;
			src="./images/event_eventos.gif";		
		break;
		
		case 20:
			name=name/10;
			src="./images/event_avisos.gif";				
		break;
		
		case 30:
			name=name/10;
			src="./images/event_biblio.gif";				
		break;
		
		case 40:
			name=name/10;
			src="./images/event_videos.gif";				
		break;			
	}
	name="f"+name;
	document.images[name].src = src; 
}
function validar_acceso(responder,encuesta,status,ps_codigo,ps_nombre,mensaje,auxiliar)
{
	ps_codigo=document.getElementById(ps_codigo).value;
	ps_nombre=document.getElementById(ps_nombre).value;
	if(status==1)
	{
		modal("<div style=padding:8;color:white><center>"+encuesta+"</div>");	
llamadasin('files_ajax/mod_encuestas.php?responder='+responder+'&cod_encuesta='+auxiliar+'&per_codigo='+ps_codigo+'&per_nombre='+ps_nombre+'&status=0','mod_encuesta',false);		
	}
	if(status==0)
llamadasin('files_ajax/mod_encuestas.php?responder='+responder+'&cod_encuesta='+auxiliar+'&per_codigo='+ps_codigo+'&per_nombre='+ps_nombre+'&status=1','mod_encuesta',false);
}
function modal_parametro(parametro)
{
    modal("<div style=padding:8;color:white><center>"+parametro+"</div>");	
}
function modal_evento(parametro)
{
	parametro=document.getElementById(parametro).value;
    modal("<div style=padding:8;color:white><center>"+parametro+"</div>");	
}
function valida_ingreso()
{
	c1=0;
	if(document.getElementById('per_codigo').value=='')
		document.getElementById('img_codigo').style.visibility='visible'
	else
	{
		document.getElementById('img_codigo').style.visibility='hidden'	
		c1++;
	};
	
	if(document.getElementById('per_nombre').value=='')
		document.getElementById('img_nombre').style.visibility='visible'
	else
	{
		document.getElementById('img_nombre').style.visibility='hidden'	
		c1++;
	};
	
	if(document.getElementById('per_apellido').value=='')
		document.getElementById('img_apellido').style.visibility='visible'
	else
	{
		document.getElementById('img_apellido').style.visibility='hidden'	
		c1++;
	};	
	if(c1==3)
	llamadasin('files_ajax/show_validate.php?per_codigo='+document.getElementById('per_codigo').value+'&per_nombre='+document.getElementById('per_nombre').value+'&per_apellido='+document.getElementById('per_apellido').value+'&codencuesta='+document.getElementById('codencuesta').value+'','modal_pol',false);
}
function cargar() 
{
  llamadasin('files_ajax/main.php?tipo=aviso&show=1', 'rndarticulo',false);
  llamadasin('files_ajax/main.php?tipo=aviso&show=2', 'rndaviso',false);  
  llamadasin('files_ajax/calendar.php?tipo=udafe', 'calendar',false);    
  llamadasin('files_ajax/title.php?titulo=UNIVERSIDAD DEL AZUAY', 'titulo',false);  
  llamadasin('files_ajax/main_event.php', 'show_event',false);  
  llamadasin('files_ajax/main_event_title.php', 'event_title',false);      
}
function tooltip(text)
{
	text="<div style=text-align:center>"+text+"<div>";
	dw_Tooltip.content_vars={L1:text}
}
function ejecuta_parametro(param) 
{
	parametro=document.getElementById(param).value;
	vars=parametro.split("|");
	ejecuta([vars[0]],[vars[1]],[vars[2]],[vars[3]],[vars[4]]);
}
function ejecuta(variables,parametros,url,div,estado) 
{
  var matriz_valores=retorna_matriz(variables);
  var matriz_variables=retorna_matriz(parametros);  
  var matriz_url=retorna_matriz(url);  
  var matriz_div=retorna_matriz(div);    
  var matriz_estado=retorna_matriz(estado);   
  for(y=0;y<matriz_url.length;y++)
  {
	  for(x=0;x<matriz_valores.length;x++)
	  {
		  matriz_url[y]+=matriz_variables[x]+"="+matriz_valores[x]+"&"; 
	  } 
	  llamadasin(matriz_url[y],matriz_div[y],matriz_estado[y]);		  
  }   
}
function ejecuta_element(variables,parametros,url,div,estado) 
{
  var matriz_valores=retorna_valor(variables);
  var matriz_variables=retorna_matriz(parametros);  
  for(x=0;x<matriz_valores.length;x++)
  {
	  url=url+matriz_variables[x]+"="+matriz_valores[x]+"&";
  }
  llamadasin(url,div,estado);
}
function abre_element(variables,parametros,url) 
{
  var matriz_valores=retorna_matriz(variables);
  var matriz_variables=retorna_matriz(parametros);  
  for(x=0;x<matriz_valores.length;x++)
  {
	  url=url+matriz_variables[x]+"="+matriz_valores[x]+"&";
  }
  window.open(url,'eventos','');	  
}

function abre_fotos(parametro) 
{
 	valor=document.getElementById(parametro).value;
	para=valor.split(",");
	ejecuta([para[0],'fotos',para[2],para[3],para[4]],['codigo','variante','fecha','get_global','get_codigo'],['files_ajax/cargar_fotos_videos.php?'],['load_events'],['1'])
}
function abre_videos(parametro) 
{
 	valor=document.getElementById(parametro).value;
	para=valor.split(",");
	ejecuta([para[0],'videos',para[2],para[3],para[4]],['codigo','variante','fecha','get_global','get_codigo'],['files_ajax/cargar_fotos_videos.php?'],['load_events'],['1'])
}
function gup( name )
{
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp ( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results != null )
		return results[1];
}

function retorna_matriz(matriz)
{
  matriz=matriz.toString();
  cont=0;
  str="";
  lon=matriz.length;
  var retorno=new Array();
  for(x=0;x<lon;x++)
  {
	 a=matriz.charAt(x); 	   
	 if(a==',')
	 {
		cont++;
		str="";
	 }
	 else
	 {
		 str=str+a;
		 retorno[cont]=str;		 
	 }
  }		
  return retorno;
}
function retorna_valor(matriz)
{
  matriz=matriz.toString();
  cont=0;
  str="";
  lon=matriz.length;
  var retorno=new Array();
  for(x=0;x<lon;x++)
  {
	 a=matriz.charAt(x); 	   
	 if(a==',')
	 {
		cont++;
		str="";
	 }
	 else
	 {
		 str=str+a;
		 retorno[cont]=str;		 
	 }
  }		
  for(x=0;x<=cont;x++)
  {
		retorno[x]=document.getElementById(retorno[x]).value;		
  }
  return retorno;
}

var ver_estado;
function ver_funcion1(Id,destino) 
{
	Cal="clase"+Id;
	document.getElementById(Cal).style.visibility="visible";
	if(Id!=destino)
	{
		Cal="clase"+Id;
		document.getElementById(Cal).style.visibility="hidden";
		Cal="clase"+destino;
		document.getElementById(Cal).style.visibility="visible";
	}
}

function ver_funcion(Id,estado,Numero,Num) 
{
	Cal="calendars"+Numero;
	if(estado=="TRUE")
	{
		document.getElementById(Cal).style.visibility="visible";
		a=document.getElementById(Id).offsetTop;
		b=document.getElementById(Id).offsetLeft;
		var oDiv1 = document.getElementById(Cal);
		oDiv1.style.top = a;
		oDiv1.style.left =b+20;	
	}
	else
	{
		document.getElementById(Cal).style.visibility="hidden";  
	}
}
function ocultar(Id,Estado,Numero) 
{
	Cal="calendars"+Numero;
	document.getElementById(Cal).style.visibility="hidden";
}

function show_poll(Id,Cal,State,Reg,ck)
{
	if(ck==1)
		llamadasin('files_ajax/div_encuestas.php', 'poll_mod',false);  	
	ok=document.getElementById(State).value;
	if(ck==1)
	{
		if(ok=='true')
		{
			document.getElementById(Cal).style.visibility="visible";
			document.getElementById(State).value=false;
		}
		else
		{
			document.getElementById(Cal).style.visibility="hidden";	
			document.getElementById(State).value=true;		
		}
	}
	a=document.getElementById(Id).offsetTop;
	b=document.getElementById(Id).offsetLeft;
	var oDiv1 = document.getElementById(Cal);
	Base=190;
	Fact=20;
	oDiv1.style.top =a-Base-(Reg*Fact);
	oDiv1.style.left =b+35;	
}

function more_poll(from,hasta,nmax)
{	
	llamadasin('files_ajax/div_encuestas.php?min='+from+'&to='+hasta+'&verificador=1', 'poll_mod',false);  
	vv=hasta-from;
	show_poll('show_poll_mod','poll_mod','poll_state',vv,0);	
	document.getElementById("poll_mod").style.visibility="visible";
}

function countDown(Es,Numero,Tiempo,Num1) 
{
  ver_estado=Es;
  Num=Numero;
  Nums=Num1;
  var c = window.setTimeout("ocultarx(Num,Nums);", Tiempo);
}


function ocultarx(Numero,Num) 
{
	if(ver_estado=="0")
	{
		Cal="calendars"+Num;
		document.getElementById(Cal).style.visibility="hidden";
	}
	else
	{
		Cal="calendars"+Num;
		document.getElementById(Cal).style.visibility="visible";
	}
}

function aparecer(Es,Numero) 
{
	ver_estado=Es;
	Cal="calendars"+Numero;
	document.getElementById(Cal).style.visibility="visible";
}

function validar_formulario(np) 
{
	np=np-1;
	codigo_encuestas=document.getElementById("encuesta").value;
	codigo_persona=document.getElementById("estudiante").value;
	respuestas='';
	for(x=1;x<=np;x++)
	{
		sc="secreto"+x;
		respuestas+=document.getElementById(sc).value;
	}
	
	atc=document.getElementById("num_preguntas").value;		
	if (atc == 1) 
	{	
		numerp = document.getElementById("num").value;		
		numerp1 = document.getElementById("num_preguntas").value;		
		desde = document.getElementById("desde").value;		
		objetos = new Array(numerp);		
		objetos1 = new Array(numerp1);		
		for (x = 1; x <= numerp1; x++) 
		{		
			objetos1[x] = "";			
		}
		for (x = 0; x < numerp; x++)
		{		
			d = parseFloat(desde) + x;			
			objetos[x] = document.forms["enviar"].elements[d].id;			
		}
		for (x = 0; x < numerp; x++) 
		{		
			variable = objetos[x];			
			texto = variable.lastIndexOf("-");			
			id = objetos[x].substr(0, texto);			
			tipo = objetos[x].substr(texto + 1, objetos[x].length);			
			objetos1[id] = objetos1[id] + objetos[x] + "(";			
		}		
		global = "";		
		contarc = 0;	
		for (x = 0; x < numerp1; x++) 
		{		
			cadena = "";			
			cadenax = "";			
			var array_datos = objetos1[x + 1].split("(");			
			var lon = objetos1[x].split("-");			
			lon = lon.length;			
			for (q = 0; q < lon; q++) 
			{			
				variable = array_datos[q];				
				texto = variable.lastIndexOf("-");				
				id = array_datos[q].substr(0, texto);				
				tipo = array_datos[q].substr(texto + 1, array_datos[q].length);				
				tipo1 = tipo.lastIndexOf("una");				
				tipo2 = tipo.lastIndexOf("dos");				
				tipo3 = tipo.lastIndexOf("tres");	
				if (tipo1 != -1) 
				{				
					z = array_datos[q];					
					abrir = "secreto" + id;					
					cadena = document.getElementById(abrir).value;					
					if (cadena == "") 
					{					
						global = global + "false"						
						r = id;						
						tr = "texto" + r;						
						document.getElementById(tr).style.visibility = "visible";						
					}					
					else 
					{					
						global = global + "true"						
						r = id;						
						tr = "texto" + r;						
						document.getElementById(tr).style.visibility = "hidden";						
					}
				}				
				if (tipo2 != -1) 
				{				
					z = array_datos[q];		
					contarc = contarc + 1;					
					cadenax = cadenax + document.getElementById(z).checked;					
					variable = cadenax;					
					texto = variable.lastIndexOf("true");					
					if (texto == -1) 
					{					
						cadenax = "false"						
						r = id;						
						tr = "texto" + r;						
						document.getElementById(tr).style.visibility = "visible";						
					}					
					else 
					{					
						cadenax = "true"						
						r = id;						
						tr = "texto" + r;						
						document.getElementById(tr).style.visibility = "hidden";						
					}					
				}				
				if (tipo3 != -1) 
				{				
					z = array_datos[q];
					cadena = cadena + document.getElementById(z).value;					
					if (cadena == "") 
					{					
						global = global + "false"						
						r = id;						
						tr = "texto" + r;						
						document.getElementById(tr).style.visibility = "visible";						
					}					
					else 
					{					
						global = global + "true"						
						r = id;						
						tr = "texto" + r;						
						document.getElementById(tr).style.visibility = "hidden";						
					}					
				}				
			}			
			text = cadenax.lastIndexOf("true");			
			text1 = cadenax.lastIndexOf("false");			
			if (text == 0) 			
				global = global + "true";			
			if (text1 == 0) 			
				global = global + "false";			
		}		
		validar = global.lastIndexOf("false");		
		if (validar == -1) ejecuta([codigo_encuestas,codigo_persona,respuestas],['p_encuesta','p_persona','p_respuestas'],'files_ajax/poll_results.php?','modal_pol','false');	else return false;		
	}
	if (atc > 1) 
	{
		numerp = document.getElementById("num").value;		
		numerp1 = document.getElementById("num_preguntas").value;		
		desde = document.getElementById("desde").value;		
		objetos = new Array(numerp);		
		objetos1 = new Array(numerp1);	
		for (x = 1; x <= numerp1; x++) 
		{objetos1[x] = "";}		
		for (x = 0; x < numerp; x++) 
		{		
			d = parseFloat(desde) + x;			
			objetos[x] = document.forms["enviar"].elements[d].id;	
		}		
		for (x = 0; x < numerp; x++) 
		{		
			variable = objetos[x];			
			texto = variable.lastIndexOf("-");			
			id = objetos[x].substr(0, texto);			
			tipo = objetos[x].substr(texto + 1, objetos[x].length);			
			objetos1[id] = objetos1[id] + objetos[x] + "(";			
		}		
		global = "";		
		contarc = 0;		
		for (x = 1; x <= numerp1; x++) 
		{		
			cadena = "";			
			cadenax = "";			
			var array_datos = objetos1[x].split("(");			
			var lon = objetos1[x].split("-");			
			lon = lon.length - 1;			
			for (q = 0; q < lon; q++) 
			{			
				variable = array_datos[q];				
				texto = variable.lastIndexOf("-");				
				id = array_datos[q].substr(0, texto);				
				tipo = array_datos[q].substr(texto + 1, array_datos[q].length);				
				tipo1 = tipo.lastIndexOf("una");			
				tipo2 = tipo.lastIndexOf("dos");				
				tipo3 = tipo.lastIndexOf("tres");			
				if (tipo1 != -1) 
				{
					z = array_datos[q];
					abrir = "secreto" + id;
					cadena = document.getElementById(abrir).value;
					if (cadena == "") 
					{
						global = global + "false"
						r = id;
						tr = "texto" + r;
						document.getElementById(tr).style.visibility = "visible";
					}
					else 
					{
						global = global + "true"
						r = id;
						tr = "texto" + r;
						document.getElementById(tr).style.visibility = "hidden";
					}
				}
				if (tipo2 != -1) 
				{
					z = array_datos[q];
					contarc = contarc + 1;
					cadenax = cadenax + document.getElementById(z).checked;
					variable = cadenax;
					texto = variable.lastIndexOf("true");
					if (texto == -1) 
					{
						cadenax = "false"
						r = id;
						tr = "texto" + r;
						document.getElementById(tr).style.visibility = "visible";
					}
					else 
					{
						cadenax = "true"
						r = id;
						tr = "texto" + r;
						document.getElementById(tr).style.visibility = "hidden";
					}
				}
				if (tipo3 != -1) 
				{
					z = array_datos[q];
					cadena = cadena + document.getElementById(z).value;
					if (cadena == "")
					{
						global = global + "false"
						r = id;
						tr = "texto" + r;
						document.getElementById(tr).style.visibility = "visible";
					}
					else 
					{
						global = global + "true"
						r = id;
						tr = "texto" + r;
						document.getElementById(tr).style.visibility = "hidden";
					}
				}
			}
			text = cadenax.lastIndexOf("true");
			text1 = cadenax.lastIndexOf("false");
			if (text == 0) global = global + "true";
			if (text1 == 0) global = global + "false";
		}
		validar = global.lastIndexOf("false");
		if (validar == -1) ejecuta([codigo_encuestas,codigo_persona,respuestas],['p_encuesta','p_persona','p_respuestas'],'files_ajax/poll_results.php?','modal_pol','false'); else return false;
	}
}
function charge(pregunta,opcion,inpu,tipo,id)
{
	switch(tipo)
	{
		case 1:
			document.getElementById(inpu.id).value=pregunta+":"+opcion+";";			
		break;
		
		case 2:
			estado=document.getElementById(id).checked;
			buscar=pregunta+":"+opcion+";";
			buscar=buscar.toString();
			texto=document.getElementById(inpu.id).value;
			texto=texto.toString();
			posicion=texto.indexOf(buscar); 			
			if(estado==true)
			{
				if(posicion==-1)
					document.getElementById(inpu.id).value=document.getElementById(inpu.id).value+pregunta+":"+opcion+";";						
			}
			else
				document.getElementById(inpu.id).value=texto.replace(buscar,"");
		break;
		
		case 3:
			document.getElementById(inpu.id).value=pregunta+":"+id+";";				
		break;
	}
}