﻿function ShowFactReservacion() {
   
}

function IrInsCripcion() {
   window.location.href ="https://www.cubaeshop.com/CubaEshop.aspx?ID=Registrarse";
}

function EnviarMensage() {
 var MyEmail=document.getElementById('ClientEmail').value;
 var MySubject=document.getElementById('Subjeto').value;
 var MyMsg=document.getElementById('TextMensage').value;
   document.getElementById('TXTEmailClient').value=document.getElementById('ClientEmail').value;
   document.getElementById('TXTSubject').value=document.getElementById('Subjeto').value;
   document.getElementById('TXTTextoMensage').value=document.getElementById('TextMensage').value;
   document.getElementById('IsEnviarMensage').checked=true;
   
   document.getElementById('ClientEmail').value="";
   document.getElementById('Subjeto').value="";
   document.getElementById('TextMensage').value="";
 
   var btn=document.getElementById('ButtonExe');
   btn.click();
}

function Abrirlocalizacion() {
     window.open("AntillasExpressLocate.aspx", 'LocalizacionAntillas', 'width=850,height=370,left=100,top=100'); 
}

function RecuperarClaveUserST(MyT,MyV) {
  document.getElementById(MyT).value=document.getElementById(MyV).value;
  
  document.getElementById('TXTPageToShow').value='EnviarRecuperacion';
   var btn=document.getElementById('ButtonExe');
   btn.click();

}

function FConnexionWebST() {
   document.getElementById('TXTPageToShow').value="Conectarse";
   document.getElementById('TxtConecEmail').value=document.getElementById('TXT_Usuario').value;
   document.getElementById('TxtConecPassWHide').value=document.getElementById('TXT_Clave').value;
   //document.getElementById('IsConnexionWeb').checked=true;
   var btn=document.getElementById('ButtonExe');
   if (btn) btn.click();

   //var MyOP="0|0| |ConnexionWeb";
   //window.location.href ="CubaEshop.aspx?ID="+MyOP;
 
}

function CrearCuentaClienteSTNew(MyOpc,IsEnvio) {
   
   if (document.getElementById('TXTPageToShow'))
   {var MyO=document.getElementById('TXTPageToShow').value
   if (MyO=="RegistrarseBene") MyOpc="BeneWeb";}
   
   if (MyOpc) {if (MyOpc=="BeneWeb") {document.getElementById('TXT_CodigoPostal').value="*";
                                      document.getElementById('TXT_Email').value="*";
                                      var MyIdProv=document.getElementById('TXT_Provincia').value;;
                                      document.getElementById('TXTIdProvAct').value=MyIdProv;}}
   
   var IsBene=0;
   var MyStrError="";
   var MyV=document.getElementById('TXT_Name').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Nombre";
   
   MyV=document.getElementById('TXT_Apellidos').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Apellidos";
   
   if (document.getElementById('TXT_Usuario')) { MyV=document.getElementById('TXT_Usuario').value;
                                                 if (MyV.length==0) MyStrError=MyStrError + "* Usuario";}
   else {IsBene=1;}
   if (MyO=="RegistrarseBene") IsBene=0;
   
   if (document.getElementById('TXT_Usuario')) {MyV=document.getElementById('TXT_Contrasena').value;
                                                if (MyV.length==0) MyStrError=MyStrError + "* Contrasena";}
   
   if (document.getElementById('TXT_Usuario')) {MyV=document.getElementById('TXT_Clave').value;
                                                if (MyV.length==0) MyStrError=MyStrError + "* Confirmación de Contrasena";}
   
   //MyV=document.getElementById('TXT_NoCivico').value;
   //if (MyV.length==0) MyStrError=MyStrError + "* No Cívico";
   
   MyV=document.getElementById('TXT_Direccion').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Dirección";
   
   MyV=document.getElementById('TXT_PaisName').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Pais";
   
   if (MyOpc=="BeneWeb") {
      MyV=document.getElementById('TXT_ProvinciaName').value;
      if (MyV.length==0) MyStrError=MyStrError + "* Provincia";
   }
   
   MyV=document.getElementById('TXT_Ciudad').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Ciudad";
   
   MyV=document.getElementById('TXT_CodigoPostal').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Codigo Postal";
   
   MyV=document.getElementById('TXT_Telefono').value;
   if (MyOpc!="BeneWeb") {if (MyV.length==0) MyStrError=MyStrError + "* Teléfono";}
   
    
   MyV=document.getElementById('TXT_Email').value;
   if (MyOpc!="BeneWeb") {if (MyV.length==0) MyStrError=MyStrError + "* Email";}
   
   if (document.getElementById('TXT_Contrasena')) {if (document.getElementById('TXT_Contrasena').value!=document.getElementById('TXT_Clave').value) MyStrError=MyStrError + " *** Error el la confirmación de la contraseña ***" }
   
   //if (MyStrError.length==0) {if (document.getElementById('IsBeneWeb')) {var MyTxtBuscar=opener.document.CubaEShop.TXTBuscar; 
   //                                                                      if (MyTxtBuscar) {MyTxtBuscar.value=document.getElementById('TXT_Telefono').value;}
   //                                                                      if (opener.document.CubaEShop.TXTPageToShow.value=="Beneficiarios") opener.document.CubaEShop.TXTPageToShow.value="BeneficiariosCreado";
   //                                                                      var btnN=opener.document.CubaEShop.ButtonExe;
   //                                                                      if (!btnN) btnN=opener.document.CubaEShop.Buttonexe; 
   //                                                                      var btn=document.getElementById('Buttonexe');}
   //                           else {if (IsBene==1) {var btn=opener.document.ArchivoDossier.Buttonexe;}
   //                                 else var btn=document.getElementById('Buttonexe');}
   //                                 }
   //else {MyStrError="Verificar : "+MyStrError ; alert(MyStrError);}                           
   
   
   if (document.getElementById('IsSaveBene')) {document.getElementById('IsSaveBene').checked=true;}
   
   //document.getElementById('TXTPageToShow').value="FactReservar";
   var btn=document.getElementById('ButtonExe');
   if (btn) btn.click();
   //if (btnN) btnN.click(); 
   
}

function CrearCuentaClienteST(MyOpc,IsEnvio) {
   
   if (document.getElementById('TXTPageToShow'))
   {var MyO=document.getElementById('TXTPageToShow').value
   if (MyO=="RegistrarseBene") MyOpc="BeneWeb";}
   
   if (MyOpc) {if (MyOpc=="BeneWeb") {document.getElementById('TXT_CodigoPostal').value="*";
                                      document.getElementById('TXT_Email').value="*";
                                      var MyIdProv=document.getElementById('TXT_Provincia').value;;
                                      document.getElementById('TXTIdProvAct').value=MyIdProv;}}
   
   var IsBene=0;
   var MyStrError="";
   var MyV=document.getElementById('TXT_Name').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Nombre";
   
   MyV=document.getElementById('TXT_Apellidos').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Apellidos";
   
   if (document.getElementById('TXT_Usuario')) { MyV=document.getElementById('TXT_Usuario').value;
                                                 if (MyV.length==0) MyStrError=MyStrError + "* Usuario";}
   else {IsBene=1;}
   if (MyO=="RegistrarseBene") IsBene=0;
   
   if (document.getElementById('TXT_Usuario')) {MyV=document.getElementById('TXT_Contrasena').value;
                                                if (MyV.length==0) MyStrError=MyStrError + "* Contrasena";}
   
   if (document.getElementById('TXT_Usuario')) {MyV=document.getElementById('TXT_Clave').value;
                                                if (MyV.length==0) MyStrError=MyStrError + "* Confirmación de Contrasena";}
   
   //MyV=document.getElementById('TXT_NoCivico').value;
   //if (MyV.length==0) MyStrError=MyStrError + "* No Cívico";
   
   MyV=document.getElementById('TXT_Direccion').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Dirección";
   
   MyV=document.getElementById('TXT_PaisName').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Pais";
   
   if (MyOpc=="BeneWeb") {
      MyV=document.getElementById('TXT_ProvinciaName').value;
      if (MyV.length==0) MyStrError=MyStrError + "* Provincia";
   }
   
   MyV=document.getElementById('TXT_Ciudad').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Ciudad";
   
   MyV=document.getElementById('TXT_CodigoPostal').value;
   if (MyV.length==0) MyStrError=MyStrError + "* Codigo Postal";
   
   MyV=document.getElementById('TXT_Telefono').value;
   if (MyOpc!="BeneWeb") {if (MyV.length==0) MyStrError=MyStrError + "* Teléfono";}
   
    
   MyV=document.getElementById('TXT_Email').value;
   if (MyOpc!="BeneWeb") {if (MyV.length==0) MyStrError=MyStrError + "* Email";}
   
   if (document.getElementById('TXT_Contrasena')) {if (document.getElementById('TXT_Contrasena').value!=document.getElementById('TXT_Clave').value) MyStrError=MyStrError + " *** Error el la confirmación de la contraseña ***" }
   
   if (MyStrError.length==0) {if (document.getElementById('IsBeneWeb')) {var MyTxtBuscar=opener.document.CubaEShop.TXTBuscar; 
                                                                         if (MyTxtBuscar) {MyTxtBuscar.value=document.getElementById('TXT_Telefono').value;}
                                                                         if (opener.document.CubaEShop.TXTPageToShow.value=="Beneficiarios") opener.document.CubaEShop.TXTPageToShow.value="BeneficiariosCreado";
                                                                         var btnN=opener.document.CubaEShop.ButtonExe;
                                                                         if (!btnN) btnN=opener.document.CubaEShop.Buttonexe; 
                                                                         var btn=document.getElementById('Buttonexe');}
                              else {if (IsBene==1) {var btn=opener.document.ArchivoDossier.Buttonexe;}
                                    else var btn=document.getElementById('Buttonexe');}
                                    }
   else {MyStrError="Verificar : "+MyStrError ; alert(MyStrError);}                           
   
   if (document.getElementById('IsSaveBene')) {document.getElementById('IsSaveBene').checked=true;}
   
   //document.getElementById('TXTPageToShow').value="FactReservar";
   if (btn) btn.click();
   if (btnN) btnN.click(); 
   
}


function UpdateForm(IdTxt,MyId,MyFld, MyType) {
  if (MyFld=="Ciudad") document.getElementById(IdTxt).focus();
  var MyV=document.getElementById(IdTxt).value;
  if (MyType) UpUpdateIITxt("TXTUpdates",MyFld,MyId,MyV);
  else UpUpdateIITxt("TXTUpdates",MyFld,MyId,"'" + MyV + "'"); 
  
}

function UpUpdateIITxt(MySeccDB,MyFld,MyId,sColour) {
  var MyUP=document.getElementById(MySeccDB).value;
  var MyP1;
  var MyP2;
  var MySub1="";
  var MySub2="";
  var MySub3="";
  var MySub4="";
  var MyPEnd;
 
 if (MyUP.length==0) {document.getElementById(MySeccDB).value= "|" + MyId + "[" + MyFld + "=" + sColour + "]";}
 
 else {MyPosId=MyUP.indexOf("|" + MyId + "[");
       if (MyPosId==-1) {document.getElementById(MySeccDB).value=MyUP + "|" + MyId + "[" + MyFld + "=" + sColour + "]"}
       else {MySub1=MyUP.substring(0,MyPosId+MyId.length+1);
             MyPos=MyUP.indexOf("]",MyPosId);
             MyPosEnd=MyUP.lastIndexOf("]");
             MySub2=MyUP.substring(MyPos+1,MyPosEnd+1);
             MySub3=MyUP.substring(MyPosId+2,MyPos+1);

             MyPEnd=MySub3.lastIndexOf("]");
             MyP1=MySub3.indexOf(MyFld + "=");
             if (MyP1==-1) {if (MyId.length==1) {MySub3="[" + MyFld + "=" + sColour + "^" + MySub3.substring(MyId.length,MyPEnd+1);}
                            else {MySub3="[" + MyFld + "=" + sColour + "^" + MySub3.substring(MyId.length,MyPEnd+1);} 
                            document.getElementById(MySeccDB).value=MySub1 + MySub3 + MySub2;
                           }
             else {MyLong=MyFld.length;
                  if (MyId.length==1) MySub4=MySub3.substring(1,MyP1+MyLong);
                  else MySub4=MySub3.substring(MyId.length-1,MyP1+MyLong);
                  MyP2= MySub3.indexOf("^",MyP1+MyLong);
                  if (MyP2==-1) MyP2= MySub3.indexOf("]");
                  MySub5=MySub3.substring(MyP2,MyPEnd+1);
                  if (MySub4.indexOf("[")==-1) MySub4="[" + MySub4;
                  MySub3=MySub4 + "=" + sColour + MySub5;
                  document.getElementById(MySeccDB).value=MySub1 + MySub3 + MySub2;
                  }    
            } 
      } 
}


function CambiaCantidad(MyOpc) {
 var MyId=MyOpc;
 var MyPrecio=document.getElementById('PrecioProd_'+MyId).innerText;
 var MyPrecioN=MyPrecio * 1;
 var MyCantAdu=document.getElementById('Adultos_'+MyId).value;
 var MyCantAduOLD=document.getElementById('AdultosOLD_'+MyId).value;
 var MyCantA=MyCantAdu * 1;
 var MyCantNi=document.getElementById('Ninos_'+MyId).value;
 var MyCantNiOLD=document.getElementById('NinosOLD_'+MyId).value;
 var MyCantN=MyCantNi * 1;
 var MyDe=document.getElementById('TXTLlegada').value;
 var MyA=document.getElementById('TXTPartida').value;
 var MyArrProd=document.getElementById('TxtArrProdSelected').value;
 
 var MyBW = parseInt(document.getElementById("C_" + MyOpc).style.borderWidth);
 if (MyBW == 2) {document.getElementById('TxtArrProdSelected').value=MyArrProd.replace("|"+MyId+"("+MyDe+","+MyA+","+MyCantAduOLD+","+MyCantNiOLD+")"+"|","");
                 MyArrProd=document.getElementById('TxtArrProdSelected').value;
                 document.getElementById('TxtArrProdSelected').value=MyArrProd +"|"+MyId+"("+MyDe+","+MyA+","+MyCantAdu+","+MyCantNi+")"+"|";}
                 
 document.getElementById('AdultosOLD_'+MyId).value=document.getElementById('Adultos_'+MyId).value;
 document.getElementById('NinosOLD_'+MyId).value=document.getElementById('Ninos_'+MyId).value;
 
}

function SelectionHabita(MyOpc) {
 var MyId=MyOpc;
 var MyPrecio=document.getElementById('PrecioProd_'+MyId).innerText;
 var MyPrecioN=MyPrecio * 1;
 var MyCantAdu=document.getElementById('Adultos_'+MyId).value;
 var MyCantA=MyCantAdu * 1;
 var MyCantNi=document.getElementById('Ninos_'+MyId).value;
 var MyCantN=MyCantNi * 1;
 var MyDe=document.getElementById('TXTLlegada').value;
 var MyA=document.getElementById('TXTPartida').value;
 var MyArrProd=document.getElementById('TxtArrProdSelected').value;
       
 var MyBW = parseInt(document.getElementById("C_" + MyOpc).style.borderWidth);
 
 if (MyBW == 2) {document.getElementById("C_" + MyOpc).style.borderWidth = 0;
                 document.getElementById('TxtArrProdSelected').value=MyArrProd.replace("|"+MyId+"("+MyDe+","+MyA+","+MyCantAdu+","+MyCantNi+")"+"|","");}    
           else {document.getElementById("C_" + MyOpc).style.borderWidth = 2;
                 document.getElementById("C_" + MyOpc).style.borderStyle = "solid";
                 document.getElementById("C_" + MyOpc).style.borderColor ="Red";
                 document.getElementById('TxtArrProdSelected').value=MyArrProd +"|"+MyId+"("+MyDe+","+MyA+","+MyCantAdu+","+MyCantNi+")"+"|";
      }
}

function AsignaValores(MyV,MyC) {
  document.getElementById(MyC).value=document.getElementById(MyV).value;
}


function ChangeFontColor(MyL,MyC) {
  document.getElementById(MyL).style.color=MyC;
}

function ShowIdioma(MyOpc) {
 
  document.getElementById('TxtIdioma').value=MyOpc;
  var MyPage=document.getElementById('TxtPageToShow').value;
  var MyId=document.getElementById('TxtId').value;
  var MyIdOpc=MyPage+'|'+MyOpc+'_'+MyId;
  
  window.location.href = "StDenis.aspx?ID=" + MyIdOpc;
  
}

function CambiaImagen(MyOpc) {
 var MyI=document.getElementById('TxtImgAct').value;
 
 if (MyOpc=='Next') {if (MyI==6) MyI=1; 
                     else MyI=(MyI*1)+1;}
 else {if (MyI==1) MyI=6; 
       else MyI=(MyI*1)-1;}                   
 
 document.getElementById('TxtImgAct').value=MyI;
 var MyImg=document.getElementById('TxtImgIni'+MyI).value;
 if (MyImg.length==0) {MyI=1;
                       var MyImg=document.getElementById('TxtImgIni'+MyI).value;} 
 MyImg="images/imgtmp/"+MyImg ;              
 AI('ImagenSelection','',MyImg,1);
}

function ShowANTILLASPage(MyOpc,MyId) {

if (MyOpc=='Certificado') {window.location.href ="https://www.cubaeshop.com/CubaEshop.aspx?ID=444|1478|Certificados%20de%20regalos%20de%20diferentes%20valores|Productos|1";}
else { document.getElementById('TxtPageToShow').value=MyOpc;
       var MyIdioma=document.getElementById('TxtIdioma').value;
       if (!MyId) {MyId=0;}
      var MyIdOpc=MyOpc+'|'+MyIdioma+'_'+MyId; 
      window.location.href = "AntillasExpress.aspx?ID=" + MyIdOpc;}
}


function ShowStPage(MyOpc,MyId) {
 //document.getElementById('TXTLlegada').value=document.getElementById('theDate').value;
 //document.getElementById('TXTPartida').value=document.getElementById('theDateA').value;
 
 var MyArrHab=document.getElementById("TxtArrProdSelected").value;
 if (MyOpc=='SalvarReservation') { var MyDesc=document.getElementById("TXTDescrip").value;
                                   var MyFLDV=document.getElementById("TXTFLDValues").value;
                                   MyFLDV=MyFLDV + ",'" + MyDesc + "'"
                                   eraseCookieAntillas("MyFLDVAlues");
                                   CreateCookieAntilla("MyFLDVAlues",MyFLDV,1);
                                   var MyCli=document.getElementById("TxtClienteWeb").value;
                                   eraseCookieAntillas("MyClien");
                                   CreateCookieAntilla("MyClien",MyCli,1);}
 eraseCookieAntillas("MyReserv");
 CreateCookieAntilla("MyReserv",MyArrHab,1);
                         
 var MyDateDe=document.getElementById("theDate").value;
 if (MyDateDe.length>0) {eraseCookieAntillas("DateDE");
                         CreateCookieAntilla("DateDE",MyDateDe,1);}

 var MyDateA=document.getElementById("theDateA").value;
 if (MyDateA.length>0) {eraseCookieAntillas("DateA");
                         CreateCookieAntilla("DateA",MyDateA,1);}


  document.getElementById('TxtPageToShow').value=MyOpc;
  var MyIdioma=document.getElementById('TxtIdioma').value;
  if (!MyId) {MyId=0;}
    
  var MyIdOpc=MyOpc+'|'+MyIdioma+'_'+MyId; 
  window.location.href = "StDenis.aspx?ID=" + MyIdOpc;
}

function OpenEnlace(MyOpc,Style) {
   var MyP=MyOpc.indexOf('"http://');
   var MyPS=MyOpc.indexOf('"httpS://');
   
   if (MyP==-1&&MyPS==-1) MyOpc="http://" +MyOpc; 
   
   if (Style) window.location.href =MyOpc;
   else window.open(MyOpc);
}