<!--
//***************************************************
//***************************************************
//FUNCIONES PERSONALIZADAS
function AbrirVentana(url, name, w, h, scrollsn) {	//funcion para abrir ventanas, reemplaza a JavaWindow
	window.open(url, name, 'width='+w+',height='+h+',scrollbars='+scrollsn);
}

function VeriContacto() {
	   var ruta;
	ruta = window.document.contacto; 
	if (ruta.nombres.value!="") {
		if (ruta.apellidos.value!="") {
			if (ruta.rut.value!="") {
				if (ruta.telefono.value!="") {				
					if (ruta.e_mail.value!="") {	
						if ((ruta.e_mail.value.indexOf ('@',0) == -1 || ruta.e_mail.value.indexOf ('.',0) == -1) &&  ruta.e_mail.value != "")
 							{							
									alert('El email debe ser válido');
									ruta.e_mail.focus();													
										} else {									
										ruta.mailok.value="ok";
										ruta.submit();												
										}
							} else {
						alert("Por favor, escribe tu email");
						ruta.e_mail.focus();
					}
				} else {
					alert("Por favor, escribe tu teléfono");
					ruta.telefono.focus();
				}
			} else {
				alert("Por favor, escribe tu rut");
				ruta.rut.focus();
			}
		} else {
			alert("Por favor, escribe tus apellidos");
			ruta.apellidos.focus();
		}
	} else {
		alert("Por favor, escribe tus nombres");
		ruta.nombres.focus();
	}
}



function VeriMail() {
	
	    var ruta;
	ruta = window.document.contacto; 
	if (ruta.nombres.value!="") {
		if (ruta.apellidos.value!="") {
			if (ruta.rut.value!="") {
				if (ruta.e_mail.value!="") {	
						if ((ruta.e_mail.value.indexOf ('@',0) == -1 || ruta.e_mail.value.indexOf ('.',0) == -1) &&  contacto.e_mail.value != "")
 							{							
									alert('El email debe ser válido');
									ruta.e_mail.focus();													
										} else {									
										ruta.mailok.value="ok";
										ruta.submit();												
										}
							} else {
						alert("Por favor, escribe tu email");
						ruta.e_mail.focus();
					}
				
			} else {
				alert("Por favor, escribe tu rut");
				ruta.rut.focus();
			}
		} else {
			alert("Por favor, escribe tus apellidos");
			ruta.apellidos.focus();
		}
	} else {
		alert("Por favor, escribe tus nombres");
		ruta.nombres.focus();
	}
}







function VeriIngresa(){			//FORMULARIO DE INSCRIPCION A ACCUCLUB

    var ingresa;
	ingresa = window.document.ingresa; 
	var cont = 0;
	for(i=0;i<=11;i++)		//desde nombres hasta patologia asociada
	{ingresa
		if (ingresa.elements[i].value!="")
		{
			cont++;
		}
	}
	//checkbox con opciones de textfields
	//para uso de medicamentos
	if ((ingresa.condiciones.checked==false) )
	{
		alert("Debe leer y aceptar las condiciones de privacidad");
		ingresa.medicamentos_si.focus();
		return;
	}
	else
	{
	
	
	if ((ingresa.medicamentos_no.checked==true) && (ingresa.medicamentos_si.value!=""))
	{
		alert("Por favor seleccione sólo una de las dos opciones (SI/NO)");
		ingresa.medicamentos_si.focus();
	
	}
	else
	{
		if (ingresa.medicamentos_no.checked)
		{
			ingresa.medicamentos.value = "No";
		}
		if (ingresa.medicamentos_si.value!="")
		{
			ingresa.medicamentos.value = ingresa.medicamentos_si.value;
		}
	}
	//para uso de insulina
	if ((ingresa.insulina_no.checked==true) && (ingresa.insulina_si.value!=""))
	{
		alert("Por favor seleccione sólo una de las dos opciones (SI/NO)");
		ingresa.insulina_si.focus();
	}
	else
	{
		if (ingresa.insulina_no.checked)
		{
			ingresa.insulina.value = "No";
		}
		if (ingresa.insulina_si.value!="")
		{
			ingresa.insulina.value = ingresa.insulina_si.value;
		}
	}
	//para auge
	if ((ingresa.auge[0].checked==false) && (ingresa.auge[1].checked==false) )
	{
		alert("Por favor seleccione una de las dos opciones (SI/NO)");
		
		ingresa.auge[0].focus();
	}
	else
	{
		if (ingresa.auge[0].checked)
		{
			ingresa.auge_valor.value = "No";
		}
		if (ingresa.auge[1].checked)
		{
			ingresa.auge_valor.value = "Si";
		}
	}
	//para prevision
	for (x=0;x<=1;x++)
	{
		if ((ingresa.prevision[x].checked==true) && (ingresa.prevision_otra.value!=""))
		{
			alert("Por favor seleccione sólo una de las opciones");
			ingresa.prevision_otra.focus();
		}
		else
		{
			for (j=0;j<=1;j++)
			{
				if (ingresa.prevision[j].checked==true)
				{
					ingresa.prevision_valor.value = ingresa.prevision[j].value;
				}
			}
			if (ingresa.prevision_otra.value!="")
			{
				ingresa.prevision_valor.value = ingresa.prevision_otra.value;
			}
		}
	}
	
	
	//para monitor de autocontrol
	for (x=0;x<=3;x++)
	{
		if ((ingresa.monitor_roche[x].checked==true) && (ingresa.monitor_otro.value!=""))
		{
			alert("Por favor seleccione sólo una de las dos opciones");
			ingresa.monitor_otro.focus();
		}
		else
		{
			for (j=0;j<=3;j++)
			{
				if (ingresa.monitor_roche[j].checked==true)
				{
					ingresa.monitor.value = ingresa.monitor_roche[j].value;
				}
			}
			if (ingresa.monitor_otro.value!="")
			{
				ingresa.monitor.value = ingresa.monitor_otro.value;
			}
		}
	}

if ((ingresa.numero_serie.value=="") )
	{
		alert("Debe ingresar el número de serie de su monitor Accu-Chek");
		ingresa.numero_serie.focus();
	}
	else
	for(i=20;i<=22;i++)		//desde fecha de adquisicion hasta frecuencia de glicemia
	{
		if (ingresa.elements[i].value!="")
		{
			cont++;
		}
	}
	if ((ingresa.medicamentos.value!="") && (ingresa.insulina.value!="") && (ingresa.monitor.value!=""))
	{
		ingresa.mailok.value="ok";
		ingresa.action = "ingresa.php";
		ingresa.submit();
	}


	else
	{
		alert ("Por favor complete correctamente todos los datos solicitados");
		
	}
	}
	
}

function FinalIngresa() {
	
	var datos_ingresa;
	datos_ingresa = window.document.datos_ingresa; 
	
	datos_ingresa.finalizar.value="ok";
	datos_ingresa.action = "ingresa_mail01.php";
	datos_ingresa.submit();
}

function VeriInscribe() {
	//inscribe.elements[0].focus();
	var cont2 = 0;
	for(i=0;i<document.inscribe.length-1;i++) {
		if (inscribe.elements[i].value!="") {
			cont2++;
		} else {
			alert("Por favor completa todos los campos");
			inscribe.elements[i].focus();
			break;
		}
	}
	if (cont2==11) {
		inscribe.mailok.value="ok";
		inscribe.action = "inscribe.php";
		inscribe.submit();
	}
}

function FinalInscribe() {
	datos_inscribe.finalizar.value="ok";
	datos_inscribe.action = "inscribe.php";
	datos_inscribe.submit();
}

function pedir_descarga(file_d) {
	document.descargar.archivo.value = file_d;
	document.descargar.submit();
}

//FUNCION PARA INSCRIPCION EN CONCURSO DIECIOCHERO ACCU-CHEK 2004 (REGALA PARRILLAS)
valor_farmacia = 0;
valor_producto = 0;
function CambiaValorFarmacia(far)
{
	valor_farmacia = far.value;
}
function CambiaValorProducto(pro)
{
	valor_producto = pro.value;
}
function EnviarDatosPromo18sept() {
	if (datos.nombres.value!="") {
		if (datos.apellidos.value!="") {
			if (datos.rut.value!="") {
				if (datos.mail.value!="") {
					if ((valor_farmacia != 0) || (datos.compro_otro.value!="")) {
						if (datos.numero_boleta.value!="") {
							if ((valor_producto != 0) || (datos.producto_otro.value!="")) {
								datos.action = "inscripcion_exec.php";
								datos.submit();
							} else {
								alert("Por favor indique el producto que adquirió");
								datos.producto_otro.focus();
							}
						} else {
							alert ("Por favor ingrese el número de su boleta de compra");
							datos.numero_boleta.focus();
						}
					} else {
						alert("Por favor indique el lugar en donde realizó su compra");
						datos.compro_otro.focus();
					} 
				} else {
					alert("Por favor ingrese una dirección de e-mail válida");
					datos.mail.focus();
				}
			} else {
				alert("Por favor ingrese su RUT");
				datos.rut.focus();
			} 
		} else {
			alert("Por favor ingrese sus apellidos");
			datos.apellidos.focus();
		}
	} else {
		alert("Por favor ingrese sus nombres");
		datos.nombres.focus();
	}
}

//
// Validador de Rut
// Descargado desde http://juque.f2o.org/
//
function revisarDigito( dvr )
{	
	dv = dvr + ""	
	if ( dv != '0' && dv != '1' && dv != '2' && dv != '3' && dv != '4' && dv != '5' && dv != '6' && dv != '7' && dv != '8' && dv != '9' && dv != 'k'  && dv != 'K')	
	{		
		alert("Debe ingresar un digito verificador valido");		
		window.document.contacto.rut.focus();		
		window.document.contacto.rut.select();		
		return false;	
	}	
	return true;
}

function revisarDigito2( crut )
{	
	largo = crut.length;	
	if ( largo < 2 )	
	{		
		alert("Debe ingresar el rut completo")		
		window.document.contacto.rut.focus();		
		window.document.contacto.rut.select();		
		return false;	
	}	
	if ( largo > 2 )		
		rut = crut.substring(0, largo - 1);	
	else		
		rut = crut.charAt(0);	
	dv = crut.charAt(largo-1);	
	revisarDigito( dv );	

	if ( rut == null || dv == null )
		return 0	

	var dvr = '0'	
	suma = 0	
	mul  = 2	

	for (i= rut.length -1 ; i >= 0; i--)	
	{	
		suma = suma + rut.charAt(i) * mul		
		if (mul == 7)			
			mul = 2		
		else    			
			mul++	
	}	
	res = suma % 11	
	if (res==1)		
		dvr = 'k'	
	else if (res==0)		
		dvr = '0'	
	else	
	{		
		dvi = 11-res		
		dvr = dvi + ""	
	}
	if ( dvr != dv.toLowerCase() )	
	{		
		alert("EL rut es incorrecto")		
		window.document.contacto.rut.focus();		
		window.document.contacto.rut.select();		
		return false	
	}

	return true
}

function Rut(texto)
{	
	var tmpstr = "";	
	for ( i=0; i < texto.length ; i++ )		
		if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
			tmpstr = tmpstr + texto.charAt(i);	
	texto = tmpstr;	
	largo = texto.length;	

	if ( largo < 2 )	
	{		
		alert("Debe ingresar el rut completo")		
		window.document.contacto.rut.focus();		
		window.document.contacto.rut.select();		
		return false;	
	}	

	for (i=0; i < largo ; i++ )	
	{			
		if ( texto.charAt(i) !="0" && texto.charAt(i) != "1" && texto.charAt(i) !="2" && texto.charAt(i) != "3" && texto.charAt(i) != "4" && texto.charAt(i) !="5" && texto.charAt(i) != "6" && texto.charAt(i) != "7" && texto.charAt(i) !="8" && texto.charAt(i) != "9" && texto.charAt(i) !="k" && texto.charAt(i) != "K" )
 		{			
			alert("El valor ingresado no corresponde a un R.U.T valido");			
			window.document.contacto.rut.focus();			
			window.document.contacto.rut.select();			
			return false;		
		}	
	}	

	var invertido = "";	
	for ( i=(largo-1),j=0; i>=0; i--,j++ )		
		invertido = invertido + texto.charAt(i);	
	var dtexto = "";	
	dtexto = dtexto + invertido.charAt(0);	
	dtexto = dtexto + '-';	
	cnt = 0;	

	for ( i=1,j=2; i<largo; i++,j++ )	
	{		
		//alert("i=[" + i + "] j=[" + j +"]" );		
		if ( cnt == 3 )		
		{			
			dtexto = dtexto + '.';			
			j++;			
			dtexto = dtexto + invertido.charAt(i);			
			cnt = 1;		
		}		
		else		
		{				
			dtexto = dtexto + invertido.charAt(i);			
			cnt++;		
		}	
	}	

	invertido = "";	
	for ( i=(dtexto.length-1),j=0; i>=0; i--,j++ )		
		invertido = invertido + dtexto.charAt(i);	

	window.document.contacto.rut.value = invertido.toUpperCase()		

	if ( revisarDigito2(texto) )		
		return true;	

	return false;
}




-->