function resize_iframe(){
	if(document.getElementById("ficha_alta"))
	{
		document.getElementById("ficha_alta").height=1500;
		if(window.frames["ficha_alta"].document.body.scrollHeight>1500)
		{
			document.getElementById('ficha_alta').height=window.frames["ficha_alta"].document.body.scrollHeight;
		}
	}
} 
function reSize()
{
	try{	
	var oBody	=	ficha_alta.document.body;
	var oFrame	=	document.all("ficha_alta");
		
	oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);
	oFrame.style.width = oBody.scrollWidth + (oBody.offsetWidth - oBody.clientWidth);
	}
	//An error is raised if the IFrame domain != its container's domain
	catch(e)
	{
	window.status =	'Error: ' + e.number + '; ' + e.description;
	}
}

function envio_invitacion()
{
	var display_actual = window.document.getElementById('invitacion').style.display;
	qu=document.getElementById('correos_invitacion').value;
	if (qu.length!=0)
	{
		window.document.getElementById('invitacion').style.display = (display_actual == 'none') ? 'block' : 'none';
		url='envio_invitacion.asp?correos='+qu
		Envio_Form_no_retorno_resp('invita',url);
		document.getElementById('correos_invitacion').value='';
	}
	else
	{
		alertas('Debe introducir algun correo');
	}
}
function showinv()
{
	var display_actual = window.document.getElementById('invitacion').style.display;
	window.document.getElementById('invitacion').style.display = (display_actual == 'none') ? 'block' : 'none';
}
function get(url) {
  var poststr = '';
  makePOSTRequestconn(url, poststr);
}

var conn_request = false;
function makePOSTRequestconn(url, parameters) {
  conn_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 conn_request = new XMLHttpRequest();
	 if (conn_request.overrideMimeType) {
		conn_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		conn_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   conn_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!conn_request) {
	 alertas('No se pudo crear la instancia XMLHTTP');
	 return false;
  }
  
  conn_request.onreadystatechange = alert_conns;
  conn_request.open('POST', url, true);
  conn_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  conn_request.setRequestHeader("Content-length", parameters.length);
  conn_request.setRequestHeader("Connection", "close");
  conn_request.send(parameters);
}

function alert_conns() {
  if (conn_request.readyState == 4) {
	 if (conn_request.status == 200) {
		//alertas(http_request.responseText);
		result = conn_request.responseText;
		if(result.length!=0)
		{
			//document.location='home.asp';
		}
		//document.getElementById('myspan').innerHTML = result;            
	 } else {
		//document.location='home.asp';
		//alertas('There was a problem with the request.');
	 }
  }
}

function cargaconectados(what,where) 
{ 
// get data from source (what)
 try 
	 {
	   objetoXML_conn = window.XMLHttpRequest?new XMLHttpRequest():
			new ActiveXObject("Microsoft.XMLHTTP");
	 }
 catch (e) 
	 { 
		/* do nothing */ 
	 }
 div_destino_conn=where;
 objetoXML_conn.onreadystatechange = Lanzado_conn; // when request finished, call the function to put result to destination DIV
 objetoXML_conn.open("GET", what);
 objetoXML_conn.send(null);
  return false;
}
function Lanzado_conn() { // put data returned by requested URL to selected DIV
  if (objetoXML_conn.readyState == 4)
  {
	   if (objetoXML_conn.status == 200) 
		{
			document.getElementById(div_destino_conn).innerHTML =objetoXML_conn.responseText;
		}
		else
		{
			document.getElementById(div_destino_conn).innerHTML = "<center><span class='cargando_ajax'>Ocurrió un error recuperando los datos</center>";
		}
	}
}

function actconns()
{
	gene=document.getElementById("genconn").value;
	chat=document.getElementById("chtconn").value;
	url_a_cargar='usuarios_conectados.asp?cht='+ chat + '&gen=' + gene;
	cargaHTML(url_a_cargar,'conectados');
}

function automatic(nbr, maxi, delay) 
{
	if (nbr <= maxi) 
	{
		if((document.getElementById("genconn"))&&(document.getElementById("chtconn")))
		{
				get('activo.asp');
		}
	}
	if (nbr < maxi) 
	{
		setTimeout('automatic('+(nbr++)+','+maxi+','+delay+')', delay); 
	}
}

automatic(1, 10, 10000);

function autoact(nbr, maxi, delay) 
{
	if (nbr <= maxi) 
	{
		if((document.getElementById("genconn"))&&(document.getElementById("chtconn")))
		{
			gene=document.getElementById("genconn").value;
			chat=document.getElementById("chtconn").value;
			url_a_cargar='usuarios_conectados.asp?cht='+ chat + '&gen=' + gene;
			cargaconectados(url_a_cargar,'conectados');
		}
	}
	if (nbr < maxi) 
	{
		setTimeout('autoact('+(nbr++)+','+maxi+','+delay+')', delay); 
	}
}

autoact(1, 10, 3000);

function chgbusqmp(txt)
{
	document.box.q.value=txt;
	document.box.submit();
}

function abrecht()
{
	window.open("chatwindow.asp" , "redmil_Chat" , "width=700,height=660,scrollbars=NO")
}
function aceptar()
{
	if ((document.login.user.value.length==0)||(document.login.pwd.value.length==0))
	{
		alertas('Para conectarse debe introducir su usuario y password');
	}
	else
	{
		document.login.submit();
	}
}

function abreav(url)
{
 window.open(url,"my_new_window");
}
function votar()
{
	var rad_val =-1
	enc=document.votar.idencuesta.value
	for (var i=0; i < document.votar.opcion.length; i++)
	{
		if (document.votar.opcion[i].checked)
		{
			rad_val = document.votar.opcion[i].value;
		}
	}
	if (rad_val!=-1)
	{
		cargaHTMLsinbarra('lateral_encuestas.asp?id_opc=' + rad_val + '&id_enc=' + enc,'encuestas_lateral');
	}
	else
	{
		alertas('Debe escoger al menos una opción de la votación');
	}
}

/* Cambiar tamaño de la letra - accesabilidad */

var min=8;
var max=18;
function increaseFontSize() 
{
   var p = document.getElementsByTagName('td');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } 
	  else 
	  {
         var s = 12;
      }
      if(s!=max) 
	  {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } 
	  else 
	  {
         var s = 12;
      }
      if(s!=max) 
	  {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('font');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } 
	  else 
	  {
         var s = 12;
      }
      if(s!=max) 
	  {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('span');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=max) 
	  {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('a');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=max) 
	  {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   document.getElementById("t_letra").value=parseInt(document.getElementById("t_letra").value)+1;
   if(document.getElementById("t_letra").value==0)
   {
	    establishFontSize();
   }
}

function decreaseFontSize() 
{
   var p = document.getElementsByTagName('td');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=min) 
	  {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=min) 
	  {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('font');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize)
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=min) 
	  {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('span');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=min) 
	  {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
   p = document.getElementsByTagName('a');
   for(i=0;i<p.length;i++) 
   {
      if(p[i].style.fontSize) 
	  {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      }
	  else 
	  {
         var s = 12;
      }
      if(s!=min) 
	  {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
   document.getElementById("t_letra").value=parseInt(document.getElementById("t_letra").value)-1;
   if(document.getElementById("t_letra").value==0)
   {
	    establishFontSize();
   }
}

function establishFontSize() 
{
   var p = document.getElementsByTagName('td');
   for(i=0;i<p.length;i++) 
   {
      p[i].style.fontSize = ""
   }
   p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) 
   {
      p[i].style.fontSize = ""
   }
   p = document.getElementsByTagName('font');
   for(i=0;i<p.length;i++) 
   {
      p[i].style.fontSize = ""
   }
   p = document.getElementsByTagName('span');
   for(i=0;i<p.length;i++) 
   {
      p[i].style.fontSize = ""
   }
   p = document.getElementsByTagName('a');
   for(i=0;i<p.length;i++) 
   {
      p[i].style.fontSize = ""
   }
   document.getElementById("t_letra").value=0;
}
function recargar_cabecera()
{
	cargaHTML('cabecera_redmil.asp','cabecera');
}

/* Fin cambio de tamaño letra */
