
var HORARIO_DONE = 0;

function horario_form_onload() {
 var frm=document.formSeleccionHorario;
 for (var i=0;i<frm.length;i++) {
  element = frm.elements[i];
  str = element.name;
    if ((str.indexOf("ELIGE")>0)&&(frm.elements[i].type=="radio")) {
	element.onclick = function () { horario_onclick_radio(this.select())};
  }
 }
}

function horario_onclick_radio () {
 if (HORARIO_DONE == 1) return;
 var img = document.getElementById("imagesubmit");
 var txt = img.src+"";
 txt = txt.replace('bt_continuar_gr','bt_continuar');
 img.src = txt;
 HORARIO_DONE = 1;
}

function horario_sendform() {
 if (HORARIO_DONE == 1) {
  //if (confirm("Se va a enviar el formulario.\n\nEstá seguro que desea continuar?")) {
   document.formSeleccionHorario.submit();
  //}
 } else {
  alert('Debe seleccionar un horario.');
 }
}

function valida_asientos() {
var x=document.getElementById("formSeleccionAsientos");
var chequeados = 0;
for (var i=0;i<x.length;i++)
  {
   if (x.elements[i].type == 'checkbox') {
   if (x.elements[i].checked) chequeados++;
 //document.write(x.elements[i].checked);
  //document.write("<br />");
  }
  }
  if (chequeados!=cantidad_astos) {
  alert('La cantidad de asientos debe ser igual a '+cantidad_astos+' y Ud. ha seleccionado '+chequeados+'.')
  } else {
   x.submit();
  }
}

function VELS09_validate() {
 var t = '';
 frm = document.formDatosComprador;
 TIPODOCLI=document.getElementById('vp_doc_tipo');
 DOCCLIENTE=document.getElementById('vp_doc_n');
 NOM1=document.getElementById('vp_nombre');
 APE1=document.getElementById('vp_apellido_paterno');
 APE2=document.getElementById('vp_apellido_materno');
 PAIS=document.getElementById('vp_pais');
 DOMIC=document.getElementById('vp_direccion');
 TELCOD11=document.getElementById('vp_telefono_fijo_pais');
 TELCOL12=document.getElementById('vp_telefono_fijo_area');
 TELCOL13=document.getElementById('vp_telefono_fijo_n');
 TELCOD21=document.getElementById('vp_telefono_celular_pais');
 TELCOL22=document.getElementById('vp_telefono_celular_area');
 TELCOL23=document.getElementById('vp_telefono_celular_n');
 TELCOD31=document.getElementById('vp_telefono_trabajo_pais');
 TELCOL32=document.getElementById('vp_telefono_trabajo_area');
 TELCOL33=document.getElementById('vp_telefono_trabajo_n');
 EMAIL=document.getElementById('vp_email');
 EMAIL2=document.getElementById('vp_email_repetir');
 //
 if (!selectnotnull(TIPODOCLI,'Debe especificar el tipo de documento de identificación.')) return false;
 if (!inputnotnull(DOCCLIENTE,'Debe especificar número de documento de identidad.')) return false;
 if (!chk_numdoc(DOCCLIENTE,'vp_doc_tipo')) return false;
 if (!inputnotnull_u(NOM1,'Debe ingresar nombre.')) return false;
 if (!inputnotnull_u(APE1,'Debe ingresar apellido.')) return false;
 to_mayuscula(APE2);
 if (!selectnotnull(PAIS,'Debe especificar el país.')) return false;
 if (!inputnotnull_u(DOMIC,'Debe ingresar dirección.')) return false;
 if (!inputnotdigitsorempty(TELCOD11,'Debe ingresar código de país válido.')) return false;
 if (!inputnotdigits(TELCOL12,'Debe ingresar código de área.')) return false;
 if (!inputnotdigits(TELCOL13,'Debe ingresar número de teléfono válido.')) return false;
 if (!inputnotdigitsorempty(TELCOD21,'Debe ingresar código de país válido.')) return false;
 if (!inputnotdigitsorempty(TELCOL22,'Debe ingresar código de área.')) return false;
 if (!inputnotdigitsorempty(TELCOL23,'Debe ingresar número de teléfono.')) return false;
 if (!inputnotdigitsorempty(TELCOD31,'Debe ingresar código de país válido.')) return false;
 if (!inputnotdigitsorempty(TELCOL32,'Debe ingresar código de área.')) return false;
 if (!inputnotdigitsorempty(TELCOL33,'Debe ingresar número de teléfono.')) return false;
 if (!inputisvalidemail(EMAIL,'Debe ingresar dirección de email válida.')) return false;
 if (!inputnotnull(EMAIL2,'Debe ingresar nuevamente la dirección de email.')) return false;
 if (!checkifequal(EMAIL,EMAIL2,'Las direcciones de email ingresadas no coinciden.')) return false;
 return true;
}

function VELS09_sendform() {
 frm = document.formDatosComprador;
 if (VELS09_validate()) {
  //if (confirm("Se va a enviar el formulario.\n\nEstá seguro que desea continuar?")) {
   frm.submit();
  //}
 }
}

function getSelectIndex(x,svalue) {
 for (i=0;i<x.length;i++) {
  if (x.options[i].value==svalue) return i;
 }
 return -1;
}