// JavaScript Document
// JavaScript Document
	function objetus() {
			 try {
					 objeto = new ActiveXObject("Msxml2.XMLHTTP");
			} catch ( e) {
					 try {
							 objeto= new ActiveXObject (" Microsoft.XMLHTTP");
					 } catch (E) {
							  objeto= false;
					}
			}
			if (! objeto && typeof XMLHttpRequest!= 'undefined') {
					 objeto = new XMLHttpRequest();
			}
			return objeto;
}
/*funciones de registro de usuario*/
/* ****************************** */
function logon_usuario() 
{	  
	var aleatorio=Math.random();
	
	var input_usuario = document.getElementById('usuario').value;
	var input_clave = document.getElementById('clave').value;
	var input_guardar_clave = document.getElementById('guardar_clave').checked;
		
	if(input_guardar_clave==true)
		var valor_guardar_clave=1;
	else
		var valor_guardar_clave=0;
			
	if(input_usuario.length==0)
	{
	  	alert('Introduzca el usuario');
		return 0;
	}
	if(input_clave.length==0)
	{
	  	alert('Introduzca la contrase\u00f1a');
		return 0;
	}
	
	var url = "logon.php";
	var params = "usuario="+input_usuario+"&clave="+input_clave+"&guardar_clave="+valor_guardar_clave+"&nocache="+aleatorio+"";
	var http = objetus();
			
	http.open("POST", url, true);
		
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
		
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
		//document.getElementById("loadingdiv").style.display ='block';
		}
		if(http.readyState == 4 && http.status == 200) {			
			document.getElementById('cabecera-registro-gentemax').innerHTML = http.responseText;
			if(document.getElementById('privilegio'))
			{
				var privilegio = document.getElementById('privilegio').value;
			
				if(privilegio==1)
					location.href="area-deportiva-maxspa.php";
				if(privilegio==2)
					location.href="salud_maxspa.php";
				if(privilegio==3)
					location.href="estetica_maxspa.php";
				if(privilegio==50)
					location.href = "";			
			}// if document... privilegio
				
			//document.getElementById("loadingdiv").style.display = 'none';
			//document.getElementById("nav_correcto").style.display = 'block';
			//setTimeout ("document.getElementById('nav_correcto').style.display = 'none';", 3000);
		}// if http.readyState

	}// if http.onreadystatechange
	http.send(params);	
}// fin logon_usuario
	  	  
function cerrar_sesion() 
{  
	var aleatorio=Math.random();
	
	var url = "logout.php";
	var params = "nocache="+aleatorio+"";
	var http = objetus();
				
	http.open("POST", url, true);
		
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
		
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
		//document.getElementById("loadingdiv").style.display ='block';
		}
		if(http.readyState == 4 && http.status == 200) {
				
			document.getElementById('cabecera-registro-gentemax').innerHTML = http.responseText;
			location.href="";
			//document.getElementById("loadingdiv").style.display = 'none';
			//document.getElementById("nav_correcto").style.display = 'block';
			//setTimeout ("document.getElementById('nav_correcto').style.display = 'none';", 3000);
		}
	}
	http.send(params);
}//fin cerrar_sesion

/*funciones de la barra del horario(menos boton semana)*/
/* *************************************************** */
function ventana()
{
	$("a#link_actividad").fancybox(
	{
		'padding': 0,
		'frameWidth': 600,
		'frameHeight':450,
		'hideOnContentClick': false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack'
	});	
	$("a#link_hor_semana").fancybox(
	{
		'padding': 0,
		'frameWidth': 900,
		'frameHeight':500,
		'hideOnContentClick': false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack'
	});
}

function horario_dia_mas() {
	  
		var aleatorio=Math.random();
		var numero_dia = document.getElementById('numero_dia').value;
		numero_dia= Number(numero_dia)+1;
		if(numero_dia==8)
	  		numero_dia=1;
		
		var url = "calcula_horario.php?";
		var params = "numero_dia="+numero_dia+"&nocache="+aleatorio+"";
		var http = objetus();
		
		http.open("GET", url+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				document.getElementById("flecha-dia-menos").style.display ='none';
				document.getElementById("flecha-dia-mas").style.display ='none';
				document.getElementById("texto_dia_horario").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {	
				document.getElementById('fondo_horario').innerHTML = http.responseText;
				ventana();
			}
		}
		http.send(null);
}
	  
function horario_dia_menos() {
	  
		var aleatorio=Math.random();
		var numero_dia = document.getElementById('numero_dia').value;
		numero_dia= Number(numero_dia)-1;
		if(numero_dia==0)
	  		numero_dia=7;
		
		var url = "calcula_horario.php?";
		var params = "numero_dia="+numero_dia+"&nocache="+aleatorio+"";
		var http = objetus();
		
		http.open("GET", url+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				document.getElementById("flecha-dia-menos").style.display ='none';
				document.getElementById("flecha-dia-mas").style.display ='none';
				document.getElementById("texto_dia_horario").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('fondo_horario').innerHTML = http.responseText;
				ventana();
			}
		}
		http.send(null);		
}

function horario_aqua() {
	  
		var aleatorio=Math.random();
		var numero_dia = document.getElementById('numero_dia').value;
		
		var url = "calcula_horario_aqua.php?";
		var params = "numero_dia="+numero_dia+"&nocache="+aleatorio+"";
		
		var http = objetus();
		http.open("GET", url+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				document.getElementById("flecha-dia-menos").style.display ='none';
				document.getElementById("flecha-dia-mas").style.display ='none';
				document.getElementById("texto_dia_horario").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {	
				document.getElementById('fondo_horario').innerHTML = http.responseText;
				ventana();
			}
		}
		http.send(null);		
}

function horario_dia_mas_aqua() {
	  
		var aleatorio=Math.random();
		var numero_dia = document.getElementById('numero_dia').value;
		numero_dia= Number(numero_dia)+1;
		if(numero_dia==8)
	  		numero_dia=1;
		
		var url = "calcula_horario_aqua.php?";
		var params = "numero_dia="+numero_dia+"&nocache="+aleatorio+"";
		var http = objetus();
		
		http.open("GET", url+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				document.getElementById("texto_dia_horario-aqua").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('fondo_horario').innerHTML = http.responseText;
				ventana();
			}
		}
		http.send(null);
}
	  	  
function horario_dia_menos_aqua() {
	  
		var aleatorio=Math.random();
		var numero_dia = document.getElementById('numero_dia').value;
		numero_dia= Number(numero_dia)-1;
		if(numero_dia==0)
	  		numero_dia=7;
		
		var url = "calcula_horario_aqua.php?";
		var params = "numero_dia="+numero_dia+"&nocache="+aleatorio+"";
		var http = objetus();
		
		http.open("GET", url+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				document.getElementById("texto_dia_horario-aqua").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('fondo_horario').innerHTML = http.responseText;
				ventana();
			}
		}
		http.send(null);		
}

function horario_gimnasio() {
	  
		var aleatorio=Math.random();
		var numero_dia = document.getElementById('numero_dia').value;
		
		var url = "calcula_horario.php?";
		var params = "numero_dia="+numero_dia+"&nocache="+aleatorio+"";
		
		var http = objetus();
		http.open("GET", url+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				document.getElementById("texto_dia_horario-aqua").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('fondo_horario').innerHTML = http.responseText;
				ventana();
			}
		}
		http.send(null);		
}

/*funciones de la ventana de horario semanal*/
/* **************************************** */
function calcula_horario_semana() {
	  
		var aleatorio=Math.random();
		var params = "";
		for (i=0;i<document.frm_actividades.elements.length;i++)
     	{
			if(document.frm_actividades.elements[i].type == "checkbox")
         	{
				
				if(document.frm_actividades.elements[i].checked){
					var actividad_valor = document.frm_actividades.elements[i].value;
					params = params+"actividad"+actividad_valor+"="+actividad_valor+""+"&";
				}
			}
		}
		params = params+"selec="+true;
		var url = "calcula_horario_semanal_tabla.php?";
		
		var http = objetus();
		http.open("GET", url+""+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				//document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				//document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				//document.getElementById("texto_dia_horario-aqua").style.display ='none';
				//document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('horario_semanal').innerHTML = http.responseText;
				//ventana();
			}
		}
		http.send(null);		
}

function seleccionar_todo()
{
   for (i=0;i<document.frm_actividades.elements.length;i++)
   {
      if(document.frm_actividades.elements[i].type == "checkbox")
         document.frm_actividades.elements[i].checked=1;
   }
	calcula_horario_semana(); 
} 

function deseleccionar_todo()
{
   for (i=0;i<document.frm_actividades.elements.length;i++)
   {
      if(document.frm_actividades.elements[i].type == "checkbox")
         document.frm_actividades.elements[i].checked=0;
   }
		 calcula_horario_semana();
} 

function calcula_horario_semana_aqua() {
	  
		var aleatorio=Math.random();
		var params = "";
		for (i=0;i<document.frm_actividades.elements.length;i++)
     	{
			if(document.frm_actividades.elements[i].type == "checkbox")
         	{	
				if(document.frm_actividades.elements[i].checked){
					var actividad_valor = document.frm_actividades.elements[i].value;
					params = params+"actividad_aqua"+actividad_valor+"="+actividad_valor+""+"&";
				}
			}
		}
		params = params+"selec_aqua="+true;
		var url = "calcula_horario_semanal_tabla_aqua.php?";//***********************************************************
		
		var http = objetus();
		http.open("GET", url+""+params, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				//document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				//document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				//document.getElementById("texto_dia_horario-aqua").style.display ='none';
				//document.getElementById("loadingdiv").style.display ='block';
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('horario_semanal_aqua').innerHTML = http.responseText;//****************************
				//ventana();
			}
		}
		http.send(null);		
}

function seleccionar_todo_aqua()
{
   for (i=0;i<document.frm_actividades.elements.length;i++)
   {
      if(document.frm_actividades.elements[i].type == "checkbox")
         document.frm_actividades.elements[i].checked=1;
   }
	calcula_horario_semana_aqua(); 
} 

function deseleccionar_todo_aqua()
{
   for (i=0;i<document.frm_actividades.elements.length;i++)
   {
      if(document.frm_actividades.elements[i].type == "checkbox")
         document.frm_actividades.elements[i].checked=0;
   }
		 calcula_horario_semana_aqua();
} 

