var DestinoActual;
function LlenaDestino(valor)
{

 //alert("el destino es ");
  //indice=este;
  DestinoActual=valor;
  seleccion=eval("D"+valor); //  es el destino
  cuantos=seleccion.length;
  document.all["XA"].length=cuantos; // Son Los Destinos
  cuantos=cuantos-1;
  //alert(este[indice].text);
  for (ciclo=0;ciclo <=cuantos;ciclo++)
   {
    if(ciclo==0)
	{
    document.all["XA"].options[ciclo].text=seleccion[ciclo];
	document.all["XA"].options[ciclo].selected=-1;

	}
	else
	{
	    document.all["XA"].options[ciclo].text=seleccion[ciclo];
    }
  }	
  muestra();
 } 
function muestra()
{
  //alert("el destino es "+ DestinoActual);
  //indice=este;
  
  if (DestinoActual==1)
  {
  seleccion=eval("mp"+document.all["XA"].selectedIndex); // XA es el destino mp destino playa
  document.all["playa"].src="./imagenes/playap.jpg";
  document.all["ciudad"].src="./imagenes/ciudad.jpg";
  document.all["montana"].src="./imagenes/montana.jpg";
  }
  if (DestinoActual==2)
  {
  seleccion=eval("mc"+document.all["XA"].selectedIndex); // XA es el destino mp destino Ciudad
  document.all["playa"].src="./imagenes/playa.jpg";
  document.all["ciudad"].src="./imagenes/ciudadp.jpg";
  document.all["montana"].src="./imagenes/montana.jpg";
  }  
  if (DestinoActual==3)
  {
  seleccion=eval("mm"+document.all["XA"].selectedIndex); // XA es el destino mp destino montaņa  
    document.all["playa"].src="./imagenes/playa.jpg";
  document.all["ciudad"].src="./imagenes/ciudad.jpg";
  document.all["montana"].src="./imagenes/montanap.jpg";
  }
  cuantos=seleccion.length;
  document.all["FA"].length=cuantos; // FA es el Hotel
  cuantos=cuantos-1;
  //alert(este[indice].text);
  for (ciclo=0;ciclo <=cuantos;ciclo++)
   {
    if(ciclo==0)
	{
    document.all["FA"].options[ciclo].text=seleccion[ciclo];
	document.all["FA"].options[ciclo].selected=-1;

	}
	else
	{
	    document.all["FA"].options[ciclo].text=seleccion[ciclo];
    }
  }	
 } 

function envia()
{
var datos;
if (document.all("codigo").value!= "")  
{
datos="vercupon1.asp?codigo="+ document.all("codigo").value;

document.location.href=datos;
 return true;
 }
 else
 {
 alert("Numero de codigo vacio");  
  return false;
 } 
}






function Formato(este)
{
var mes
var hoy=new Date();
var Months = new Array ("Ene", "Feb", "Mar", "Abr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dic");

if(este.value!=null) 
{
	
	if (este.value.length == 7 || este.value.length == 8 || este.value.length == 9 )
	
	{
		alert("se requiere un ano de 4 cifras");
		return false;
	}
	
  if (este.value.length == 2) este.value = este.value+'/'+Months[hoy.getMonth()] + "/" + hoy.getFullYear();
     if (este.value.length == 5) 
     {
       mes=este.value.substr(3,2);
       if (mes.substr(0,1)=='0') mes=mes.substr(1,1); 
       este.value = este.value.substr(0,2)+'/'+ Months[parseInt(mes)-1] + "/" + hoy.getFullYear();  
  
     }
 

    if (este.value.length == 10) 
     {
  mes=este.value.substr(3,2);
  if (mes.substr(0,1)=='0') mes=mes.substr(1,1); 
  este.value = este.value.substr(0,2)+'/'+ Months[parseInt(mes)-1] + "/" + este.value.substr(6,4);  
  
     }  


}

     return true;
  }   




function Formatf(fld,  e) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789/';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;
  

  if (whichCode == 13)    return true;  // Enter

  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  if (len > 10) return false;
  
  if (len == 2) fld.value = fld.value+'/';
  if (len == 5) fld.value = fld.value+'/';
  return true;
}

function FormatM(fld, milSep, decSep, e) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}
function SoloNumeros(fld,  e) {
  
  var key = '';
  
  var strCheck = '0123456789';
  
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  
  return true;
  }

