// Variables para setear
var contador=new Array(0,0);
var maxi=4;

onload=function(){
	divTransparente=document.getElementById("transparencia");
	divMensaje=document.getElementById("transparenciaMensaje");
	form=document.getElementById("formulario");

	
	claseNormal="input";
	claseError="inputError";
	
		preCarga("ok.gif", "loading.gif", "error.gif");
}
function preCarga()
{
	imagenes=new Array();
	for(i=0; i<arguments.length; i++)
	{
		imagenes[i]=document.createElement("img");
		imagenes[i].src=arguments[i];
	}
}

function nuevoAjax()
{ 
	var xmlhttp=false; 
	try 
	{ 
		// Si es cualkier otro navegador
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Internet Explorer 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 
	return xmlhttp; 
}
function marcarDesmarcarCheck(check, viaje, origen, destino,retorno){
if (check.checked == true){
			regAsiento(check, 'regAsiento.asp', viaje, check.name, origen, destino,retorno)
 	 }else {
   			eliAsientos(check, 'eliAsiento.asp', viaje, check.name, origen, destino,retorno)
   }
}	 
function regAsiento(check, pagina, viaje, asiento, origen, destino, retorno)
{
	  
    var url_final = pagina+'?viaje='+viaje+'&asiento='+asiento+'&origen='+origen+'&destino='+destino+'&retorno='+retorno
    
    var objAjax = nuevoAjax()
    
    objAjax.open("GET", url_final)
    objAjax.onreadystatechange = function() {
      if (objAjax.readyState == 4) {
       //Se escribe el resultado en la capa contenedora
	   if(objAjax.responseText=="ERROR")
	   {
		   check.checked=false
		    Sexy = new SexyAlertBox();
					   Sexy.alert('<h1>&nbsp;&nbsp;Transportes Linea</h1><br/><p>Debe tener al menos un asiento de ida</p>');
		   }
		if(objAjax.responseText=="2" || objAjax.responseText=="1"){
			check.checked=false
			 Sexy = new SexyAlertBox();
             Sexy.alert('<h1>&nbsp;&nbsp;Transportes Linea</h1><br/><p>El &nbsp;máximo&nbsp; de&nbsp; asientos &nbsp;que&nbsp; puede </br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elegir&nbsp; por &nbsp;compra &nbsp;son&nbsp; 8</p>');
		}
      }
    }
    objAjax.send(null);
}
function listaDatos(viaje,retorno){
//document.getElementById("listadoAsientos").innerHTML="<img src='imagenes/gif_cargando.gif' width='300' height='300' />"
	var url_final = 'sp_listaDatos.asp?via='+viaje+'&retorno='+retorno
	var objAjax = nuevoAjax()
    objAjax.open("GET", url_final)
    objAjax.onreadystatechange = function() {
    if (objAjax.readyState == 4) {
       //Se escribe el resultado en la capa contenedora
		    document.getElementById("listadoAsientos").innerHTML=objAjax.responseText
    	}
	}
    objAjax.send(null);
}	
function eliAsientos(check, pagina, viaje, asiento,origen,destino,retorno){
var url_final = pagina+"?viaje="+viaje+"&asiento="+asiento+'&origen='+origen+'&destino='+destino
	var objAjax=nuevoAjax()
	objAjax.open("GET", url_final)
    objAjax.onreadystatechange = function() {
      if (objAjax.readyState == 4) {
       //Se escribe el resultado en la capa contenedora
	  resp=objAjax.responseText
	   if(resp=="3")
	   {
		   check.checked=true
			Sexy = new SexyAlertBox();
					   Sexy.alert('<h1>Transportes Linea</h1><br/><p>Debe tener al menos un asiento de ida</p>');
	      }else{
				if(check=='imagen'){
			  listaDatos(viaje,retorno)		
//			  location.reload()
				}
		  }
    	}
		
	}
    objAjax.send(null);
}	
function campoError(campo)
{
	campo.className=claseError;
	error=1;
}

function ocultaMensaje()
{
	divTransparente.style.display="none";
}

function muestraMensaje(mensaje)
{
	divMensaje.innerHTML=mensaje;
	divTransparente.style.display="block";
}
function borrarAsientosTrasladados(check,asientoida,asientovuelta){
document.getElementById("idtxtdnivuelta"+asientovuelta.toString()).value="";
	document.getElementById("idtxtnombrevuelta"+asientovuelta.toString()).value = "";
	document.getElementById("idtxtemailvuelta"+asientovuelta.toString()).value = "";
	document.getElementById("idtxtedadvuelta"+asientovuelta.toString()).value = "";
	document.getElementById("idcmbsexovuelta"+asientovuelta.toString()).value = "";
	document.getElementById("idcmbtdocvuelta"+asientovuelta.toString()).disabled=false
	document.getElementById("idtxtdnivuelta"+asientovuelta.toString()).disabled=false
	document.getElementById("idtxtnombrevuelta"+asientovuelta.toString()).disabled=false
	document.getElementById("idtxtemailvuelta"+asientovuelta.toString()).disabled=false
	document.getElementById("idtxtedadvuelta"+asientovuelta.toString()).disabled=false
	document.getElementById("idcmbsexovuelta"+asientovuelta).disabled=false
	document.getElementById("idtxtrucvuelta"+asientovuelta.toString()).disabled=false
	document.getElementById("idtxtrazonsocialvuelta"+asientovuelta.toString()).disabled=false		
			gAsiento= check.name
			var cont1= new Array(check.form.elements.length)
			var cont2= new Array(check.form.elements.length)
			for(i=0;i<check.form.elements.length;i++){
			if( check.form.elements[i].type == 'checkbox' && check.form.elements[i].checked){
						check.form.elements[i].style.visibility="visible"
						cont1[i]=check.form.elements[i].id
						cont2[i]=check.form.elements[i].name
						   }
			}
			for(i=0;i<check.form.elements.length;i++){
					if(check.form.elements[i].id==asientoida){
							check.form.elements[i].style.visibility="visible"
							   }
				}
			for(i=0;i<check.form.elements.length;i++){
				 if ( check.form.elements[i].type == 'checkbox' && check.form.elements[i].name==gAsiento) {
						check.form.elements[i].style.visibility="visible"
						
      			   }
				   
				}
			for(j=0;j<check.form.elements.length;j++){	
				for(i=0;i<check.form.elements.length;i++){
					if(check.form.elements[i].id==cont1[j]){
							check.form.elements[i].style.visibility="hidden"
							   }
				}
			}
			for(i=0;i<check.form.elements.length;i++){	
				for(j=0;j<check.form.elements.length;j++){
					if(check.form.elements[i].name==cont2[j]){
							check.form.elements[i].style.visibility="hidden"
							   }
				}
			}
			for(i=0;i<check.form.elements.length;i++){
				if( check.form.elements && check.form.elements[i].checked){
						check.form.elements[i].style.visibility="visible"

						   }
			}

	}		
function comprobarRepeticion(txtCampo){
if(txtCampo.value!=""){
	cont=0
		for(i=0;i<txtCampo.form.elements.length;i++){
			if(txtCampo.form.elements[i].value==txtCampo.value){
			cont=cont+1
			}
		}
	return cont			
	}
	else
	{
		return 0
		}
}										   
function pasarDatosAsientos(check,asientoida,asientovuelta){

	document.getElementById("idcmbtdocvuelta"+asientovuelta.toString()).value=document.getElementById("idcmbtdocida"+asientoida.toString()).value;
	document.getElementById("idtxtdnivuelta"+asientovuelta.toString()).value=document.getElementById("idtxtdniida"+asientoida.toString()).value;
	document.getElementById("idtxtnombrevuelta"+asientovuelta.toString()).value = document.getElementById("idtxtnombreida"+asientoida.toString()).value;
	document.getElementById("idtxtemailvuelta"+asientovuelta.toString()).value = document.getElementById("idtxtemailida"+asientoida.toString()).value;
	document.getElementById("idtxtedadvuelta"+asientovuelta.toString()).value = document.getElementById("idtxtedadida"+asientoida.toString()).value;
	document.getElementById("idcmbsexovuelta"+asientovuelta).value = document.getElementById("idcmbsexoida"+asientoida.toString()).value;
	document.getElementById("idtxtrucvuelta"+asientovuelta.toString()).value = document.getElementById("idtxtrucida"+asientoida.toString()).value;
	document.getElementById("idtxtrazonsocialvuelta"+asientovuelta.toString()).value = document.getElementById("idtxtrazonsocialida"+asientoida.toString()).value;
			document.getElementById("vuelta"+asientovuelta.toString()).value=document.getElementById("cod"+asientoida.toString()).value;
			
	document.getElementById("idcmbtdocvuelta"+asientovuelta.toString()).disabled=true
	document.getElementById("idtxtdnivuelta"+asientovuelta.toString()).disabled=true
	document.getElementById("idtxtnombrevuelta"+asientovuelta.toString()).disabled=true
	document.getElementById("idtxtemailvuelta"+asientovuelta.toString()).disabled=true
	document.getElementById("idtxtedadvuelta"+asientovuelta.toString()).disabled=true
	document.getElementById("idcmbsexovuelta"+asientovuelta).disabled=true
	document.getElementById("idtxtrucvuelta"+asientovuelta.toString()).disabled=true
	document.getElementById("idtxtrazonsocialvuelta"+asientovuelta.toString()).disabled=true
			gAsiento= check.name
			for(i=0;i<check.form.elements.length;i++){
				 if ( check.form.elements[i].type == 'checkbox' && check.form.elements[i].name==gAsiento) {
						check.form.elements[i].style.visibility="hidden"
      			   }
				}
			for(i=0;i<check.form.elements.length;i++){
				if(check.form.elements[i].id==asientoida){
						check.form.elements[i].style.visibility="hidden"
						   }
			}
			for(i=0;i<check.form.elements.length;i++){
				if( check.form.elements[i].type == 'checkbox' && check.form.elements[i].checked){
						check.form.elements[i].style.visibility="visible"
						   }
			}
}
function trasladarAsientos(check,asientoida,asientovuelta){
if (check.checked == true){
			pasarDatosAsientos(check,asientoida,asientovuelta)
 	 }else {
   			borrarAsientosTrasladados(check,asientoida,asientovuelta)
   }
	}		
function datosPasajeroida(asiento,txtBox)
{
	var oTDoc = document.getElementById("idcmbtdocida"+asiento.toString());
	var oNDoc = document.getElementById("idtxtdniida"+asiento.toString());
	
		if(oNDoc.value==""){
			document.getElementById("idtxtnombreida"+asiento.toString()).value=""
			document.getElementById("idtxtemailida"+asiento.toString()).value=""
			document.getElementById("idtxtedadida"+asiento.toString()).value=""
			document.getElementById("idtxtrazonsocialida"+asiento.toString()).value=""
						}
		else{if(oNDoc.value.length>=8){
		xTDoc=oTDoc.value;
		xNDoc=oNDoc.value;
	
		ajax=nuevoAjax();
		ajax.open("GET", "sp_datosboleto.asp?TDoc="+xTDoc+"&NDoc="+xNDoc, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==4)
			{ 
				results = ajax.responseText.split("|-|"); 
				
				if (Trim(results[0])!='')document.getElementById("idtxtnombreida"+asiento.toString()).value = Trim(results[0]);
				if (Trim(results[1])!='') document.getElementById("idtxtemailida"+asiento.toString()).value = Trim(results[1]);
				if (Trim(results[2])!='') document.getElementById("idtxtedadida"+asiento.toString()).value = Trim(results[2]);
				if (Trim(results[3])!='') document.getElementById("idcmbsexoida"+asiento).value = Trim(results[3]);
				} 
	
				//if(Trim(results[4])=="1"){
					//	document.getElementById("idtxtnombreida"+asiento.toString()).disabled=true
						//document.getElementById("idtxtemailida"+asiento.toString()).disabled=true
						//document.getElementById("idtxtedadida"+asiento.toString()).disabled=true
						
					//}
					//else{
						//document.getElementById("idtxtnombreida"+asiento.toString()).disabled=false
						//document.getElementById("idtxtemailida"+asiento.toString()).disabled=false
						//document.getElementById("idtxtedadida"+asiento.toString()).disabled=false
						
						//}
				
		}
		ajax.send(null);
		}
		}
}
function datosPasajeroidatarjeta(form)
{
	var oTDoc = document.getElementById("idcmbtdocida3");
	var oNDoc = document.getElementById("idtxtdniida3");
	xTDoc=oTDoc.value;
	xNDoc=oNDoc.value;
	ajax=nuevoAjax();
	ajax.open("GET", "sp_datosboletoth.asp?TDoc="+xTDoc+"&NDoc="+xNDoc, true);
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==4)
		{ results = ajax.responseText.split("|-|"); 
			
			if (ajax.responseText!=""){
				document.getElementById("idtxtnombreida3").value =results[0]	
				document.getElementById("idtxtemailida3").value = results[1]
				document.getElementById("idtxtfono3").value=results[2]
				}
				else{
					document.getElementById("idtxtnombreida3").value = ""	
					document.getElementById("idtxtemailida3").value = ""
					document.getElementById("idtxtfono3").value=""
					}
		
		}
	}
ajax.send(null);
}
function datosPasajerovuelta(asiento,txtBox)
{
	var oTDoc = document.getElementById("idcmbtdocvuelta"+asiento.toString());
	var oNDoc = document.getElementById("idtxtdnivuelta"+asiento.toString());

	xTDoc=oTDoc.value;
	xNDoc=oNDoc.value;
	if(oNDoc.value==""){
		document.getElementById("idtxtnombrevuelta"+asiento.toString()).value=""
		document.getElementById("idtxtemailvuelta"+asiento.toString()).value=""
		document.getElementById("idtxtedadvuelta"+asiento.toString()).value=""
		document.getElementById("idtxtrazonsocialvuelta"+asiento.toString()).value=""
					}
					else{if(oNDoc.value.length>=8){
						ajax=nuevoAjax();
						ajax.open("GET", "sp_datosboleto.asp?TDoc="+xTDoc+"&NDoc="+xNDoc, true);
						ajax.onreadystatechange=function() 
						{ 
							if (ajax.readyState==4)
							{ 
								results = ajax.responseText.split("|-|"); 
								
								document.getElementById("idtxtnombrevuelta"+asiento.toString()).value = Trim(results[0]);
								document.getElementById("idtxtemailvuelta"+asiento.toString()).value = Trim(results[1]);
								document.getElementById("idtxtedadvuelta"+asiento.toString()).value = Trim(results[2]);
								if (Trim(results[3])!='') document.getElementById("idcmbsexovuelta"+asiento.toString()).value = Trim(results[3]);
								if(Trim(results[6])==1){
								document.getElementById("idtxtnombrevuelta"+asiento.toString()).disabled=true
								document.getElementById("idtxtemailvuelta"+asiento.toString()).disabled=true
								document.getElementById("idtxtedadvuelta"+asiento.toString()).disabled=true
									}else{
								document.getElementById("idtxtnombrevuelta"+asiento.toString()).disabled=false
								document.getElementById("idtxtemailvuelta"+asiento.toString()).disabled=false
								document.getElementById("idtxtedadvuelta"+asiento.toString()).disabled=false
										}
							} 
						}
						ajax.send(null);
					}
	}
}
function datosEmpresaida(asiento)
{
	var oNDoc = document.getElementById("idtxtrucida"+asiento.toString());
	
	xNDoc=oNDoc.value;
	
	ajax=nuevoAjax();
	ajax.open("GET", "sp_datosboleto.asp?TDoc=RUC&NDoc="+xNDoc, true);
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==4)
		{ 
			results = ajax.responseText.split("|-|"); 
			
			document.getElementById("idtxtrazonsocialida"+asiento.toString()).value = Trim(unescape(results[0]));
			if (Trim(results[0])==''){
				document.getElementById("idtxtrazonsocialida"+asiento.toString()).disabled=false;
			}else{
				document.getElementById("idtxtrazonsocialida"+asiento.toString()).disabled=true;
			}
		} 
	}
	ajax.send(null);
}
function datosEmpresavuelta(asiento)
{
	var oNDoc = document.getElementById("idtxtrucvuelta"+asiento.toString());
	
	xNDoc=oNDoc.value;
	
	ajax=nuevoAjax();
	ajax.open("GET", "sp_datosboleto.asp?TDoc=RUC&NDoc="+xNDoc, true);
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==4)
		{ 
			results = ajax.responseText.split("|-|"); 
			
			document.getElementById("idtxtrazonsocialvuelta"+asiento.toString()).value = Trim(unescape(results[0]));
			if (Trim(results[0])==''){
				document.getElementById("idtxtrazonsocialvuelta"+asiento.toString()).disabled=false;
			}else{
				document.getElementById("idtxtrazonsocialvuelta"+asiento.toString()).disabled=true;
			}
		} 
	}
	ajax.send(null);
}
function datosPasajero()
{
	var oTDoc = document.getElementById("idcmbtdoc");
	var oNDoc = document.getElementById("idtxtdni");
	
	xTDoc=oTDoc.value;
	xNDoc=oNDoc.value;

	ajax=nuevoAjax();
	ajax.open("GET", "sp_datosboleto.asp?TDoc="+xTDoc+"&NDoc="+xNDoc, true);
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==4)
		{ 
			results = ajax.responseText.split("|-|"); 
			
			document.getElementById("idtxtnombre").value = Trim(results[0]);
			document.getElementById("idtxtemail").value = Trim(results[1]);
			

		} 
	}
	ajax.send(null);
}

function registrarPasajero(formulario,pagina){
		 
         var longitudFormulario = formulario.elements.length;
         var cadenaFormulario = ""
         var sepCampos
         sepCampos = ""
         for (var i=0; i <= formulario.elements.length-1;i++) {
         cadenaFormulario += sepCampos+formulario.elements[i].name+'='+encodeURI(formulario.elements[i].value);
         sepCampos="&";
		 }
		 url = 'regPasajero.asp?'+cadenaFormulario
		 ajax=nuevoAjax();
  		 ajax.open("GET", url, true);
 		 
 		 ajax.onreadystatechange = function () {
			 if (ajax.readyState == 4) {
					 
			 location.href=pagina
			}
		}
		ajax.send(null);

}	
function cerrarSession(){
url='cerrarSesion.asp'
	ajax=nuevoAjax();
  		 ajax.open("GET", url, true);

 		 ajax.onreadystatechange = function () {
			 if (ajax.readyState == 4) {

			}
		}
		ajax.send(null);
	
	}
if (history.forward(1))
{
	location.replace(history.forward(1))
	} 
function obtenerViajero(txtTarjeta){

		if(txtTarjeta.value.length!=0){
		text =document.getElementById("viajeroFrecuente")
		text.innerHTML="<img src='imagenes/precarga.gif' width='20' height='22'>"
			url="sp_viajerofrecuente.asp?tarjeta="+txtTarjeta.value
			ajax=nuevoAjax();
  		 	ajax.open("GET", url, true);
 		  	ajax.onreadystatechange = function () {
				 if (ajax.readyState == 4) {
						text.innerHTML = ajax.responseText
					}
					
			}
			ajax.send(null);
		}
}
function obtenerItinerario(formulario){
		 

		var longitudFormulario = formulario.elements.length;
         var cadenaFormulario = ""
         var sepCampos
         sepCampos = ""
		 document.getElementById("espera").innerHTML="<a href='javascript:comprueba(document.rutas);'><img src=botonbuscar.gif border=0></a><img src='imagenes/precarga.gif' width='20' height='22'>"
         for (var i=0; i <= formulario.elements.length-1;i++) {
			 if(formulario.elements[i].type=='radio' && formulario.elements[i].checked){
				 
				 cadenaFormulario += sepCampos+formulario.elements[i].name+'='+encodeURI(formulario.elements[i].value);
				 sepCampos="&";
			 }else{
				 if(formulario.elements[i].type!='radio'){
					cadenaFormulario += sepCampos+formulario.elements[i].name+'='+encodeURI(formulario.elements[i].value);
				 	sepCampos="&"; 
					 }
				 
				 }
		 }
		 url = 'itinerario.asp?'+cadenaFormulario
		 ajax=nuevoAjax();
  		 ajax.open("GET", url, true);
 		 
 		 ajax.onreadystatechange = function () {
			 if (ajax.readyState == 4) {
					 respuesta=document.getElementById("resultados")
					 respuesta.innerHTML=ajax.responseText
			 		 document.getElementById("espera").innerHTML="<a href='javascript:comprueba(document.rutas);'><img src=botonbuscar.gif border=0></a>"
					 obtenerViajero(window.document.rutas.nrotarjeta)
			}
		}
		ajax.send(null);

}	
function sombrearTabla1(cont){
contador=document.getElementById("contador")
	parimpar=0
	for(i=0;i<contador.value;i++){
			if(parimpar==0){
			parimpar=1	
			document.getElementById("servicio"+i.toString()).className="par"
			document.getElementById("salida"+i.toString()).className="par"
			document.getElementById("llegada"+i.toString()).className="par"
			document.getElementById("precio"+i.toString()).className="par"
			document.getElementById("libres"+i.toString()).className="par"
			document.getElementById("usar"+i.toString()).className="par"
			}else{if(parimpar==1){
					parimpar=0
						document.getElementById("servicio"+i.toString()).className="impar"
						document.getElementById("salida"+i.toString()).className="impar"
						document.getElementById("llegada"+i.toString()).className="impar"
						document.getElementById("precio"+i.toString()).className="impar"
						document.getElementById("libres"+i.toString()).className="impar"
						document.getElementById("usar"+i.toString()).className="impar"

					}
				
				}
		}
		document.getElementById("servicio"+cont.toString()).className="marcado"
		document.getElementById("salida"+cont.toString()).className="marcado"
		document.getElementById("llegada"+cont.toString()).className="marcado"
		document.getElementById("precio"+cont.toString()).className="marcado"
		document.getElementById("libres"+cont.toString()).className="marcado"
		document.getElementById("usar"+cont.toString()).className="marcado"
		
}	
function sombrearTabla2(cont){
contador2=document.getElementById("contador2")
	parimpar=0
	for(i=50;i<contador2.value;i++){
			if(parimpar==0){
			parimpar=1	
			document.getElementById("servicio"+i.toString()).className="par"
			document.getElementById("salida"+i.toString()).className="par"
			document.getElementById("llegada"+i.toString()).className="par"
			document.getElementById("precio"+i.toString()).className="par"
			document.getElementById("libres"+i.toString()).className="par"
			document.getElementById("usar"+i.toString()).className="par"
			}else{if(parimpar==1){
					parimpar=0
						document.getElementById("servicio"+i.toString()).className="impar"
						document.getElementById("salida"+i.toString()).className="impar"
						document.getElementById("llegada"+i.toString()).className="impar"
						document.getElementById("precio"+i.toString()).className="impar"
						document.getElementById("libres"+i.toString()).className="impar"
						document.getElementById("usar"+i.toString()).className="impar"

					}
				
				}
		}
		document.getElementById("servicio"+cont.toString()).className="marcado"
		document.getElementById("salida"+cont.toString()).className="marcado"
		document.getElementById("llegada"+cont.toString()).className="marcado"
		document.getElementById("precio"+cont.toString()).className="marcado"
		document.getElementById("libres"+cont.toString()).className="marcado"
		document.getElementById("usar"+cont.toString()).className="marcado"
		
}	
                                        
function compraConPuntos(check,asiento,cont,origen,destino,viaje){
if (check.checked == true){
			descontarPuntos(check,asiento,cont,origen,destino,viaje)
 	 }else {
   			sumarPuntos(check,asiento,cont,origen,destino,viaje)
   }
	
}	
function descontarPuntos(check,asiento,cont,origen,destino,viaje){
		
		 division=document.getElementById("textoNombre"+asiento.toString())

		 url="sp_listarMienbros.asp?contador="+cont+"&asiento="+asiento+"&viaje=ida"
		 ajax=nuevoAjax()
		ajax.open("GET",url, true)
	
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==4)
			{ 
				division.innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
		
		
		 url2="sp_pagaconpuntos.asp?asiento="+asiento+"&viaje="+viaje+"&origen="+origen+"&destino="+destino+"&puntos=1"
		 ajax2=nuevoAjax()
		ajax2.open("GET",url2, true)
	
		ajax2.onreadystatechange=function() 
		{ 
			if (ajax2.readyState==4)
			{ 
			document.getElementById("Saldo"+cont).innerHTML=ajax2.responseText
			}
		}
		ajax2.send(null)
		
}
function sumarPuntos(check,asiento,cont,origen,destino,viaje){
division=document.getElementById("textoNombre"+asiento.toString())
	division.innerHTML="<input type=text class='obl' id='idtxtnombreida"+asiento.toString()+"' name=nombreida"+cont.toString()+" maxlength=50 size='50'>"
	 url2="sp_pagaconpuntos.asp?asiento="+asiento+"&viaje="+viaje+"&origen="+origen+"&destino="+destino+"&puntos=0"
		 ajax2=nuevoAjax()
		ajax2.open("GET",url2, true)
	
		ajax2.onreadystatechange=function() 
		{ 
			if (ajax2.readyState==4)
			{ 
				document.getElementById("Saldo"+cont).innerHTML=ajax2.responseText
				document.getElementById("idtxtemailida"+asiento.toString()).value = ""
				document.getElementById("idtxtedadida"+asiento.toString()).value = ""
				document.getElementById("idtxtdniida"+asiento.toString()).value = ""


				
				document.getElementById("idtxtemailida"+asiento.toString()).disabled = false
				document.getElementById("idtxtedadida"+asiento.toString()).disabled = false
				document.getElementById("idtxtdniida"+asiento.toString()).disabled = false
				document.getElementById("idcmbtdocida"+asiento.toString()).disabled = false
				document.getElementById("idcmbsexoida"+asiento.toString()).disabled = false
			}
		}
		ajax2.send(null)
		
}	
function compraConPuntosvuelta(check,asiento,cont,origen,destino,viaje){
if (check.checked == true){
			descontarPuntosvuelta(check,asiento,cont,origen,destino,viaje)
 	 }else {
   			sumarPuntosvuelta(check,asiento,cont,origen,destino,viaje)
   }
	
}	
function descontarPuntosvuelta(check,asiento,cont,origen,destino,viaje){
		
		 division=document.getElementById("textoNombrevuelta"+asiento.toString())
		 document.getElementById("vuelta"+asiento.toString()).value="00"
		 url="sp_listarMienbros.asp?contador="+cont+"&asiento="+asiento+"&viaje=vuelta"
		 ajax=nuevoAjax()
		 ajax.open("GET",url, true)
		
		 ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==4)
			{ 
				division.innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
		
		
		 url2="sp_pagaconpuntos.asp?asiento="+asiento+"&viaje="+viaje+"&origen="+origen+"&destino="+destino+"&puntos=1"
		 ajax2=nuevoAjax()
		ajax2.open("GET",url2, true)
	
		ajax2.onreadystatechange=function() 
		{ 
			if (ajax2.readyState==4)
			{ 
			document.getElementById("Saldo"+cont).innerHTML=ajax2.responseText
			}
		}
		ajax2.send(null)
		
}
function sumarPuntosvuelta(check,asiento,cont,origen,destino,viaje){
division=document.getElementById("textoNombrevuelta"+asiento.toString())
	division.innerHTML="<input type=text class='obl' id='idtxtnombrevuelta"+asiento.toString()+"' name=nombreida"+cont.toString()+" maxlength=50 size='50'>"
	 url2="sp_pagaconpuntos.asp?asiento="+asiento+"&viaje="+viaje+"&origen="+origen+"&destino="+destino+"&puntos=0"
		 ajax2=nuevoAjax()
		ajax2.open("GET",url2, true)
	
		ajax2.onreadystatechange=function() 
		{ 
			if (ajax2.readyState==4)
			{ 
				document.getElementById("Saldo"+cont).innerHTML=ajax2.responseText
				document.getElementById("idtxtemailvuelta"+asiento.toString()).value = ""
				document.getElementById("idtxtedadvuelta"+asiento.toString()).value = ""
				document.getElementById("idtxtdnivuelta"+asiento.toString()).value = ""


				
				document.getElementById("idtxtemailvuelta"+asiento.toString()).disabled = false
				document.getElementById("idtxtedadvuelta"+asiento.toString()).disabled = false
				document.getElementById("idtxtdnivuelta"+asiento.toString()).disabled = false
				document.getElementById("idcmbtdocvuelta"+asiento.toString()).disabled = false
				document.getElementById("idcmbsexovuelta"+asiento.toString()).disabled = false
			}
		}
		ajax2.send(null)
		
}	
function comprobarError(){
setTimeout('comprobarError()',1000)
	ajax=nuevoAjax();
	ajax.open("GET", "obtenerErrores.asp", true);
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==4)
		{ 
			if(ajax.responseText!=""){
			mostrarError(ajax.responseText)		
			}
		}
	
	}
	ajax.send(null);
}	
function regTarjetaHabiente(){
documento=document.getElementById("idcmbtdocida3").value
	nrodocumento=document.getElementById("idtxtdniida3").value
	nombre=document.getElementById("idtxtnombreida3").value
	telefono=document.getElementById("idtxtfono3").value
	mail=document.getElementById("idtxtemailida3").value
	url="sp_regTarjetaHabiente.asp?nombre="+nombre+"&documento="+documento+"&nrodocumento="+nrodocumento+"&telefono="+telefono+"&mail="+mail
	ajax=nuevoAjax();
  		 ajax.open("GET", url, true);
 		 
 		 ajax.onreadystatechange = function () {
			 if (ajax.readyState == 4) {
				documento=document.getElementById("idcmbtdocida3").disabled=true
				nrodocumento=document.getElementById("idtxtdni3").disabled=true
				nombre=document.getElementById("idtxtnombreida3").disabled=true
				telefono=document.getElementById("idtxtfono3").disabled=true
				mail=document.getElementById("idtxtemailida3").disabled=true
			}
		}
		ajax.send(null);
	}	
function RegPuntos(){

	url="sp_regpuntos.asp"
	ajax=nuevoAjax();
  		 ajax.open("GET", url, true);
 		 
 		 ajax.onreadystatechange = function () {
			 if (ajax.readyState == 4) {
				//MENSAJE
			}
		}
		ajax.send(null);
	}

function enviarMail(pagina,transaccion,cliente,correo,sesi){
	
			url=pagina+"transaccion="+transaccion+"&cliente="+cliente+"&correo="+correo+"&sesi="+sesi
			ajax=nuevoAjax();
  		 	ajax.open("GET", url, true);
 		  	ajax.onreadystatechange = function () {
				 if (ajax.readyState == 4) {
					 
						}
					
			}
			ajax.send(null);
}
if(navigator.userAgent.indexOf("MSIE")>=0) navegador=0;
else navegador=1;