// JavaScript Document

function enviar_formulario (xxx){
	formulario=document.getElementById(xxx);
	valor= comprobar_campos(formulario,0);
	if (valor) formulario.submit();
}
function enviar_formulario_factura (xxx){
	formulario=document.getElementById(xxx);
	if (document.getElementById('solicito').checked){
		valor= comprobar_campos(formulario,0);
	}else{
		valor=true;
	}
	if (valor) formulario.submit();
}
function enviar_formulario_borrado (xxx,pregunta){
	var entrar = confirm(pregunta);
	if ( entrar ){
		valor=document.getElementById('borrar_tabla').value=1;
		formulario=document.getElementById(xxx);
		valor= comprobar_campos(formulario,0);
		if (valor) formulario.submit();
	}
}
function calcula_importe (xxx,yyy)
{
	formulario=document.getElementById(xxx);
	//valor= checkIn_selFecha(yyy);
	valor= checkIn(yyy);
	if (valor) formulario.submit();
}

function calcula_importe_ext (xxx,yyy)
{
	formulario=document.getElementById(xxx);
	valor= checkIn_ext(yyy);
	if (valor) formulario.submit();
}

function comparaFecha(fecha, fecha1)
{
	fec=fecha.split("/");
	fec1=fecha1.split("/");
	if(fec[0]>fec1[0])
	{
		return 1;
	}
	else if(fec[0]<fec1[0])
	{
		return -1;
	}
	else
	{
		if(fec[1]>fec1[1])
		{
			return 1;
		}
		else if(fec[1]<fec1[1])
		{
			return -1;
		}
		else
		{
			if(fec[2]>fec1[2])
			{
				return 1;
			}
			else if(fec[2]<fec1[2])
			{
				return -1;
			}
			else
			{
				return 0;
			}
		}
	}
} 
function checkIn_selFecha(xxx)
{
	control = new Array (xxx);
	//Obtenemos el FORM inscripcion
	var f = document.getElementById('inscripcion'); 
	//Recorremos todos los elementos del FORM
 	for( var i = 0; i < f.elements.length; i++ ) 
 	{ 
		//Para cada iteración obtenemos:
		//		-Elemento
		var elemento = f.elements[i];
		var previo;
		var pre;
		//En previo almacenamos un array que separa sus elementos por medio de '_'. estos datos se obtienen de la
		//propiedad 'name' del Elemento.
		previo=elemento.name.split("_");
		vio=previo[0];
		if (previo[1]!=null)
		{
			pre=previo[1].split("-");
			if (pre[0]=='ins')
				if (elemento.checked)
					control[vio]=1;
		}
 	} 
	final=0;
	for (var h=0; h<control.length; h++)
		if (control[h]!=1)
			final=1;
	if (final!=0)
	{
		alert(text_almenos);
		return false;
	}
	else
	 	return true;
}

function calcula_importe_insc (xxx,yyy)
{
	formulario=document.getElementById(xxx);
	valor= checkIn_selFecha_insc(yyy);
	if (valor) formulario.submit();
}
function checkIn_selFecha_insc(xxx)
{
	control = new Array (xxx);
	//Obtenemos el FORM inscripcion
	var f = document.getElementById('inscripcion'); 
	//Recorremos todos los elementos del FORM
 	for( var i = 0; i < f.elements.length; i++ ) 
 	{ 
		//Para cada iteración obtenemos:
		//		-Elemento
		var elemento = f.elements[i];
		var previo;
		var pre;
		//En previo almacenamos un array que separa sus elementos por medio de '_'. estos datos se obtienen de la
		//propiedad 'name' del Elemento.
		previo=elemento.name.split("_");
		vio=previo[0];
		if (previo[1]!=null)
		{
			pre=previo[1].split("-");
			if (pre[0]=='ins')
			{
				if (elemento.value != "")
					control[vio]=1;
			}
		}
 	} 
	final=0;
	for (var h=0; h<control.length; h++)
	{
		if (control[h]!=1)
			final=1;
	}
	if (final!=0)
	{
		alert(text_almenos);
		return false;
	}
	else
	 	return true;
}
//Buscar hoteles desde ONLINE
function buscar_hoteles_insc_online(xxx, yyy, zzz)
{
	var fechaIni = document.getElementById(yyy + '_campoini').value;
	var fechaFin = document.getElementById(yyy + '_campofin').value;
	var SelHotel = document.getElementById('hoteles');
	var ajax = xmlhttp();
	var cadena_id = "habitacionhotel_";
	var reserva_id, NombreHotel, TipoHabitacion, Precio;
	var Memoria=false;
	
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			//Mostramos el mensaje de Cargando Hoteles con Habitaciones disponibles
			document.getElementById ('Cargando_' + yyy).style.display = "inline";
			document.getElementById ('Cargando_' + yyy).innerHTML = text_cargando_hoteles + "<img src='../images/geyseco_loading.gif' alg='Cargando Hoteles...' />";
		}
		if(ajax.readyState == 4)
		{
			SelHotel.length = 0;
			var elOptNew = document.createElement('option');
			elOptNew.text = 'Seleccione un hotel';
			elOptNew.value = '';
			elOptNew.selected = true;
			try 
			{
				SelHotel.add(elOptNew, null); // Segun el STANDARD de W3C, no funciona con IE
			}
			catch(ex) 
			{
				SelHotel.add(elOptNew); // IE only
			}
			var elementos, indices;
			var info=ajax.responseText;
			valor = info.split("*");
			for (elementos in valor)
			{					
				campos = valor[elementos].split("-");
				for (indices in campos)
				{
					campo = campos[indices].split(":");
					if (campo[0].indexOf('habitacionhotel_') != -1)
					{	
						reserva_id = campo[0].substring(cadena_id.length);
						if (campo[1] == 1)
							Memoria = true;
						else
							Memoria = false;
					}
					if (Memoria == true)
					{
						if  (campo[0].indexOf('NombreHotel')!= -1)
							NombreHotel = campo[1];
						if  (campo[0].indexOf('TipoHabitacion')!= -1)
							TipoHabitacion = campo[1];
						if  (campo[0].indexOf('Precio')!= -1)
							Precio = campo[1];
					}
				}
				if (Memoria == true)
				{
					var elOptNew = document.createElement('option');
					elOptNew.text = NombreHotel + " " + TipoHabitacion + " " + Precio + String.fromCharCode(8364);
					elOptNew.value = reserva_id;
					try 
					{
						SelHotel.add(elOptNew, null); // Segun el STANDARD de W3C, no funciona con IE
					}
					catch(ex) 
					{
						SelHotel.add(elOptNew); // IE only
					}
				}
			}
			//Desactivamos el mensaje de Cargando Hoteles con habitaciones disponibles
			document.getElementById('Cargando_' + yyy).style.display = "none";
			document.getElementById('Cargando_' + yyy).innerHTML = "";
			//Desactivamos también el botón de busqueda.
			document.getElementById('boton_' + yyy).style.display = "none";
			//Habilitamos por último el COMBOBOX deshabilitado al haber cambiado alguna de las fechas.
			SelHotel.disabled = false;
		}
	}
	ajax.open("GET", xxx+".php?fechaIni=" + encodeURIComponent(fechaIni) + "&fechaFin=" + encodeURIComponent(fechaFin) + "&congresoId=" +  encodeURIComponent(zzz) ,true);
	ajax.send(null);
	return false;
}

function buscar_hoteles(xxx, yyy, zzz)
{
	var fechaIni = document.getElementById('campoini_' + yyy).value;
	var fechaFin = document.getElementById('campofin_' + yyy).value;
	var ajax = xmlhttp();
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			//Mostramos el mensaje de Cargando Hoteles con Habitaciones disponibles
			document.getElementById ('Cargando_' + yyy).style.display = "inline";
			document.getElementById ('Cargando_' + yyy).innerHTML = text_cargando_hoteles + "<img src='../images/geyseco_loading.gif' alg='Cargando Hoteles...' />";
		}
		if(ajax.readyState == 4)
		{
			var elementos;
			var info=ajax.responseText;
			valor = info.split("-");
			for (elementos in valor)
			{					
				campo = valor[elementos].split(":");
				if (campo[1]=='1')
					document.getElementById(campo[0] + "_" + yyy).style.display = "";
				else
					document.getElementById(campo[0] + "_" + yyy).style.display = "none";
			}
			//Desactivamos el mensaje de Cargando Hoteles con habitaciones disponibles
			document.getElementById('Cargando_' + yyy).style.display = "none";
			document.getElementById('Cargando_' + yyy).innerHTML = "";
			//Desactivamos también el botón de busqueda.
			document.getElementById('boton_' + yyy).style.display = "none";
		}
	}
	ajax.open("GET", xxx+".php?fechaIni=" + encodeURIComponent(fechaIni) + "&fechaFin=" + encodeURIComponent(fechaFin) + "&congresoId=" +  encodeURIComponent(zzz),true);
	ajax.send(null);
	return false;
}
function buscar_hoteles_insc(xxx, yyy, zzz)
{
	var fechaIni = document.getElementById('campoini_' + yyy).value;
	var fechaFin = document.getElementById('campofin_' + yyy).value;
	var SelHotel = document.getElementById('hoteles');
	var ajax = xmlhttp();
	var cadena_id = "habitacionhotel_";
	var reserva_id, NombreHotel, TipoHabitacion, Precio;
	var Memoria=false;
	
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			//Mostramos el mensaje de Cargando Hoteles con Habitaciones disponibles
			document.getElementById ('Cargando_' + yyy).style.display = "inline";
			document.getElementById ('Cargando_' + yyy).innerHTML = text_cargando_hoteles + "<img src='../images/geyseco_loading.gif' alg='Cargando Hoteles...' />";
		}
		if(ajax.readyState == 4)
		{
			SelHotel.length = 0;
			var elOptNew = document.createElement('option');
			elOptNew.text = 'Seleccione un hotel';
			elOptNew.value = '';
			elOptNew.selected = true;
			try 
			{
				SelHotel.add(elOptNew, null); // Segun el STANDARD de W3C, no funciona con IE
			}
			catch(ex) 
			{
				SelHotel.add(elOptNew); // IE only
			}
			var elementos, indices;
			var info=ajax.responseText;
			valor = info.split("*");
			for (elementos in valor)
			{					
				campos = valor[elementos].split("-");
				for (indices in campos)
				{
					campo = campos[indices].split(":");
					if (campo[0].indexOf('habitacionhotel_') != -1)
					{	
						reserva_id = campo[0].substring(cadena_id.length);
						if (campo[1] == 1)
							Memoria = true;
						else
							Memoria = false;
					}
					if (Memoria == true)
					{
						if  (campo[0].indexOf('NombreHotel')!= -1)
							NombreHotel = campo[1];
						if  (campo[0].indexOf('TipoHabitacion')!= -1)
							TipoHabitacion = campo[1];
						if  (campo[0].indexOf('Precio')!= -1)
							Precio = campo[1];
					}
				}
				if (Memoria == true)
				{
					var elOptNew = document.createElement('option');
					elOptNew.text = NombreHotel+" "+TipoHabitacion+" "+Precio;
					elOptNew.value = reserva_id;
					try 
					{
						SelHotel.add(elOptNew, null); // Segun el STANDARD de W3C, no funciona con IE
					}
					catch(ex) 
					{
						SelHotel.add(elOptNew); // IE only
					}
				}
			}
			//Desactivamos el mensaje de Cargando Hoteles con habitaciones disponibles
			document.getElementById('Cargando_' + yyy).style.display = "none";
			document.getElementById('Cargando_' + yyy).innerHTML = "";
			//Desactivamos también el botón de busqueda.
			document.getElementById('boton_' + yyy).style.display = "none";
			//Habilitamos por último el COMBOBOX deshabilitado al haber cambiado alguna de las fechas.
			SelHotel.disabled = false;
		}
	}
	ajax.open("GET", xxx+".php?fechaIni=" + encodeURIComponent(fechaIni) + "&fechaFin=" + encodeURIComponent(fechaFin) + "&congresoId=" +  encodeURIComponent(zzz) ,true);
	ajax.send(null);
	return false;
}

//Lanzar POPUP

function abrir_popup(popup,target,xx,yy){
	window.open(popup,target, 'width='+xx+',height='+yy); 
}

// Terminar poster
function terminar_poster(id,mensaje){
	var entrar = confirm(mensaje);
	if ( entrar ) window.location='index.php?go=poster&posterfin='+id;
}

// Funciones generales de cortinas
function abre_cortina(){
document.getElementById('cortina').style.display="";
document.getElementById('mensaje').style.display="";
}
function cierra_cortina(){
document.getElementById('cortina').style.display="none";
document.getElementById('mensaje').style.display="none";
}

// SEGUNDA CORTINA
function abre_cortina2(){
document.getElementById('cortina2').style.display="";
document.getElementById('mensaje2').style.display="";
}
function cierra_cortina2(){
document.getElementById('cortina2').style.display="none";
document.getElementById('mensaje2').style.display="none";
}



function actualiza_poster(xxx){
	window.location='index.php?go=poster&codigo='+xxx;
}



function editar_imagen(yyy){
abre_cortina();
mensaje.location='vista_foto.php?codigo='+yyy;
}

function vista_evaluar(xxx){
abre_cortina();
mensaje.location='vista_evaluar.php?com_ver='+xxx;
}
// Redireccionamientos vista

function vista_previa(xxx){
abre_cortina();
mensaje.location='vista_previa.php?com_ver='+xxx;
}

function vista_presentacion(xxx){
abre_cortina();
mensaje.location='vista_presentacion.php?codigo='+xxx;
}

function vista_previa_comunicacion(xxx){
abre_cortina();
mensaje.location='vista_previa.php?muestra=com_ver&com_ver='+xxx;
}

function vista_previa_comunicacion_epi(xxx){
abre_cortina();
mensaje.location='vista_previa.php?muestra=com_ver_epi&com_ver='+xxx;
}

function vista_previa_boletin(xxx){
abre_cortina();
mensaje.location='vista_previa.php?muestra=boletin_ver&boletin_ver='+xxx;
}

function vista_previa_poster(xxx){
abre_cortina();
mensaje.location='vista_previa.php?muestra=poster&poster_ver='+xxx;
}
function vista_previa_tabla(xxx){
abre_cortina();
mensaje.location='vista_previa.php?muestra=tabla&com_ver='+xxx;
}

function vista_previa_foto(xxx,yyy){
abre_cortina();
mensaje.location='vista_previa.php?muestra=foto&archivo='+xxx+'&congreso='+yyy;
}
function vista_previa_video(xxx){
abre_cortina();
mensaje.location='vista_previa.php?muestra=video&archivo='+xxx;
}
function vista_previa_foto2(xxx){
abre_cortina2();
mensaje2.location='vista_previa2.php?muestra=foto&archivo='+xxx;
}
function vista_previa_video2(xxx){
abre_cortina2();
mensaje2.location='vista_previa2.php?muestra=video&archivo='+xxx;
}


// Redireccionamientos cambiar/eliminar

function elimina_previo(id,mensaje){
	var entrar = confirm(mensaje);
	if ( entrar ) window.location='index.php?go=inscripcion&outprevio='+id;
}


function cambia_presentador(xxx,mensaje){
	var entrar = confirm(mensaje);
	if ((xxx.checked==true)&&(entrar)){
		window.location='index.php?go=comunicacion&paso=4&new_pre='+xxx.value;
	
	}
}

function elimina_autor(id,pos,mensaje){
	var entrar = confirm(mensaje);
	if ( entrar ) window.location='index.php?go=comunicacion&paso=4&autor_out='+id+'&pos='+pos;
}




// Comprobacionnes

function enviarformulario(xxx,paso,alerta)
{
	if (xxx>0){
  		window.location='index.php?go=inscripcion&paso='+paso;
	}else{
		alert(alerta);
	}
}
function enviarformulario2(xxx,yyy,paso,alerta1,alerta2)
{
	if ((xxx>0)&&(yyy>0))
	{
		window.location='index.php?go=inscripcion&paso='+paso;
	}else{
		if (xxx>0)
		{
			alert(alerta2);
		}else{
			alert(alerta1);
		}
	}
}


function validarCuota(xxx,y) {
	doc=xxx;
	for ( var i = 0; i < doc.cuota.length; i++ ) {
	alert(doc.cuota[i].value);
    	if (doc.cuota[i].checked){
      		return true;
			break;
      	}
    }
	alert ("debes escoger una cuota");
	return false;
}

function comprueba_fecha(fechainicio, fechafinal)
{
	
	inicio=document.getElementById(fechainicio).value;
	final=document.getElementById(fechafinal).value;
	  
	if (inicio==""){
		alert("Debes poner una fecha de entrada");
		document.getElementById(fechainicio).focus;
		return false;
	}
	if (final==""){
		alert("Debes poner una fecha de salida");
		document.getElementById(fechafinal).focus;
		return false;
	}
	//alert(inicio+" "+final);
	dateini=inicio.split("/");
	datefin=final.split("/");
	fechaini=new Date();
	//alert ("inicio dia:"+sincero(dateini[0])+" "+((sincero(dateini[1]))-1)+" "+parseInt(dateini[2]));
	fechaini.setYear(parseInt(dateini[2]));
	fechaini.setMonth(((sincero(dateini[1]))-1));
	fechaini.setDate(sincero(dateini[0]));
	//alert (fechaini);
	fechafin=new Date();
	fechafin.setYear(parseInt(datefin[2]));
	fechafin.setMonth(((sincero(datefin[1]))-1));
	fechafin.setDate(sincero(datefin[0]));
	fechahoy=new Date();
	//fechafin.setFullYear(parseInt(datefin[2]),((sincero(datefin[1]))-1),sincero(datefin[0]));
	//alert (fechaini+" "+fechafin);
	
	if(fechaini>=fechafin)
	{
		alert(inicio+" "+final+"la fecha de salida tiene que ser mayor a la de llegada."+fechaini+" "+fechafin);
		return false;
	}
	else
		return true;
}

function checkOut(xxx){
	
	var f = document.getElementById('inscripcion'); 
 	for( var i = 0; i < f.elements.length; i++ ) 
 	{ 
		var elemento = f.elements[i];
		var previo;
		previo=elemento.name.split("_");
		//pre=previo[0].split("-");
		if (previo[0]==xxx)
   			elemento.checked=false;
 	} 
}
function sincero(string){ 
	var str=""; 
	var i=-1; 
	while(string.charAt(++i)==0); 
	// en "i" esta el indice del primer caracter no igual a cero 

	str=string.substring(i,string.length); 

	return parseInt(str); 
} 

function checkIn(xxx){

	control = new Array (xxx);
	var f = document.getElementById('inscripcion'); 
	
 	for( var i = 0; i < f.elements.length; i++ ) 
 	{ 
		var elemento = f.elements[i];
		var previo;
		var pre;
		
		previo=elemento.name.split("_");
		vio=previo[0];
		if (previo[1]!=null)
		{
			pre=previo[1].split("-");
			if (pre[0]=='ins' || pre[0]=='res')
			{
   				if (elemento.checked)
				{
					//alert( previo[0] ); 
					control[vio]=1;
					if (pre[0]=='res')
					{
						return comprueba_fecha('campoini_'+previo[0],'campofin_'+previo[0]);
					}
				}
			}
		}
 	} 
	final=0;
	for (var h=0; h<control.length; h++)
	{
		if (control[h]!=1)
		{
			final=1;
		}
	}
	if (final!=0)
	{
		alert(text_almenos);
		return false;
	}
	else
	{
	 	return true;
	}
}

// permite pasar seleccionando cuotas extras
function checkIn_ext(xxx){

	control = new Array (xxx);
	var f = document.getElementById('inscripcion'); 
	
 	for( var i = 0; i < f.elements.length; i++ ) 
 	{ 
		var elemento = f.elements[i];
		var previo;
		var pre;
		
			previo=elemento.name.split("_");
			vio=previo[0];
		if (previo[1]!=null){
			pre=previo[1].split("-");
			if (pre[0]=='ins' || pre[0]=='res' || pre[0]=='extra')
			{
   				if (elemento.checked){
					//alert( previo[0] ); 
					control[vio]=1;
					if (pre[0]=='res')
					{
						return comprueba_fecha('campoini_'+previo[0],'campofin_'+previo[0]);
					}
				}
			}
		}
 	} 
	final=0;
	for (var h=0; h<control.length; h++){
		if (control[h]!=1){
		final=1;
		}
	}
	if (final!=0){
		alert(text_almenos);
		return false;
	}else{
	 	return true;
	}
}


// Funciones de mostrar/ocultar
function muestra_sucursal(xxx){
	var elementos=document.getElementsByTagName ('tr');
	//alert (elementos.length);
	for (i = 0; i< elementos.length; i++) {
			att = elementos[i].getAttribute("name");
	
		if (att=="centro_especial"){
			//alert (att);
			if (xxx.value=="new"){	
				elementos[i].style.display="";
			}else{
				elementos[i].style.display ="none";
			}
		}	
	}
}

function muestra_mas(xxx){
	var elementos=document.getElementsByTagName ('tr');
	//alert (elementos.length);
	for (i = 0; i< elementos.length; i++) 
	{
		att = elementos[i].getAttribute("name");
		if (att=="centro_especial")
		{
			if ((xxx.value==1)||(xxx.value==2)||(xxx.value==8))
				elementos[i].style.display="";
			else
				elementos[i].style.display ="none";
		}	
	}
}

function muestra_mas_direccion(xxx,amostrar){
	//alert(amostrar);
	var elementos=document.getElementsByTagName ('tr');
	//alert (elementos.length);
	for (i = 0; i< elementos.length; i++) {
			att = elementos[i].getAttribute("name");
	
		if (att=="centro_especial"){
			//alert (att);
			if ((xxx.value==1)||(xxx.value==2)||(xxx.value==8)){	
				elementos[i].style.display="";
			}else{
				elementos[i].style.display ="none";
			}
		}	
		if (att==amostrar){
			//alert (att);
			if (xxx.value==4){	
				elementos[i].style.display="";
			}else{
				elementos[i].style.display ="none";
			}
		}
		if (att=="centro_especial_domiciliacion"){
			//alert (att);
			if (xxx.value==12){	
				elementos[i].style.display="";
			}else{
				elementos[i].style.display ="none";
			}
		}
	}
}

function muestra_factura(xxx){
	if (xxx.checked==true){
		document.getElementById('muestra_factura').style.display="";
		document.getElementById('confactura').value=1;
	
	
	}else{
		document.getElementById('muestra_factura').style.display="none";
		document.getElementById('confactura').value=0;
		
	
	}
}
function muestra_tipopago(xxx){
	if (xxx.checked==true){
		document.getElementById('tipopago').value=xxx.value;
	
	}
}




//------- VALIDOS SEGUROS

function vista_documento(xxx){
	abre_cortina();
	mensaje.location='vista_previa.php?muestra='+xxx;
}

function activa_botonradio(control_campo,control_valor)
{
	document.getElementById(control_campo).value=control_valor;
}

function elimina_campo(listado,id,mensaje,tabla,modifica){
	var entrar = confirm(mensaje);
	if ( entrar ) {
		window.location='index.php?go='+listado+'&listout='+id+'&tabla='+tabla+'&modifica='+modifica;
	}
}
function elimina_comunicacion(id,mensaje){
	var entrar = confirm(mensaje);
	if ( entrar ) window.location='index.php?go=panel_personal&com_out='+id;
}



function muestra_ext(xxx){
	if (xxx.value==6){
		document.getElementById('campo_extension').style.display="";
	}else{
		document.getElementById('campo_extension').style.display="none";
	}
}

function activa_menu(pe,menu)
{
	if (document.getElementById('concambios').value!=0){
	 	if (confirm('Has hechos cambios en la comunicacion que aun no has guardado, si continuas perderas los cambios')){
			document.getElementById('concambios').value=0;
			document.getElementById(menu_on).style.display="none";
			document.getElementById(pe_on).className="formu_pes_off";
	
			document.getElementById(menu).style.display="";
			document.getElementById(pe).className="formu_pes_on";
			menu_on=menu;
			pe_on=pe;
		}
	}else{
		
		document.getElementById(menu_on).style.display="none";
		document.getElementById(pe_on).className="formu_pes_off";
	
		document.getElementById(menu).style.display="";
		document.getElementById(pe).className="formu_pes_on";
		menu_on=menu;
		pe_on=pe;
	}
}

function verifica_mail(t_mail)
{
	if ((t_mail.lastIndexOf(" ")!=-1) || (t_mail.lastIndexOf("@")==-1) || (t_mail.lastIndexOf(".")<=(t_mail.lastIndexOf("@")+1)) || (t_mail.lastIndexOf(".")==(t_mail.length-1))) return false;
		else return true;
}

function confirmar_poster(formulario,mensaje){
	if (formulario.poster_autorizo.checked==true){
		if (formulario.con_pdf.value!=""){
			return true;
		}else{
			alert("Para poder cerrar el Poster debe antes subirlo en formato PDF.");
			return false;
		}
	}else{
		alert (mensaje);
		formulario.poster_autorizo.focus();
		return false;
	}
	return false;
}

function comprobar_campos(formulario, check)
{
	for (var i=0;i<formulario.elements.length;i++)
	{
		var e = formulario.elements[i],bvar;
		var valor;
		//alert(e.id);
		
		valor=e.id.split("-");
			if (valor[0]=="requerido")
			{
				
				if (e.value=="")
				{
					if ((valor[1]=="Otro")||(valor[1]=="Otra"))
					{
						if (valor[1]=="Otro"){	
							if (formulario.direccion_tipo.value==4)
							{
								alert(valor[1]+": no puede estar vacio");
								e.focus();
								return false;
							}
						}
						if (valor[1]=="Otra"){	
							if (formulario.user_extra.value==4)
							{
								alert("Centro de Trabajo no puede estar vacio");
								e.focus();
								return false;
							}
						}
					}else{
						alert(text_campo+valor[1]+text_vacio);
						if ((e.dato!='textarea')&&(e.type!='hidden')) e.focus();
						return false;
					}
				}
				//alert (e.type);
				if (e.type=="select-one")
				{
					//alert(e.selectedIndex);
					var indice = e.selectedIndex;
					if ((e.options[indice].value =="")||(e.options[indice].value =="0"))
					{
						alert(text_campo+valor[1]+text_vacio);
						return false;
					}
				}
				if (valor[1]=="Email")
				{
					if (!verifica_mail(e.value))
					{
						alert(text_mail);
						e.focus();
						return false;
					}		
				}
			}
		
	
		
		if (e.name=="user_pass_TXT")
		{
			//alert("user_pass_TXT:" + e.value + " / repass:" + formulario.repass.value);
			if (e.value!=formulario.repass.value)
			{
				alert(text_pass);
				if (e.dato!='textarea')
				{
					formulario.repass.value="";
					formulario.repass.focus();
				}
				return false;
			}
		}
	}
	
	//Comprovar tipo de dato
	if (check==1)
	{
		if (!verifica_check(formulario))
		{
			alert(text_mail);
			return false;
		}
	}
	return true;

}

function comprobar_autor(formulario,check)
{
	for (var i=0;i<formulario.elements.length;i++)
	{
	
		var e = formulario.elements[i],bvar;
	
		if (e.id=="user_presentador")
		{
		//alert(e.value);
			if ((e.value=="")||(e.value==0))
			{
				alert(text_campo+" "+text_presentador+" "+text_vacio);
				e.focus();
				return false;			
			}
		}
	}
}

function comprobar_datos(formulario,check)
{
	for (var i=0;i<formulario.elements.length;i++)
	{
	
		var e = formulario.elements[i],bvar;
	
		if (e.id=="user_datos")
		{
		//alert(e.value);
			if ((e.value=="")||(e.value==0))
			{
				alert("Debemos tener al menos una forma de contacto.");
				e.focus();
				return false;			
			}
		}
	}
}
// AJAX BUSCADOR
function xmlhttp()
{
	var xmlhttp;
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp = new XMLHttpRequest();
			}
			catch(e)
			{
				xmlhttp = false;
			}
		}
	}
	if (!xmlhttp) 
		return null;
	else
		return xmlhttp;
}
// ACTIVAR PUNTERO
var offsetfromcursorX=15 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

if (muestra_cursor==1){ // las paginas que lleven cursores deberan asignar valor a la variable muestra_cursor
document.write('<div id="visorpuntero"></div>') //write out tooltip DIV
document.write('<img id="puntero" src="../images/arrow2.gif">') //write out pointer image
}
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["visorpuntero"] : document.getElementById? document.getElementById("visorpuntero") : ""

var pointerobj=document.all? document.all["puntero"] : document.getElementById? document.getElementById("puntero") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip