// JavaScript Document
var modulos='';
var URL = unescape(location.href)	
var xstart = URL.lastIndexOf("/") + 1
var xend = URL.length
var hereName = URL.substring(xstart,xend)
var url2=unescape(hereName)	
var xend2 = url2.lastIndexOf("?")
if (xend2>-1)
	{
	var final=hereName.substring(0,xend2)
	var nom_pagina=final.replace(/.php/,"")
	}
else
	{
	var nom_pagina=hereName.replace(/.php/,"")
	}
function mensajes_front(x,e)
{
	if (x==15){alert("El registro fué procesado con éxito."+'\n'+"Recibirás un email en tu cuenta indicando"+'\n'+"los datos de acceso."+'\n'+"Muchas gracias por registrarte!!!")}
	if (x==16){alert("El email indicado ya existe en nuestros registros.")}
	if (x==3){alert("Te enviamos los datos de acceso a tu cuenta de email")}
	if (x==4){alert("La cuenta de email especificada no es válida")}
	// 5 reservada para login positivo
	if (x==1){alert("Los datos indicados son icorrectos")}
	if (x==7){alert("El archivo a subir  excede el límite permitido.")}
	if (x==8){alert("El mensaje fue enviado con éxito.")}
	if (x==9){alert("No puede enviarle un mensaje a este usuario"+'\n'+"porque el mismo ha bloqueado esta acción.")}
	if (x==10){alert("La solicitud fué enviada con éxito.")}
	if (x==11){alert("La solicitud fué confirmada con éxito.")}
	if (x==12){alert("La operación ya fué realizada.")}
	if (x==13){alert("La/s invitacione/s fueron enviadas correctamente.")}
	if (x==14){alert("La pesona que deseas invitar ya es miembro del grupo indicado.")}
	if (x==17){alert("La operación fué realizada correctamente.")}
	if (x==18){alert("Se enviaron correctamente "+e+" invitaciones.")}
}
function mensajes()
{
var query = window.location.search.substring(1);
if (query=="we345hidq"){alert("Los datos ingresados son incorectos.")}
if (query=="endsessions"){alert("Por favor, Identifíquese.")}
if (query=="nofile"){alert("No se encuentra autorizado para descargar este archivo.")}
if (query=="permiso"){alert("No se encuentra autorizado para acceder a esta sección.")}
if (query=="msjok"){alert("El mensaje fué enviado con éxito,"+'\n'+"en breve nos comunicaremos contigo."+'\n'+"Muchas Gracias!.")}
if (query=="newsok"){alert("Los datos fueron almacenados con éxito,"+'\n'+"en breve empezaras a recibir nuestro Newsletter."+'\n'+"Muchas Gracias!.")}
if (query=="newserror"){alert("El email indicado ya se encuentra,"+'\n'+"habilitado para recibir nuestro Newsletter.")}
if (query=="importok"){alert("El archivo ha sido importado con éxito.")}
if (query=="desok"){alert("El proceso se ejecutó con éxito.")}
}
function tamano()
{
	if(document.form1.lst_tipos.value=="I")
	{
	document.getElementById('tam').style.display=""
	}
	else
	{
	document.getElementById('tam').style.display="none"
	}
	if(document.form1.lst_tipos.value=="A")
		{
		document.getElementById('descrimedia').style.display="none"
		document.getElementById('linkmedia').style.display="none"
		}
	else
		{
		document.getElementById('descrimedia').style.display=""
		document.getElementById('linkmedia').style.display=""
		}
}
function valida_invitar()
{
var elementos = document.form1.elements.length;
var invitados=''
for(i=0; i<elementos-1; i++)
	{
	if(document.form1.elements[i].checked==true)
		{
			if(invitados=='')
				{sep=""}
			else
				{sep="|"}
			invitados=document.form1.elements[i].value+'|'+invitados
		}
	}
if(invitados=='')
	{
	alert("Debes seleccionar a algún amigo a invitar")
	}
else
	{
	document.form1.action="comandos.php?accion=invitaragrupo&pag=rs_grupos.php&invitados="+invitados;
	document.form1.submit()
	}
}
function valida_enviomensaje()
{
var oEditor = FCKeditorAPI.GetInstance('txt_detalle');
valor=oEditor.GetXHTML(true);	
if((valor=="")|(document.form1.txt_asunto.value==""))
	{
	alert("Debes especificar el asunto del mensaje y el detalle del mismo.");
	}
else
	{
	document.form1.action="comandos.php?accion=enviomensaje&pag=rs_mensaje_envio.php";
	document.form1.submit()
	}
}
function valida_import()
{
if ((document.form1.txt_archivo.value==""))
	{
	alert("Debes especificar el archivo a importar.")
	}
else
	{
	var archivo=document.form1.txt_archivo.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & (extension != ".xls"))
		{
			alert("El archivo debe ser tipo excel");
		}
	else	
		{
			document.form1.action="comandos.php?accion=importar&pag=importar.php?importok"
			document.form1.submit()
		}
	}
}
function valida_invitacion()
{
if ((document.form1.txt_archivo.value=="")|(document.form1.lst_grupo.value==0))
	{
	alert("Debes especificar el archivo a importar y grupo al cual vas a invitar.")
	}
else
	{
	var archivo=document.form1.txt_archivo.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & (extension != ".xls"))
		{
			alert("El archivo debe ser tipo excel");
		}
	else	
		{
			document.form1.action="comandos.php?accion=invitaragrupoporemail&pag=invitar.php"
			document.form1.submit()
		}
	}
}
function valida_contacto()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_telefono.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_comentarios.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.submit();
		}
	}
}

function valida_grupo(tipo)
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_descripcion.value==""))
	{
	alert("Todos los datos (*) son obligatorios.")
	}
else
	{	
	if(tipo==1)
		{
		document.form1.action="comandos.php?accion=add_grupos&pag=rs_gruposinvitar.php";
		document.form1.submit();
		}
	else
		{
		document.form1.action="comandos.php?accion=updt_grupos&pag=rs_grupos.php";
		document.form1.submit();
		}
	
	}
}
function valida_amistad()
{
document.form1.action="comandos.php?accion=amistad&pag=rs_viewprofile.php";
document.form1.submit();
}
function valida_registro(x)
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_localidad.value=="")|(document.form1.resultado.value=="")|(document.form1.txt_clave.value=="")|(document.form1.txt_clave1.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		if(document.form1.resultado.value!=x)
			{
			alert("El resultado es incorrecto.")
			}
		else
			{
			q=document.form1.txt_email.value;
			var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
			if(b.test(q)==false)
			{
				alert ("La dirección de e-mail es incorrecta.");
				document.form1.txt_email.focus();
			}
			else
			{
				if((document.form1.txt_clave.value.length<6)|(document.form1.txt_clave1.value.length<6))
					{
					alert("La contraseña debe tener 6 caracteres")
					}
				else
					{
					if(document.form1.txt_clave.value != document.form1.txt_clave1.value)	
						{
						alert("Las contraseñas no coinciden")
						}
					else
						{
						document.form1.action="comandos.php?accion=add_miembros&pag=registro.php";
						document.form1.submit();
						}
					}
			}
		}
	}
}
function edit_profile()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_localidad.value=="")|(document.form1.txt_clave.value=="")|(document.form1.txt_clave1.value==""))
	{
		alert("Todos los datos (*) son obligatorios.")
	}
else
	{	
	var archivo=document.form1.txt_foto.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
			alert("El archivo debe ser una imágen  .jpg o .gif");
		}
	else
		{
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
			{
			alert ("La dirección de e-mail es incorrecta.");
			document.form1.txt_email.focus();
			}
			else
			{
			if((document.form1.txt_clave.value.length<6)|(document.form1.txt_clave1.value.length<6))
					{
					alert("La contraseña debe tener 6 caracteres")
					}
				else
					{
					if(document.form1.txt_clave.value != document.form1.txt_clave1.value)	
						{
						alert("Las contraseñas no coinciden")
						}
					else
						{
						document.form1.action="comandos.php?accion=edit_miembros&pag=rs_editprofile.php";
						document.form1.submit();
						}
					}
			}
		}
	}
}
function valida_login()
{
if ((document.form1.txt_email.value=="")|(document.form1.txt_clave.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.");
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.action="comandos.php?accion=login&pag=login_red.php";
			document.form1.submit();
		}
	}
}
function valida_olvide()
{
if ((document.form1.txt_email.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.");
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.action="comandos.php?accion=olvide&pag=olvide.php";
			document.form1.submit();
		}
	}
}
function valida_inscripcion()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_domicilio.value=="")|(document.form1.txt_localidad.value=="")|(document.form1.txt_telefono.value=="")|(document.form1.txt_email.value==""))
	{
		alert("Todos los datos (*) son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.submit();
		}
	}
}
function valida_socios()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_domicilio.value=="")|(document.form1.txt_localidad.value=="")|(document.form1.txt_provincia.value=="")|(document.form1.txt_cp.value=="")|(document.form1.txt_telefono.value=="")|(document.form1.txt_email.value==""))
	{
		alert("Todos los datos (*) son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.submit();
		}
	}
}
function valida_blocktestins()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_establecimiento.value=="")|(document.form1.txt_marca.value=="")|(document.form1.txt_telefono.value==""))
	{
		alert("Debe indicar su nombre, el establecimiento y un teléfono de contacto.")
	}
else
	{	
		q=document.form1.txt_email.value;
		if(q!="")
		{
			var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
			if(b.test(q)==false)
			{
				alert ("La dirección de e-mail es incorrecta.")
				document.form1.txt_email.focus();
			}
			else
			{
				document.form1.submit();
			}
		}
		else
		{
			document.form1.submit();
		}
	}
}
function valida_recibirnews()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_email.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.submit();
		}
	}
}
function valida_usuarios()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_clave1.value=="")|(document.form1.txt_clave2.value==""))
	{
	alert("Todos los datos son obligatorios.")
	}
else
	{
	if (document.form1.txt_clave1.value != document.form1.txt_clave2.value)
		{
		alert("Las claves no coinciden.")
		document.form1.txt_clave1.focus()
		}
	else
		{
			cant=document.form1.txt_clave1.value.length
			if (cant<6)
				{
				alert("Las claves deben poseer 6 caracteres.")
				}
				else
				{
				q=document.form1.txt_email.value;
				var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
				if(b.test(q)==false)
					{
					alert ("La dirección de email es incorrecta")
					}
				else
					{
					/*var URL = unescape(location.href)	
					var xstart = URL.lastIndexOf("/") + 1
					var xend = URL.length
					var pagina = URL.substring(xstart,xend)
					pag=pagina.replace(/updt=1/, "updt=0")
					pag=pagina.replace(/add=1/, "add=0")
					accion1=pag.lastIndexOf("add")
					accion2=pag.lastIndexOf("updt")
					if (accion1>-1){accion="add"}
					if (accion2>-1){accion="updt"}	*/
						/*recopilo noticias agrgadas*/
					var can = (document.getElementById('lst_incmodulos').length)
					if (can>0)
						{
						for (var g=0; g < can;g++)
							{
							if (modulos!='')
								{sep="@"}
							else
								{sep=""}
							modulos=modulos+sep+document.form1.lst_incmodulos[g].text
							}
						}
					if (document.form1.txt_id.value!="")
						{
						accion="updt"
						id=document.form1.txt_id.value
						busca_duplicado(accion,'usuarios',document.form1.txt_email.value,id)
						}
					else
						{
						accion="add"
						id=document.form1.txt_id.value
						busca_duplicado(accion,'usuarios',document.form1.txt_email.value,id)
						}
					}
				}
		}
	}
}
function updt_usuarios(foco,valores,modulos)
{
a=modulos.split("|")
cant=a.length
for (var g=0; g < cant-1;g++)
	 {	
		var new_option = new Option(a[g], a[g], false, false);
		document.getElementById('lst_incmodulos').options[g] = new_option;	
	 }
valores=valores.replace(/ª/,"'")
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_nombre.value=arr[1]
document.form1.txt_email.value=arr[2]
document.form1.txt_clave1.value=arr[3]
document.form1.txt_clave2.value=arr[3]
}

function valida_novedades()
{
if ((document.form1.txt_titulo.value==""))
	{
	alert("Debe ingresar el Título.")
	}
else
	{
	var archivo=document.form1.txt_imagen.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
			alert("La archivo debe ser una imágen  .jpg o .gif");
		}
	else	
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'novedades',document.form1.txt_titulo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'novedades',document.form1.txt_titulo.value,id)
			}
		}
	}
}
function valida_blocktest()
{
if ((document.form1.txt_titulo.value=="")|(document.form1.txt_fecha.value==""))
	{
	alert("Debe ingresar el Título y la Fecha de publicación de la Noticia.")
	}
else
	{
	var archivo=document.form1.txt_imagen.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
			alert("El archivo debe ser una imágen  .jpg o .gif");
		}
	else	
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'blocktest',document.form1.txt_titulo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'blocktest',document.form1.txt_titulo.value,id)
			}
		}
	}
}	
function valida_prensa()
{
if ((document.form1.txt_titulo.value=="")|(document.form1.txt_fecha.value==""))
	{
	alert("Debe ingresar el Título y la Fecha de publicación de la Nota.")
	}
else
	{
	var archivo=document.form1.txt_imagen.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
			alert("La archivo debe ser una imágen  .jpg o .gif");
		}
	else	
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'prensa',document.form1.txt_titulo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'prensa',document.form1.txt_titulo.value,id)
			}
		}
	}
}	
function valida_encuestas()
{

if ((document.form1.txt_descripcion.value==""))
	{
	alert("Debe ingresar la descripción.")
	document.form1.txt_descripcion.focus();
	}
else	
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'encuestas2',document.form1.txt_descripcion.value,id)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'encuestas2',document.form1.txt_descripcion.value,id)
		}
	}
}
function valida_encuesta_detalle()
{

if ((document.form1.txt_descripcion.value==""))
	{
	alert("Debe ingresar la descripción de la opción.")
	document.form1.txt_descripcion.focus();
	}
else	
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'encuesta_detalles',document.form1.txt_descripcion.value,id)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'encuesta_detalles',document.form1.txt_descripcion.value,id)
		}
	}
}
function valida_eventos()
{

if ((document.form1.txt_nombre.value==""))
	{
	alert("Debe ingresar el nombre del evento.")
	}
else
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'eventos',document.form1.txt_nombre.value,id		)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'eventos',document.form1.txt_nombre.value,id)
		}
		
	}
}
function valida_legislacion()
{

if ((document.form1.txt_titulo.value==""))
	{
	alert("Debe ingresar el título.")
	}
else
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'legislacion',document.form1.txt_titulo.value,id		)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'legislacion',document.form1.txt_titulo.value,id)
		}
		
	}
}
function valida_categoria_links()
{

if ((document.form1.txt_descripcion.value==""))
	{
	alert("Debe ingresar la descripción.")
	document.form1.txt_descripcion.focus();
	}
else	
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'categoria_links',document.form1.txt_descripcion.value,id)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'categoria_links',document.form1.txt_descripcion.value,id)
		}
	}
}
function valida_links()
{

if ((document.form1.txt_descripcion.value=="")|(document.form1.txt_link.value=="")|(document.form1.lst_categoria.value==0))
	{
	alert("Todos los datos son obligatorios.")
	document.form1.txt_descripcion.focus();
	}
else	
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'links',document.form1.txt_link.value,id)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'links',document.form1.txt_link.value,id)
		}
	}
}
function valida_listas()
{

if ((document.form1.txt_descripcion.value==""))
	{
	alert("Todos los datos son obligatorios.")
	document.form1.txt_descripcion.focus();
	}
else	
	{
	if (document.form1.txt_id.value!="")
		{
		accion="updt"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'lista_emails',document.form1.txt_descripcion.value,id)
		}
	else
		{
		accion="add"
		id=document.form1.txt_id.value
		busca_duplicado(accion,'lista_emails',document.form1.txt_descripcion.value,id)
		}
	}
}
function valida_lista_detalle()
{

if ((document.form1.txt_destinatario.value=="")|(document.form1.txt_email.value==""))
	{
	alert("Todos los datos son obligatorios.")
	document.form1.txt_descripcion.focus();
	}
else	
	{
	q=document.form1.txt_email.value;
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
	if(b.test(q)==false)
		{
		alert ("La dirección de email es incorrecta")
		}
	else	
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'lista_detalle',document.form1.txt_email.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'lista_detalle',document.form1.txt_email.value,id)
			}
		}
	}
}
function valida_news(tipo)
{
if ((document.form1.txt_asunto.value=="")|(document.form1.lst_incgrupos.length==0))
	{
	alert("Debe ingresar el asunto del News y al menos un grupo a quien enviarlo.")
	}
else
	{
	/*recopilo noticias agrgadas*/
	var can = (document.getElementById('lst_incnoticias').length)
	var noticias=''
	if (can>0)
		{
		for (var g=0; g < can;g++)
			{
			if (noticias!='')
				{sep="@"}
			else
				{sep=""}
			noticias=noticias+sep+document.form1.lst_incnoticias[g].value
			}
		}
	/*recopilo eventos agrgadas*/
	var can = (document.getElementById('lst_inceventos').length)
	var eventos=''
	if (can>0)
		{
		for (var g=0; g < can;g++)
			{
			if (eventos!='')
				{sep="@"}
			else
				{sep=""}
			eventos=eventos+sep+document.form1.lst_inceventos[g].value
			}
		}
	/*recopilo grupos agrgadas*/
	var can = (document.getElementById('lst_incgrupos').length)
	var grupos=''
	if (can>0)
		{
		for (var g=0; g < can;g++)
			{
			if (grupos!='')
				{sep="@"}
			else
				{sep=""}
			grupos=grupos+sep+document.form1.lst_incgrupos[g].value
			}
		}
		
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
		    //busca_duplicado(accion,'newsletters',document.form1.txt_asunto.value,id)
			document.form1.action="comandos.php?accion=updt_newsletters&pag=newsletters.php?tipo="+tipo+"&noticias="+noticias+"&eventos="+eventos+"&grupos="+grupos+"&id="+id	;
			document.form1.submit();
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			//busca_duplicado(accion,'newsletters',document.form1.txt_asunto.value,id)
			document.form1.action="comandos.php?accion=add_newsletters&pag=newsletters.php?tipo="+tipo+"&noticias="+noticias+"&eventos="+eventos+"&grupos="+grupos;
			document.form1.submit();
			}
	}

}
function valida_banners()
{
if ((document.form1.txt_imagen.value=="")|(document.form1.txt_link.value==""))
	{
	alert("Todos los datos son obligatorios.")
	}
else
	{
	var archivo=document.form1.txt_imagen.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
			alert("La archivo debe ser una imágen  .jpg o .gif");
		}
	else	
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'new_banners',document.form1.lst_tipo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'new_banners',document.form1.lst_tipo.value,id)
			}
		}
	}
}
function valida_grlbanners()
{
if(document.form1.txt_guardado.value==""){document.form1.txt_guardado.value=document.form1.txt_imagen.value}
if ((document.form1.txt_guardado.value=="")|(document.form1.txt_link.value==""))
	{
	alert("Todos los datos son obligatorios.")
	}
else
	{
	var archivo=document.form1.txt_imagen.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif")) & ((extension != ".swf"))  )
		{
			alert("La archivo debe ser una imágen  .jpg o .gif");
		}
	else	
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'banners',document.form1.lst_tipo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'banners',document.form1.lst_tipo.value,id)
			}
		}
	}
}
function valida_bien()
{
accion="updt"
busca_duplicado(accion,'bienvenida','d',0)
}
function valida_comision()
{
accion="updt"
busca_duplicado(accion,'comision','d',0)
}
function valida_reglamento()
{
accion="updt"
busca_duplicado(accion,'reglamento','d',0)
}
function valida_ganadores()
{
accion="updt"
busca_duplicado(accion,'ganadores','d',0)
}
function valida_delegados()
{
accion="updt"
busca_duplicado(accion,'delegados','d',0)
}
function valida_galeria()
{
if(document.form1.txt_guardado.value==""){document.form1.txt_guardado.value=document.form1.txt_imagen.value}
if ((document.form1.txt_titulo.value=="")|(document.form1.txt_guardado.value==""))
	{
	alert("Todos los datos son obligatorios.")
	}
else
	{
	var archivo=document.form1.txt_guardado.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg") & (extension != ".gif")))
		{
			alert("La extensión del archivo debe ser tipo jpg o gif.");
			document.form1.txt_guardado.value=""
		}
	else
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'galeria',document.form1.txt_titulo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'galeria',document.form1.txt_titulo.value,id)
			}
		}
	}
}
function valida_galeria_items()
{
if(document.form1.txt_guardado.value==""){document.form1.txt_guardado.value=document.form1.txt_imagen.value}
if ((document.form1.txt_titulo.value=="")|(document.form1.txt_guardado.value==""))
	{
	alert("Todos los datos son obligatorios.")
	}
else
	{
	var archivo=document.form1.txt_guardado.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg") & (extension != ".gif")))
		{
			alert("La extensión del archivo debe ser tipo jpg o gif.");
			document.form1.txt_guardado.value=""
		}
	else
		{
		if (document.form1.txt_id.value!="")
			{
			accion="updt"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'galeria_items',document.form1.txt_titulo.value,id)
			}
		else
			{
			accion="add"
			id=document.form1.txt_id.value
			busca_duplicado(accion,'galeria_items',document.form1.txt_titulo.value,id)
			}
		}
	}
}
function updt_galeria(foco,valores)
{
mue_form(foco)
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_titulo.value=arr[1]
document.form1.txt_guardado.value=arr[2]
}
function updt_galeria_items(foco,valores)
{
mue_form(foco)
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_titulo.value=arr[1]
document.form1.txt_guardado.value=arr[2]
}
function updt_grlbanners(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_guardado.value=arr[1]
document.form1.txt_link.value=arr[2]
var can = (document.getElementById('lst_pagina').length)
opt=''
if (can>0)
	{
	for (var g=0; g < can;g++)
		 {
		 var tex=document.form1.lst_pagina[g].text;
		   if (arr[3]==tex)
		 	{
				opt=g}
		 }
	}

if (opt)
	{
	var selObj = document.getElementById('lst_pagina');
	selObj.options[opt].selected =opt
	}
if(arr[4]==1)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[0].selected =1
	}
if(arr[4]==2)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[1].selected =2
	}
if(arr[4]==3)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[2].selected =3
	}

}
function updt_novedades(foco,valores)
{
mue_form(foco)
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_titulo.value=arr[1]
if(document.form1.txt_fecha){document.form1.txt_fecha.value=arr[2]}
copete=arr[3]
detalle=arr[4]
document.form1.txt_copete.value=copete.replace(/<br>/g,"\r")
var oEditor = FCKeditorAPI.GetInstance('txt_detalle');
oEditor.SetHTML (detalle, true);
if(document.form1.txt_finaliza){document.form1.txt_finaliza.value=arr[5]}
if(arr[6]>0)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[arr[6]-1].selected =arr[6];	
	}
}
function updt_blocktest(foco,valores)
{
mue_form(foco)
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_titulo.value=arr[1]
document.form1.txt_fecha.value=arr[2]
detalle=arr[3]
var oEditor = FCKeditorAPI.GetInstance('txt_detalle');
oEditor.SetHTML (detalle, true);
document.form1.txt_finaliza.value=arr[4]
document.form1.txt_organiza.value=arr[5]
}
function updt_prensa(foco,valores)
{
mue_form(foco)
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_titulo.value=arr[1]
document.form1.txt_fecha.value=arr[2]
copete=arr[3]
detalle=arr[4]
document.form1.txt_copete.value=copete.replace(/<br>/g,"\r")
var oEditor = FCKeditorAPI.GetInstance('txt_detalle');
oEditor.SetHTML (detalle, true);

}
function updt_encuestas(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_descripcion.value=arr[1]
}
function updt_encuesta_detalles(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_descripcion.value=arr[1]
}
function updt_eventos(foco,valores)
{
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_nombre.value=arr[1]
var oEditor = FCKeditorAPI.GetInstance('txt_descripcion');
oEditor.SetHTML (arr[2], true);
}
function updt_legislacion(foco,valores)
{
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_titulo.value=arr[1]
var oEditor = FCKeditorAPI.GetInstance('txt_descripcion');
oEditor.SetHTML (arr[2], true);
}
function updt_categoria_links(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_descripcion.value=arr[1]
}
function updt_links(foco,valores)
{
valores=valores.replace(/ª/g,"'")
valores=valores.replace(/ç/g,'"')
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_descripcion.value=arr[1]
document.form1.txt_link.value=arr[2]
var can = (document.getElementById('lst_categoria').length)
opt=''
if (can>0)
	{
	for (var g=0; g < can;g++)
		 {
		 var tex=document.form1.lst_categoria[g].text;
		   if (arr[3]==tex)
		 	{opt=g}
		 }
	}

if (opt)
	{
	var selObj = document.getElementById('lst_categoria');
	selObj.options[opt].selected =opt
	}
}
function updt_listas(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_descripcion.value=arr[1]
}
function updt_lista_detalle(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_destinatario.value=arr[1]
document.form1.txt_email.value=arr[2]
}
function updt_news(id,tipo)
{
window.open("newsletters.php?id="+id+"&tipo="+tipo, "_parent")
}
function updt_banners(foco,valores)
{
mue_form(foco)
arr=valores.split("|")
document.form1.txt_id.value=arr[0]
document.form1.txt_link.value=arr[2]
if(arr[3]==1)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[0].selected =1
	}
if(arr[3]==2)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[1].selected =2
	}
if(arr[3]==3)
	{
	var selObj = document.getElementById('lst_tipo');
	selObj.options[2].selected =3
	}

}
function ocu_form()
{
document.getElementById('alta_modi').style.display="none"
document.getElementById('marco').style.display="none"
}

function mue_form(foco)
{
document.getElementById('alta_modi').style.display="block"
document.getElementById(foco).focus()
document.getElementById('marco').style.display="none"
var foto=document.getElementById('tdimg')
if (foto){document.getElementById('tdimg').innerHTML=""}
if (nom_pagina=="media"){document.getElementById('tam').style.display="none"}

if (nom_pagina=='novedades')
	{
	var oEditor = FCKeditorAPI.GetInstance('txt_detalle');
	oEditor.SetHTML ('', true);
	document.forms[0].reset()
	}
	else
	{
	if (nom_pagina=='eventos')
		{
		var oEditor = FCKeditorAPI.GetInstance('txt_descripcion');
		oEditor.SetHTML ('', true);
		}
	else
		{
		if (nom_pagina=='legislacion')
			{
			var oEditor = FCKeditorAPI.GetInstance('txt_descripcion');
		oEditor.SetHTML ('', true);	
			}
		else
			{
			if (nom_pagina=='institutos')
				{
				tinyMCE.getInstanceById('txt_descripcion').setHTML("")
				document.form1.txt_nombre.value=""	
				}
			else
				{
				document.forms[0].reset()
				}
			}
		
		}
		
	}

}
function mue_form2(tipo)
{
window.open("newsletters.php?id=0&tipo="+tipo, "_parent")
}
function alta_news(val)
{
if (val>-1)
	{
	mue_form('txt_asunto')
	if(val>0){document.form1.txt_id.value=val}
	}
}
function asignaclase()
{

//if (nom_pagina=='novedades') {document.getElementById('novedades').className = 'current'}
if (nom_pagina=='encuestas') {document.getElementById('encuestas').className = 'current'}
if (nom_pagina=='eventos') {document.getElementById('eventos').className = 'current'}
if (nom_pagina=='links') {document.getElementById('links').className = 'current'}
if (nom_pagina=='newsletters') {document.getElementById('newsletters').className = 'current'}
}
function validausu()
{
if ((document.form_usuario.usuario.value=="" )|(document.form_usuario.clave.value==""))
	{
	alert("Debes ingresar el Usuario y la Clave.")
	document.form_usuario.usuario.focus()
	}
else
	{
	document.form_usuario.submit()
	}
}
function intro() 
{
	var x=event.keyCode
	if (x==13)  
	{
	validausu();
	return true;
	}
}
function intro_forms() 
{
	var x=event.keyCode
	if (x==13)  
	{
	if (nom_pagina=="clientes"){valida_clientes()}
	if (nom_pagina=="directores"){valida_clientes()}
	if (nom_pagina=="peliculas"){valida_peliculas()}
	if (nom_pagina=="media"){valida_media()}
	if (nom_pagina=="novedades"){valida_novedades()}
	return true;
	}
}
function intro_busca(pagina) 
{
	var x=event.keyCode
	if (x==13)  
	{
	buscar(pagina);
	return true;
	}
}
function eliminar(cod,tabla,campo,archivo)
{
var eli = confirm("¿Deseas eliminar el Registro?");
if (eli== true)
{
var URL = unescape(location.href)	
var xstart = URL.lastIndexOf("/") + 1
var xend = URL.length
var pagina = URL.substring(xstart,xend)
pag=pagina.replace(/&/gi,"|")
sql="delete from "+tabla+" where "+campo+"="+cod
nav=pag.lastIndexOf("totalRows_"+nom_pagina+"=")
caracteres=nom_pagina.length
if (nav>-1)
	{
	numero=pag.substring(nav+11+caracteres,nav+10+caracteres+3)
	final=parseInt(numero)-1
	va="totalRows_"+nom_pagina+"="+numero
	pag=pag.replace(va,"totalRows_"+nom_pagina+"="+final)
	}
window.open('comandos.php?accion=delete&sql='+sql+'&file='+archivo+'&pag='+pag+'&id='+cod , '_parent')
}
}
function eliminar_front(cod,tabla,campo,archivo)
{
var eli = confirm("¿Deseas eliminar el Registro?");
if (eli== true)
{
var URL = unescape(location.href)	
var xstart = URL.lastIndexOf("/") + 1
var xend = URL.length
var pagina = URL.substring(xstart,xend)
pag=pagina.replace(/&/gi,"|")
sql="delete from "+tabla+" where "+campo+"="+cod
nav=pag.lastIndexOf("totalRows_"+nom_pagina+"=")
caracteres=nom_pagina.length
if (nav>-1)
	{
	numero=pag.substring(nav+11+caracteres,nav+10+caracteres+3)
	final=parseInt(numero)-1
	va="totalRows_"+nom_pagina+"="+numero
	pag=pag.replace(va,"totalRows_"+nom_pagina+"="+final)
	}
window.open('comandos.php?accion=delete&sql='+sql+'&file='+archivo+'&pag='+pag , '_parent')
}
}
function buscar(pagina)
{
if(document.getElementById('txt_busca').value=="")
{
alert("Tienes que ingresar el dato a buscar.")
document.getElementById('txt_busca').focus()
}
else
{
window.open(pagina+'?valor='+document.getElementById('txt_busca').value , '_parent')
}
}
function oculta_submen()
{
document.getElementById('marco').style.display="none"
}
function muestra_submen()
{
document.getElementById('marco').style.display=""
}
function orden(op,campo)
{
obj = document.getElementById(op);
var top=obj.offsetTop 
var left=obj.offsetParent.offsetLeft 
var query = window.location.search.substring(1);
var esta=document.getElementById('alta_modi').style.display
tt=document.getElementById('tbl').offsetTop
ll=document.getElementById('tbl').offsetLeft
var navegador = navigator.appName 
if (navegador == "Microsoft Internet Explorer") 
{
document.getElementById('marco').style.left=left+255+ll+'px'
document.getElementById('marco').style.top=tt+200+'px'
}
else 
{
document.getElementById('marco').style.left=left+ll+'px'
document.getElementById('marco').style.top=tt+30+'px'
}
	

muestra_submen()
col="<div><div id=item><ul><li><a href=javascript:ira('asc','"+campo+"') onclick=oculta_submen()>Ascending Order</a></li></ul></div><div id=item2><ul><li><a href=javascript:ira('desc','"+campo+"')  onclick=oculta_submen()>Descending Order</a></li></ul></div>"
document.getElementById('interior').innerHTML=col
}
function ira(orden,campo)
{
var URL = unescape(location.href)	
var xstart = URL.lastIndexOf("/") + 1
var xend = URL.length
var pagina = URL.substring(xstart,xend)
var query1=pagina.lastIndexOf("?")	
if (query1<0)
	{pag=pagina+"?ord="+orden+"&campo="+campo}
else
	{
	var inicio=pagina.lastIndexOf("?ord=")	
	if (inicio>0)
		{
			if (orden=='asc') {pag=pagina.replace(/ord=desc/, "ord=asc")}
	    	if (orden=='desc') {pag=pagina.replace(/ord=asc/, "ord=desc")}
		}
	else
		{
		var inicio=pagina.lastIndexOf("&ord=")	
			if (inicio>0)
			{
				if (orden=='asc') {pag=pagina.replace(/ord=desc/, "ord=asc")}
	    		if (orden=='desc') {pag=pagina.replace(/ord=asc/, "ord=desc")}
			}
			else
			{		
			pag=pagina+"&ord="+orden+"&campo="+campo
			}
		}
	}
var inicio=pag.lastIndexOf("campo=")	
if (inicio>0){pag=pag.substring(0,inicio-1)+"&campo="+campo}
window.open(pag, '_parent')
}
function control_errores(x,valores)
{
if (x>0){document.getElementById('alta_modi').style.display=""}	
if (x==1)
	{
	val=valores.split("|")
	document.form1.txt_descripcion.value=val[1]
	document.form1.txt_id.value=val[0]
	alert("La imágen no debe superar los "+val[2]+".")
	}
if (x==2)
	{
	alert("El email fué enviado con éxito.")
	}
}
function duplicado_cmd() { 
	if (http.readyState == 4) { 
       if (http.status == 200) { 
          if (http.responseText.indexOf('invalid') == -1) {
			 var a=http.responseText
			 if (a<1)
			 {
				var URL = unescape(location.href)	
				var xstart = URL.lastIndexOf("/") + 1
				var xend = URL.length
				var pagina = URL.substring(xstart,xend)
				pag=pagina.replace(/updt=1/, "updt=0")
				pag=pagina.replace(/add=1/, "add=0")
				accion1=pag.lastIndexOf("add")
				accion2=pag.lastIndexOf("updt")
				if (accion1>-1){accion="add"}
				if (accion2>-1){accion="updt"}
				pag=pag.replace(/&/gi,"|")
				//alert("comandos.php?accion="+accion+"_clientes&pag="+pag)
				nav=pag.lastIndexOf("totalRows_"+nom_pagina+"=")
				caracteres=nom_pagina.length
				if ((nav>-1) && (document.form1.txt_id.value==""))
					{
						numero=pag.substring(nav+11+caracteres,nav+10+caracteres+3)
						final=parseInt(numero)+1
						va="totalRows_"+nom_pagina+"="+numero
						pag=pag.replace(va,"totalRows_"+nom_pagina+"="+final)
					}
					
					if (document.form1.txt_id.value!="")
						{
						accion="updt_"+nom_pagina+"&id="+document.form1.txt_id.value
						}
						else
						{
						accion="add_"+nom_pagina
						}
					//alert(accion)
					//alert("comandos.php?accion="+accion+"&pag="+pag+"&modulos="+modulos)
					document.form1.action="comandos.php?accion="+accion+"&pag="+pag+"&modulos="+modulos
					document.form1.submit();
			 }
			 else
			 {
				alert("Ya existe un registro similar.") 
			 }
			 enProceso = false;
			}
			
       }
    }
}
function busca_duplicado(comando,modulo,valor,id)
{
if (!enProceso && http) 
	{
   	   var url = "includes/duplicado.php?comando="+comando+"&modulo="+modulo+"&valor="+valor+"&id="+id
	   http.open("GET", url, true);
	   http.onreadystatechange = duplicado_cmd;
       enProceso = true;
       http.send(null);
    }
}

/***ajax*///
function getHTTPObject()
{
 var xmlhttp = null;
 //Internet Explorer
 try
 {
  xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
 }
 catch (e)
 {
  try
  {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  catch (e)
  {
   xmlhttp = null;
  }
 }

 //Mozilla y Safari

 if ((xmlhttp == null) && (typeof XMLHttpRequest != 'undefined'))
 {
  try
  {
   xmlhttp = new XMLHttpRequest();
  }
  catch (e)
  {
   xmlhttp = null;
  }
 }
 return xmlhttp;
}
var enProceso = false; // lo usamos para ver si hay un proceso activo
var http =  getHTTPObject(); // Creamos el objeto XMLHttpRequest
function solonumeros() {
if (event.keyCode < 48  || event.keyCode >  57)  {
	if (event.keyCode != 44 ){
	event.keyCode = 0;
	return true;
}}
}
function formateo(control)
{
var val=document.getElementById(control).value
//var val=document.form2.importe.value 
var val=val.replace(".","") 
var val=val.replace(".","") 
var val=val.replace(".","") 
var cant=val.length 
var esta=val.search(",") 
if (esta<0){ 
if (cant==0) document.getElementById(control).value='' 
if (cant==4) document.getElementById(control).value=val.substr(0,1) + "." + val.substr(1,15) 
if (cant==5) document.getElementById(control).value=val.substr(0,2) + "." + val.substr(2,15) 
if (cant==6) document.getElementById(control).value=val.substr(0,3) + "." + val.substr(3,15) 
if (cant==7) document.getElementById(control).value=val.substr(0,1) + "." + val.substr(1,3) + "." + val.substr(4,15) 
if (cant==8) document.getElementById(control).value=val.substr(0,2) + "." + val.substr(2,3) + "." + val.substr(5,15) 
}
}
function notifica(id,presu)
{
var eli = confirm("Usted esta por enviar un email al cliente "+"\n"+"con la dirección web para acceder a visualizar el Presupuesto."+"\n"+"¿Desea hacerlo?");
if (eli== true)	
	{
	 window.open("presupuestonotifica.php?id="+id+"&presu="+presu , "_parent")
	}
}
/*funciones de agrgados de combos news*/
function addd(lst,lstinc)
{
var m=document.form1[lst].value
if (m==0){
	alert("Debe selecionar una noticia.");}
else{

	var can = (document.getElementById(lstinc).length)
	var indice1 = document.form1[lst].selectedIndex; 
	var texto=document.form1[lst][indice1].text;
	var error =0
		if (can>0)
			{
			for (var g=0; g < can;g++)
				 {
				var tex=document.form1[lstinc][g].text;
				var valor=document.form1[lstinc][g].value;
				if ((texto==tex))
					{
					error=1
					break;
					}
				else
					{
					error=0
					}
				}	
			
			}
		else
			{
			error=0
			}
		
	
		if (error==0)
			{		
			var valor = document.form1[lst].value;
			var new_option = new Option(texto, valor, false, false);
			document.getElementById(lstinc).options[can] = new_option;
			var selObj = document.getElementById(lst);
			selObj.options[0].selected = 1
			}
		else
			{
			if(m<100000)
				{
				alert("El Item que desea agregar ya existe!.");
				}
			var selObj = document.getElementById(lst);
			selObj.options[0].selected = 1
			}
	}
}
function quit(lst,lstinc)
{
var indi =  document.form1[lstinc].selectedIndex; 
if (indi==-1){
alert("No hay ningún item seleccionado!.")}
else
{
document.getElementById(lstinc).options[indi] = null;
var selObj = document.getElementById(lst);
selObj.options[0].selected = 1
}
}
function enviar_news(id,tipo,exclusivo)
{
var eli = confirm("¿Desea realizar el envío?");
if (eli== true)	
	{
	if(exclusivo)
		{
		window.open("news_envio_exclusivo.php?id="+id+"&tipo="+tipo, "_parent")
		}
	else
		{
		window.open("news_envio.php?id="+id+"&tipo="+tipo, "_parent")	
		}
	}
}
function exito(m)
{
	if(m==1)
	{
		alert("El News fué enviado con éxito")
	}
}
function save_cancel(x)
{
	if (x==1)
	{
	document.getElementById('save').style.display=""
	document.getElementById('cancel').style.display=""
	document.getElementById('edit').style.display="none"
	document.getElementById('edit1').style.display="none"
	document.getElementById('edit2').style.display=""
	}
	else
	{
	document.getElementById('save').style.display="none"
	document.getElementById('cancel').style.display="none"
	document.getElementById('edit').style.display=""
	document.getElementById('edit1').style.display=""
	document.getElementById('edit2').style.display="none"
	}
}
function vota(cant,enc)
{
var cod=0
	for (var g=0; g < cant;g++) {
		 if (document.encuestas.voto[g].checked==true)
			{var cod=document.encuestas.voto[g].value}
	}
	if (cod==0){
		alert("Tienes que selccionar una opción válida!.")}
	else
	{
	for (var u=0; u < cant;u++) {
		 var ss="td"+(u+1)
		 document.all[ss].style.display="none"
		 var ss2="td2"+(u+1)
		 document.all[ss2].style.display=""
		 }
		 if(document.getElementById('pregunta'))
		 	{
			 var ss3='pregunta'
			  document.getElementById('pregunta').style.display="none"
			}
		if(document.getElementById('respu'))
			{
			 var ss4='respu'
			  document.getElementById('respu').style.display=""
			}
		if(document.getElementById('boton'))
			{
			 var ss5='boton'
			 document.getElementById('boton').style.display="none"
			}
		if (!enProceso && http) {
		   var url = 'duplicado.php?modulo=encuestas&cod='+cod+'&enc='+enc
		   http.open("GET", url, true);
		   http.onreadystatechange = handleHttpResponse4;
		   enProceso = true;
		   http.send(null);
	 }
	 }

}
function handleHttpResponse4() { 
    if (http.readyState == 4) { 
       if (http.status == 200) { 
          if (http.responseText.indexOf('invalid') == -1) {
		  var qbusco = http.responseText.split("-");
		  for (var m=0; m < qbusco.length;m++) {
		 	var obj='resultado'+(m+1)
			document.encuestas[obj].value=qbusco[m]
			}
					
		  /*document.getElementById("enttot").value=qbusco[1]
          document.getElementById("prodtot").value=qbusco[2]
		  document.getElementById("total").value=qbusco[0]
		  document.getElementById("vta_cantidad").value=qbusco[3]
		  document.getElementById("vta_total").value=qbusco[0]*/
		  enProceso = false;
		  }
    }
	}
}
function ordenbannews(x,pre)
{
	obj="lst_orden"+x
	valor=document.getElementById(obj).value
	window.open('comandos.php?accion=ordenbanner&id='+x+'&pag=new_banners.php?pre='+pre+'&orden='+valor , '_parent')
}
function ordenbanners(x)
{
	obj="lst_orden"+x
	valor=document.getElementById(obj).value
	window.open('comandos.php?accion=ordenbanners&id='+x+'&pag=banners.php&orden='+valor , '_parent')
}
function carga_fechas(dia,mes,ano)
{
for (var g=0; g < 31;g++)
	{
	if(g+1<10)
		{d='0'+(g+1)}
		else
		{d=g+1}
	var new_option = new Option(d, g+1, false, false);
	document.getElementById('lst_dia').options[g] = new_option;
	}
/*if(dia>0)
		{
		var selObj = document.getElementById('lst_dia');
		selObj.options[dia-1].selected=dia
		}*/
for (var g=0; g < 12;g++)
	{
	if(g+1<10)
		{d='0'+(g+1)}
	else
		{d=g+1}
	var new_option = new Option(d, g+1, false, false);
	document.getElementById('lst_mes').options[g] = new_option;
	}
	if(mes>0)
		{
		var selObj = document.getElementById('lst_mes');
		selObj.options[mes-1].selected =mes
		}
var aano=new Date();	
var an=(aano.getFullYear()-17);
var z=an-1910;	
var a=1909;
for (var x=0; x < z;x++)
	{
	a++;	
	var new_option = new Option(a, a, false, false);
	document.getElementById('lst_ano').options[x] = new_option;
	}
	if(ano>0)
		{
		var selObj = document.getElementById('lst_ano');
		selObj.options[ano-1910].selected =ano
		}
}
function valida_buscar(x)
{
	if((document.getElementById('txt_busca').value=="")|(document.getElementById('txt_busca').value=="Indica el nombre a buscar"))
		{
		alert("Debes indicar el nombre a buscar.");
		document.getElementById('txt_busca').focus();
		}
	else
		{
		if(x==1)
			{
			window.open('rs_buscar.php?search='+document.getElementById('txt_busca').value, '_parent');
			}
		else
			{
			window.open('rs_buscargrupos.php?search='+document.getElementById('txt_busca').value, '_parent');	
			}
		}
}
function valida_invitaporemail()
{
if ((document.form1.txt_email.value=="")|(document.form1.txt_nombre.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.");
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.action="comandos.php?accion=invitaragrupoporemail&pag=rs_grupos.php";
			document.form1.submit();
		}
	}
}
function quitar_amigo(id,nombre)
{
var eli = confirm("¿Estas seguro que deseas quitar a "+nombre+" de tu lista de amigos?"+'\n'+"Si confirmas la acción "+nombre+" dejará de fomrar parte de los grupos de los cuales"+'\n'+"seas propietario y haya estado invitado.");
if (eli== true)
	{
	window.open('comandos.php?accion=quitaramigo&id='+id+'&pag=rs_misamigos.php', '_parent');
	}
}
function quitar_delgrupo(id,nombre)
{
var eli = confirm("¿Estas seguro que deseas quitar a "+nombre+" del grupo?"+'\n'+"Si confirmas la acción, "+nombre+" no podrá participar mas de este grupo.");
if (eli== true)
	{
	window.open('comandos.php?accion=quitardegrupo&id='+id+'&pag=rs_grupodetalle.php', '_parent');
	}
}
function valida_denuncia(id)
{
if ((document.form1.txt_descripcion.value==""))
	{
		alert("Debes indicar el motivo de la denuncia.")
	}
else
	{
	document.form1.action="comandos.php?accion=denuncia&id="+id+"&pag=rs_misamigos.php";
	document.form1.submit();
	}
}
function valida_addforo(x)
{
if ((document.form1.txt_nombre.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{
	if(x==1)
		{document.form1.action="comandos.php?accion=add_foros&pag=rs_foros.php";}
	else
		{document.form1.action="comandos.php?accion=updt_foros&pag=rs_foros.php";}
	document.form1.submit();
	}
}
function valida_addcontenido(x,accion)
{
var err=0;
var err1=0;
if(accion==1)
	{
	if ((document.form1.txt_nombre.value=="")|(document.form1.txt_descripcion.value=="")|(document.form1.txt_archivo.value==""))
		{
		alert("Todos los datos son obligatorios.")
		err1=1
		}
	else
		{
		err1=0
		}
	}
if(accion==2)
	{
	if ((document.form1.txt_nombre.value=="")|(document.form1.txt_descripcion.value==""))
		{
		alert("Todos los datos son obligatorios.")
		err1=1
		}
	else
		{
		err1=0
		}
	}	
		
		
if((x==1)|(x==2))
	{
	var archivo=document.form1.txt_archivo.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
		alert("El archivo debe ser una imágen  .jpg o .gif");
		err=1
		}
	else
		{
		err=0
		}
	}
/*if(x==2)
	{
	var archivo=document.form1.txt_archivo.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".flv")))
		{
		alert("El archivo debe ser una video  .flv ");
		err=1
		}
	else
		{
		err=0
		}
	}*/
if((err==0)&(err1==0))
	{
	if(accion==1)
		{document.form1.action="comandos.php?accion=add_contenidos&pag=rs_contenidos.php";}
	else
		{document.form1.action="comandos.php?accion=updt_contenidos&pag=rs_contenidos.php";}
	document.form1.submit();
	}
}
function valida_additemcontenido(x,accion,pag)
{
var err=0;
var err1=0;
var err2=0;
if(accion==1)
	{
	if(x==1)
		{
		if ((document.form1.txt_nombre.value=="")|(document.form1.txt_descripcion.value=="")|(document.form1.txt_archivo.value==""))
			{
			alert("Todos los datos son obligatorios.")
			err1=1
			}
		else
			{
			err1=0
			}
		}
	else
		{
			if ((document.form1.txt_nombre.value=="")|(document.form1.txt_descripcion.value=="")|(document.form1.txt_archivo.value=="")|(document.form1.txt_archivo2.value==""))
			{
			alert("Todos los datos son obligatorios.")
			err1=1
			}
		else
			{
			err1=0
			}
		}
	}
if(accion==2)
	{
	if ((document.form1.txt_nombre.value=="")|(document.form1.txt_descripcion.value==""))
		{
		alert("Todos los datos son obligatorios.")
		err1=1
		}
	else
		{
		err1=0
		}
	}	
		
		
if(x==1)
	{
	var archivo=document.form1.txt_archivo.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
		alert("El archivo debe ser una imágen  .jpg o .gif");
		err=1
		}
	else
		{
		err=0
		}
	}
if(x==2)
	{
	var archivo=document.form1.txt_archivo2.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".jpg")) & ((extension != ".gif"))  )
		{
		alert("La imagen inicial del video debe ser  .jpg o .gif");
		err2=1
		}
	else
		{
		err2=0
		}	
	var archivo=document.form1.txt_archivo.value
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
	if ((extension != "") & ((extension != ".flv")))
		{
		alert("El video debe ser un archivo .flv ");
		err=1
		}
	else
		{
		err=0
		}
	}
if((err==0)&(err1==0)&(err2==0))
	{
	if(accion==1)
		{document.form1.action="comandos.php?accion=add_itemcontenidos&pag="+pag;}
	else
		{document.form1.action="comandos.php?accion=updt_itemcontenidos&pag="+pag;}
	document.form1.submit();
	}
}
function valida_addintervencion(x)
{
document.form1.action="comandos.php?accion=add_intervencion&pag=rs_forodetalle.php";
document.form1.submit();
}
function valida_solicitud(x)
{
if ((document.form1.txt_descripcion.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{
	document.form1.action="comandos.php?accion=solicitud&pag=rs_grupodetalle.php";
	document.form1.submit();
	}
}
function valida_addcomentariitem(x)
{
if ((document.form1.txt_descripcion.value==""))
	{
		alert("Debes agregar un comentario.")
	}
else
	{
	document.form1.action="comandos.php?accion=add_comentarioitem&pag=rs_contenidoitemdetalles.php";
	document.form1.submit();
	}
}

function cerrarforo(id,pag,estado)
{
if(estado==1)
	{var m="¿Quieres cerrar el foro?"+'\n'+"Si lo haces los integrates no podrán agregar"+'\n'+"nuevas intervenciónes.";}
else
	{var m="¿Quieres abrir el foro?"+'\n'+"Si lo haces los integrates podrán agregar"+'\n'+"nuevas intervenciónes.";}
var eli = confirm(m);
if (eli== true)
	{
	window.open('comandos.php?accion=estado_foro&id='+id+'&pag='+pag, '_parent');	
	}
}
function desactivar(id,pag,estado)
{
if(estado==1)
	{var m="¿Quieres desactivar los comentarios para tus fotos?"+'\n'+"Si lo haces los integrates no podrán agregar"+'\n'+"nuevos comentarios a las imagenes de esta galería.";}
else
	{var m="¿Quieres activar los comentarios para tus fotos?"+'\n'+"Si lo haces los integrates podrán agregar"+'\n'+"nuevos comentarios a las imagenes de esta galería.";}
var eli = confirm(m);
if (eli== true)
	{
	window.open('comandos.php?accion=estado_galeria&id='+id+'&pag='+pag, '_parent');	
	}
}
