function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); 
        if (p<1 || p==(val.length-1) || val.indexOf(',')>1 || val.indexOf('/')>1 || val.indexOf('&')>1 || val.indexOf('$')>1 || val.indexOf('#')>1 || val.indexOf('!')>1 || val.indexOf('?')>1 || val.indexOf(';')>1 || val.indexOf(':')>1)errors+='- '+nm+' debe contener una dirección de mail.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' debe contener un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' debe contener un número entre '+min+' y'+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es necesario.\n'; }
  } if (errors) alert('Los siguientes errores han ocurrido:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  winContent = window.open(theURL,winName,features);
  winContent.focus();
}

function obtenerfoco() {
 var el = event.srcElement;
el.focus;
}


function NoNacional(){
	
	if (document.frmVoto.chknacional.checked){
		document.frmVoto.otronacional.disabled = false;
	}else{
		document.frmVoto.otronacional.disabled = true;
		document.frmVoto.otronacional.value = '';
	}
}

function SolicitarVotoEncuesta(formulario,oculto,btn,nombre,direccion,ciudad,telefono,miemail,repetirEmail)
{
	var form, error='';
	var varNombre,varDireccion,varCiudad,varEmail,varRepetirEmail,varTelefono;
	var campoOculto, boton;
	form = document.getElementById(formulario);
	
	varNombre = document.getElementById(nombre);
	varDireccion = document.getElementById(direccion);
	varCiudad = document.getElementById(ciudad);
	varEmail = document.getElementById(miemail);
	varRepetirEmail = document.getElementById(repetirEmail);
	varTelefono = document.getElementById(telefono);
	
	campoOculto = document.getElementById(oculto);
	boton = document.getElementById(btn);
	
	if (varNombre.value == '')
	{
		error = error + 'Nombre es necesario\n';
	}
	if (varDireccion.value == '')
	{
		error = error + 'Dirección es necesario\n';
	}
	if (varCiudad.value == '')
	{
		error = error + 'Ciudad es necesario\n';
	}
	if (varEmail.value == '')
	{
		error = error + 'Mi Email es necesario\n';
	}
	if (varRepetirEmail.value == '')
	{
		error = error + 'Repetir Email es necesario\n';
	}
	if (varTelefono.value == '')
	{
		error = error + 'Teléfono es necesario\n';
	}
	
	if ((varEmail.value != '') && (varRepetirEmail.value != ''))
	{
		if (varEmail.value != varRepetirEmail.value)
		{
			error = error + 'Email y Repetir Email no coinciden\n';
		}
	}
	
	if (error == '')
	{
		
		campoOculto.value = btn;
		boton.style.visibility = 'hidden';
		form.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
	
}

function EnviarOpinionEncuesta(formulario,oculto,btn,txtEmail,txtClave,chkOtroArtista,txtOtroArtista,chkOtroWeb,txtOtroWeb,chkOtroShow,txtOtroShow)
{
	var form, error='';
	var varOrtoArtista,varOtroWeb,varotroShow,varChkOtroArtista,varChkOtroWeb,varChkOtroShow,varEmail,varClave;
	var campoOculto, boton;
	form = document.getElementById(formulario);
	
	varOrtoArtista = document.getElementById(txtOtroArtista);
	varOtroWeb = document.getElementById(txtOtroWeb);
	varOtroShow = document.getElementById(txtOtroShow);
	varChkOtroArtista = document.getElementById(chkOtroArtista);
	varChkOtroWeb = document.getElementById(chkOtroWeb);
	varChkOtroShow = document.getElementById(chkOtroShow);
	
	varEmail = document.getElementById(txtEmail);
	varClave = document.getElementById(txtClave);
	
	campoOculto = document.getElementById(oculto);
	boton = document.getElementById(btn);
	
	if (varEmail.value == '')
	{
		error = error + 'Email es necesario\n';
	}
	
	if (varClave.value == '')
	{
		error = error + 'Clave es necesario\n';
	}
	
	if (varChkOtroArtista.checked == true)
	{
		if (varOrtoArtista.value == '')
		{
			error = error + 'Es necesario agregar un valor para Otro artista\n';
		}
	}
	
	if (varChkOtroWeb.checked == true)
	{
		if (varOtroWeb.value == '')
		{
			error = error + 'Es necesario agregar un valor para Otro sitio web\n';
		}
	}
	
	if (varChkOtroShow.checked == true)
	{
		if (varOtroShow.value == '')
		{
			error = error + 'Es necesario agregar un valor para Otro espectáculo\n';
		}
	}
	
	
	if (error == '')
	{
		campoOculto.value = btn;
		boton.style.visibility = 'hidden';
		form.submit();		
		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
	
}

function EncuestaNoEnLista(ddList,chkBox,txtBox){
	
	var miDropDownList, miTextBox, miCheckBox;
	miDropDownList = document.getElementById(ddList);
	miTextBox = document.getElementById(txtBox);
	miCheckBox = document.getElementById(chkBox);
	
	if (miCheckBox.checked){
		miTextBox.style.disabled = false;
		miTextBox.style.visibility = 'visible';
		miTextBox.style.display = 'block';
		miTextBox.value = '';
		miDropDownList.style.visibility = 'hidden';
		miDropDownList.style.display = 'none';
	}else{
		miTextBox.style.disabled = true;
		miTextBox.value = 'n/d';
		miTextBox.style.visibility = 'hidden';
		miTextBox.style.display = 'none';
		miDropDownList.style.visibility = 'visible';
		miDropDownList.style.display = 'block';
		
		
	}
}

function EncuestaOtroALista(ddList,chkBox,txtBox,lblOtro){
	
	var miDropDownList, miTextBox, miCheckBox, miLabel;
	miDropDownList = document.getElementById(ddList);
	miTextBox = document.getElementById(txtBox);
	miCheckBox = document.getElementById(chkBox);
	miLabel = document.getElementById(lblOtro);
	
	if (miCheckBox.checked){
		miTextBox.style.disabled = false;
		miTextBox.style.visibility = 'visible';
		miLabel.style.visibility = 'visible';
		miTextBox.style.display = 'block';
		miTextBox.value = '';
		miDropDownList.style.visibility = 'hidden';
		miDropDownList.style.display = 'none';
	}else{
		miTextBox.style.disabled = true;
		miTextBox.value = 'n/d';
		miTextBox.style.visibility = 'hidden';
		miLabel.style.visibility = 'hidden';
		miTextBox.style.display = 'none';
		miDropDownList.style.visibility = 'visible';
		miDropDownList.style.display = 'block';
		
		
	}
}

function NoInternacional(){
	
	if (document.frmVoto.chkinternacional.checked){
		document.frmVoto.otrointernacional.disabled = false;
	}else{
		document.frmVoto.otrointernacional.disabled = true;
		document.frmVoto.otrointernacional.value = '';
	}
}

function ValidarApunte(formulario)
{
	var form, error='';
	var apunte, titulo, oculto,btn,mensaje,cerrar,layTitulo;
	form = document.getElementById(formulario);
	apunte = document.getElementById('txtCuerpo');
	titulo = document.getElementById('txtTitulo');
	layTitulo = document.getElementById('layTitulo');
	oculto = document.getElementById('oculto');
	btn = document.getElementById('btnEnviar');
	mensaje = document.getElementById('layEspere');
	cerrar = document.getElementById('btnCerrar');
	if (apunte.value == '')
	{
		error = error + 'Cuerpo del apunte es necesario.\n' ;
	}
	
	if (titulo.value == '')
	{
		error = error + 'Título del apunte es necesario.\n' ;
	}
		  
	if (error == '')
	{
		oculto.value = 'btnEnviar';
		btn.style.visibility = 'hidden';
		cerrar.style.visibility = 'hidden';
		apunte.style.visibility = 'hidden';
		titulo.style.visibility = 'hidden';
		layTitulo.style.visibility = 'hidden';
		mensaje.style.visibility = 'visible';
		
		form.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
}

function ValidarComentario(formulario)
{
	var form, error='';
	var cmt, oculto,btn,mensaje,cerrar;
	form = document.getElementById(formulario);
	cmt = document.getElementById('comentario');
	oculto = document.getElementById('oculto');
	btn = document.getElementById('btnEnviar');
	mensaje = document.getElementById('layEspere');
	cerrar = document.getElementById('btnCerrar');
	if (cmt.value == '')
	{
		error = error + 'Comentario es necesario.\n' ;
	}
		  
	if (error == '')
	{
		oculto.value = 'btnEnviar';
		btn.style.visibility = 'hidden';
		cerrar.style.visibility = 'hidden';
		cmt.style.visibility = 'hidden';
		mensaje.style.visibility = 'visible';
		
		form.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
}

function ValidarInscripcion(formulario)
{
	var form, error='';
	var nombre,casilla,repetirCasilla, clave,repetirClave;
	form = document.getElementById(formulario);
	nombre = document.getElementById('nombre');
	casilla = document.getElementById('casilla');
	repetirCasilla = document.getElementById('repite_casilla');
	usuario = document.getElementById('usuario');
	clave = document.getElementById('clave');
	repetirClave = document.getElementById('repite_clave');
	if (nombre.value == '')
	{
		error = error + 'Nombre es necesario.\n' ;
	}
	
	if (casilla.value == '' || repetirCasilla.value == '')
	{
		error = error + 'Casilla de correos es necesario.\n' ;
	}
	
	if (usuario.value == '')
	{
		error = error + 'Usuario es necesario.\n' ;
	}
	else
	{
		if (usuario.value.length < 6)
		{
			error = error + 'El usuario debe tener como mínimo 6 caracteres.\n';
		}
		else
		{
			if (!TextBoxValido(usuario.value))
			{
				error = error + 'El usuario seleccionado tiene caracteres no válidos.\n';
			}
		}
	}
	
	if (clave.value == '' || repetirClave.value == '')
	{
		error = error + 'Clave es necesario.\n' ;
	}
	else
	{
		if (clave.value.length < 6)
		{
			error = error + 'La clave debe tener como mínimo 6 caracteres\n';
		}
		else
		{
			if (!TextBoxValido(clave.value))
			{
				error = error + 'La clave seleccionada tiene caracteres no válidos.\n';
			}
		}
	}
	
	if (casilla.value != repetirCasilla.value)
	{
		error = error + 'Casilla y Repetir Casilla deben ser iguales.\n' ;
	}
	
	if (clave.value == '' || repetirClave.value == '')
	{
		error = error + 'Clave y Repetir Clave deben ser iguales.\n' ;
	}
	
	if ( emailCheck(casilla.value) == false)
	{
		error = error + 'La casilla de email proporcionada no es válida.\n' ;
	}
	
	
	
	if (error =='')
	{
		form.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
}

function ValidarModificarInscripcion(formulario)
{
	var form, error='';
	var nombre,casilla,repetirCasilla, clave,repetirClave,claveAnterior,oculto;
	form = document.getElementById(formulario);
	nombre = document.getElementById('nombre');
	casilla = document.getElementById('casilla');
	repetirCasilla = document.getElementById('repite_casilla');
	usuario = document.getElementById('usuario');
	clave = document.getElementById('clave');
	repetirClave = document.getElementById('repite_clave');
	claveAnterior = document.getElementById('clave_anterior');
	oculto = document.getElementById('oculto');
	if (nombre.value == '')
	{
		error = error + 'Nombre es necesario.\n' ;
	}
	
	if (casilla.value == '' || repetirCasilla.value == '')
	{
		error = error + 'Casilla de correos es necesario.\n' ;
	}
	
	if (usuario.value == '')
	{
		error = error + 'Usuario es necesario.\n' ;
	}
	else
	{
		if (usuario.value.length < 6)
		{
			error = error + 'El usuario debe tener como mínimo 6 caracteres\n';
		}
		else
		{
			if (!TextBoxValido(usuario.value))
			{
				error = error + 'El usuario seleccionado tiene caracteres no válidos.\n';
			}
		}
	}
	
	if (claveAnterior.value == '')
	{
		error = error + 'Clave anterior es necesario.\n' ;
	}
	
	if (clave.value == '' || repetirClave.value == '')
	{
		error = error + 'Clave es necesario.\n' ;
	}
	else
	{
		if (clave.value.length < 6)
		{
			error = error + 'La clave debe tener como mínimo 6 caracteres\n';
		}
		else
		{
			if (!TextBoxValido(clave.value))
			{
				error = error + 'La clave seleccionada tiene caracteres no válidos.\n';
			}
		}
	}
	
	
	if (casilla.value != repetirCasilla.value)
	{
		error = error + 'Casilla y Repetir Casilla deben ser iguales.\n' ;
	}
	
	if (clave.value == '' || repetirClave.value == '')
	{
		error = error + 'Clave y Repetir Clave deben ser iguales.\n' ;
	}
	
	
	if ( emailCheck(casilla.value) == false)
	{
		error = error + 'La casilla de email proporcionada no es válida.\n' ;
	}
	
	if (error =='')
	{
		oculto.value = 'btnModificar';
		form.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
}

function ValidarAcceso(formulario)
{
	var form, error='';
	var usuario,clave,oculto;
	form = document.getElementById(formulario);
	//alert(form.usuario);
	usuario = form.usuario;
	clave = form.clave;
	oculto = form.oculto;
	
	//usuario = document.getElementById('usuario');
	//clave = document.getElementById('clave');
	//oculto = document.getElementById('oculto');
	if (usuario.value == '')
	{
		error = error + 'Usuario es necesario.\n' ;
	}
	else
	{
		if (!TextBoxValido(usuario.value))
		{
			error = error + 'El usuario proporcionado tiene caracteres no válidos.\n';
		}
	}
		
	if (clave.value == '')
	{
		error = error + 'Clave es necesario.\n' ;
	}
	else
	{
  		if (!TextBoxValido(clave.value))
		{
			error = error + 'La clave proporcionada tiene caracteres no válidos.\n';
		}
	}
	
	if (error == '')
	{
		oculto.value = 'btnIngresar';
		form.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
}


function ValidarSolicitarClave(formulario)
{
	var form, error='';
	var email,p;
	form = document.getElementById(formulario);
	email = document.getElementById('email_clave');
	oculto = document.getElementById('oculto');
	if (email.value == '')
	{
		error = error + 'Email es necesario.\n' ;
	}
	else
	{ 
	p=email.value.indexOf('@'); 
    if (p<1 || p==(email.value.length-1) || email.value.indexOf(',')>1 || email.value.indexOf(' ')>1 || email.value.indexOf('/')>1 || email.value.indexOf('&')>1 || email.value.indexOf('$')>1 || email.value.indexOf('#')>1 || email.value.indexOf('!')>1 || email.value.indexOf('?')>1 || email.value.indexOf(';')>1 || email.value.indexOf(':')>1)error+='El email proporcionado no es correcto.\n';
    }
	  
	//if (error =='')
	//{
		//return true;
		//oculto.value = 'btnMisDatos';
		//form.submit();		
	//}
	//else
	//{
		//error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		//alert(error);
		//return false;
	//}
	if (error) alert('Atención, los siguiente datos necesitan tu atención:\n'+error);
	document.MM_returnValue = (error == '');
}

function MensajeActualizacion(mensaje)
{
		if (!window.opener.closed)
		{
			window.opener.location.reload();
			alert(mensaje);
		}
		else
		{
			alert(mensaje);
			Cerrar();
		}
}

function Cerrar()
{
	
	window.close();
}

//marca los checkboxs
function CheckAll(formulario)
    {
	var i;
	 for (i=0;i<formulario.elements.length;i++)
  	{ 
	 if ( (formulario.elements[i].type=="checkbox") )
		{
		(formulario.elements[i].checked) = true;
		}
    }	
	}
	
//chequea si hay checks seleccionados, sino, envía un mensaje, si existen pregunta
function CheckEmpty(frame,text,formname,hidden){
	var form;
	var i;
	form= document.getElementById(formname)
	for (i=0;i<form.elements.length;i++){
  
	 if (form.elements[i].type=="checkbox"){
		if ((form.elements[i].checked) == true){
			Confirm(frame,text,formname,hidden);
			return true;
		}
	 }	
	}
			alert('No hay items seleccionados.');
			return false;
}

//limpia los checkboxs
function ClearAll(formulario)
    {
	var i;
	 for (i=0;i<formulario.elements.length;i++)
  
	 if ((formulario.elements[i].type=="checkbox"))
		{
		(formulario.elements[i].checked) = false;
		}
   	}
   	
   	
function Confirm(frame,text,formname,hidden) { 
	var x=window.confirm(text),doc,accion;
	doc = top.frames[frame].document; 
	id = doc.getElementById(formname);
	accion = doc.getElementById('oculto');
	accion.value = hidden;
	//oculto.name = hidden;
	
	if (x)
	{
	id.submit();
	}
}

function ConfirmarFormulario(text) { 
	var x=window.confirm(text);

	if (x)
	{
	return true;
	}
	else
	{
	return false;
	}
}

function RealizarPedido(text) { 

	chkBox = document.getElementById('chkCondiciones');
	
	if (chkBox.checked == true)
	{
		var x=window.confirm(text);
	
		if (x)
		{
		return true;
		}
		else
		{
		return false;
		}
	}
	else
	{
		alert('Atención: Es necesario aceptar las condiciones de venta.\nPor favor, marca "He leído y acepto las condiciones de venta" para realizar el pedido.')
		return false;
	}
}

function TextBoxValido(valor)
{
	if (valor.indexOf(',')>=0 || valor.indexOf('\/')>=0 || valor.indexOf('\\')>=0 || valor.indexOf('&')>=0 || valor.indexOf('$')>=0 || valor.indexOf('#')>=0 || valor.indexOf('!')>=0 || valor.indexOf('?')>=0 || valor.indexOf(';')>=0 || valor.indexOf(':')>=0 || valor.indexOf('*')>=0)
	{
		return false;
	}
	else
	{
		return true;
	}
	
}

function ValidarBuitres(formulario,email,clave,oculto)
{
	
	var i,cantidad=0,error='';
	 for (i=0;i<formulario.elements.length;i++)
		{ 
		 if ( (formulario.elements[i].type=="checkbox") )
			{
				if ((formulario.elements[i].checked) == true)
				{
					cantidad = cantidad + 1;
				}
			}
		}	
	if (cantidad == 0)
	{
		error = error + 'Es necesario seleccionar algún tema.\n';
	}
	if (cantidad > 10)
	{
		error = error + 'Es necesario seleccionar no más de 10 temas.\n';
	}
	if (email.value == '')
	{
		error = error + 'Es necesario proporcionar un email.\n';
	}
	if (clave.value == '')
	{
		error = error + 'Es necesario proporcionar la clave.\n';
	}
	
	if (error =='')
	{
		oculto.value = 'btnVoto';
		formulario.submit();		
	}
	else
	{
		error = 'Por favor, estos datos necesitan tu atención:\n' + error ;
		alert(error);
	}
}

function emailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		var iChars = "!#$%^&*()+=[]\\\';,/{}|\":<>?";
		
		for (var i = 0; i < str.length; i++) {
			if (iChars.indexOf(str.charAt(i)) != -1) {
			return false;
			}
		  }

		if (str.indexOf(at)==-1){
		   return false;
		}

		
		if (str.indexOf("\\n") >= 0)
		{
			return false;
		}
		
		if (str.indexOf("\\") >= 0)
		{
			return false;
		}
		
		
		
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   return false;
		 }

 		 return true;			
	}
	
	function TemasRegistrados()
	{
		alert('ATENCION::\nPara escuchar el tema es necesario estar registrado.\nSi ya eres usuario registrado, ingresa tu nombre de usuario y clave en la parte superior del sitio.\nSi no te encuentras registrado, lo puede hacer a través de Nuevo Usuario.');	
	}
	
	function PrintPage() {
	window.print();  
	}
