function abreventanascroll(mipage,mititulo,ancho,alto)
{
espacio = / /g;
valorcaja=eval('document.formVuelo.' + mititulo + '.value');
valorcaja = valorcaja.replace(espacio,"%20");
mipage=mipage + "&conten=" + valorcaja;

miresize="no"
if (navigator.appName == "Netscape")
	{
	miresize="yes"
	}
	window.open(mipage,mititulo,'scrollbars=yes,toolbar=no,status=no,resizable=' + miresize + ',width=' + ancho + ',height=' + alto);
}
function checfecha(fech_sal,fech_reg)
{
	array_sal = fech_sal.split('/');
	array_reg = fech_reg.split('/');
	if (Number(array_sal[2]) < 100) {
		array_sal[2] = "20" + array_sal[2];
	}
	if (array_sal[1].length == 1) {
		array_sal[1] = "0" + array_sal[1];
	}
	if (array_sal[0].length == 1) {
		array_sal[0] = "0" + array_sal[0];
	}
	if (Number(array_reg[2]) < 100) {
		array_reg[2] = "20" + array_reg[2];
	}
	if (array_reg[1].length == 1) {
		array_reg[1] = "0" + array_reg[1];
	}
	if (array_reg[0].length == 1) {
		array_reg[0] = "0" + array_reg[0];
	}
	salida = array_sal[2]+array_sal[1]+array_sal[0];
	regreso = array_reg[2]+array_reg[1]+array_reg[0];
	
	
			
	if ((Number(salida))<=(Number(regreso))) {
		return true;
	}else
	{
		
		return false;
	}
}

function checkDate()
{

	mensaje='';
	var err=0;
	if ((document.formVuelo.Origen.value == document.formVuelo.Destino.value) && (document.formVuelo.Origen.value != "")) 
	{
		alert("El destino y el origen no pueden ser los mismos");
		return false;
		//mensaje+='El destino y el origen no pueden ser los mismos.\n';
	}
	if (document.formVuelo.Origen.value == "") 
	{
		alert("Introduzca un origen");
		return false;
		//mensaje+='Debe introducir un origen.\n';
	}
	if (document.formVuelo.Destino.value == "") 
	{
		alert("Introduzca un destino");
		return false;
		//mensaje+='Debe introducir un destino.\n';
	}
		
	if (document.formVuelo.TipoBillete.value=='V')
	{
	if ((FechaValida(document.formVuelo.Fecha_ida)) && (FechaValida(document.formVuelo.Fecha_reg))) {
		
	var diasalida,messalida,aniosalida;
	
	array_sal = document.formVuelo.Fecha_ida.value.split('/');
	array_reg = document.formVuelo.Fecha_reg.value.split('/');
	
	diasalida = array_sal[0];
	messalida = array_sal[1];
	aniosalida = array_sal[2];
	
	//var now = new Date();
	var now=new Date(document.formVuelo.fechahoy.value)	
	// En now almacenamos el dia de hoy
	messalida = messalida - 1; // Los meses van de 0 a 11
	var then = new Date(aniosalida,messalida,diasalida);
			
	var gap = then.getTime() - now.getTime();
	gap = Math.floor(gap / (1000 * 60 * 60 * 24));
	gap = gap + 1; // La diferenca en dias...
	}
	else
	{
	err=1;
	}
	}
	
	if (document.formVuelo.TipoBillete.value=='I')
	{
	if ((FechaValida(document.formVuelo.Fecha_ida)))
	
	{
	var diasalida,messalida,aniosalida;
	
	array_sal = document.formVuelo.Fecha_ida.value.split('/');
	array_reg = array_sal;
	
	diasalida = array_sal[0];
	messalida = array_sal[1];
	aniosalida = array_sal[2];
	
	//var now = new Date();
	var now=new Date(document.formVuelo.fechahoy.value)
		
	// En now almacenamos el dia de hoy
	messalida = messalida - 1; // Los meses van de 0 a 11
	var then = new Date(aniosalida,messalida,diasalida);
			
	var gap = then.getTime() - now.getTime();
	gap = Math.floor(gap / (1000 * 60 * 60 * 24));
	gap = gap + 1; // La diferenca en dias...

	
	}
	else
	{
	err=1;
	}
	}

	
	
	
	//if (gap < 0)  {
		//mensaje +='La fecha de salida no puede ser inferior a la actual.\n';
	//	alert("La fecha de salida no puede ser inferior a la actual");
	//	return false;
	//	}
	
	//if (gap > 331) {
		//mensaje +='No se pueden reservar vuelos con más de 331 días de antelación.\n';
	//	alert("No se pueden reservar vuelos con más de 331 días de antelación");
	//	return false;
	//	}
		
	if (document.formVuelo.Fecha_ida.value == '') 
	{
		alert("Introduzca una fecha de salida");
		return false;
		//mensaje+='Debe introducir una fecha de salida.\n';
	}
	if ((document.formVuelo.Fecha_reg.value == '')&&(document.formVuelo.TipoBillete.options[document.formVuelo.TipoBillete.selectedIndex].value=='V')) {
		alert("Introduzca una fecha de regreso");
		return false;
		//mensaje+='Debe introducir una fecha de regreso.\n';  
	}
	
	if ((document.formVuelo.Fecha_ida.value == document.formVuelo.Fecha_reg.value) && (document.formVuelo.TipoBillete.options[document.formVuelo.TipoBillete.selectedIndex].value == 'V') ) {
		
		HR = parseInt(document.formVuelo.HoraRegreso.options[document.formVuelo.HoraRegreso.selectedIndex].value);
		HS = parseInt(document.formVuelo.HoraSalida.options[document.formVuelo.HoraSalida.selectedIndex].value);
		
		
		if ( HR <= HS) 
		{
			alert("La hora de regreso debe ser posterior a la de salida");
			return false;
			//mensaje+='La Hora de regreso debe ser posterior a la de salida.\n';
		}
	}
	
	
	
			
	if (!mensaje==''){
		alert(mensaje);
		return false;
	}else{
		
		if (err!=1)
		{
		if ((document.formVuelo.TipoBillete.options[document.formVuelo.TipoBillete.selectedIndex].value =='V')&&(!checfecha(document.formVuelo.Fecha_ida.value,document.formVuelo.Fecha_reg.value)))
			{ 
			alert('La fecha de Regreso debe ser igual o posterior a la de Salida.'); 
			return false;
		}
		else
			{
			 return true;
			}
		}
		else
		{ 
		return false;	
		}
}
} 

function openWin(popup_url,name,width,height)
	{ 
	var  size=  ',width=  '+ width  +',height='+ height;
	varposicion=",left="+Math.round(screen.availWidth/3)+",top="+Math.round(screen.availHeight/3);varpopUp=window.open(popup_url,name,'resizable=no,menubar=no,location=no,toolbar=no,status=yes,scrollbars=no,directories=no,'+size+posicion);
	popUp.opener=self;
}

function FechaValida(THISDATE) {
        var err=0
        a=THISDATE.value
        if (a.length > 10) err=1
        
        var valid = "0123456789/"
		var ok = "yes";
		var temp;
		for (var i=0; i<a.length; i++) {
		temp = "" + a.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
                  
        err=1;
        
		}
                
        
        a_sal = a.split('/');
				
		a_dia = a_sal[0];
		a_mes = a_sal[1];
		a_anio = a_sal[2];
        
        b = a_mes// month
        d = a_dia// day
        f = a_anio // year
        
        
        
        if (b<1 || b>12) err = 1
        if (d<1 || d>31) err = 1
        if (f< 2001) err = 1
        if (f> 2006) err = 1
        if (b==4 || b==6 || b==9 || b==11){
                if (d==31) err=1
        }
        if (b==2){
                var g=parseInt(f/4)
                if (isNaN(g)) {
                        err=1
                }
                if (d>29) err=1
                if (d==29 && ((f/4)!=parseInt(f/4))) err=1
        }
        if (err==1) {
                alert(THISDATE.value + ' no es una fecha válida. Por favor, vuelva a introducirla.');
                //THISDATE.value = "";
                THISDATE.focus();
                return false;
        }
        else
			{return true;}
}

function enviaformulario(valor)
{

if (valor=='vuelos')
{
document.formVuelo.action="http://www.muchoviaje.com/msn_es/msnconn.asp?tip=ltxt&pagmv=http://reservas.muchoviaje.com/vuelos/index.asp";
document.formVuelo.submit();
}
else
{
 if (valor=='puente')
 {
	document.formVuelo.action="http://www.muchoviaje.com/msn_es/msnconn.asp?tip=ltxt&pagmv=http://reservas.muchoviaje.com/vuelos/puente/puenteaereo.asp";
	document.formVuelo.submit();
 }
}
}
function empezar_200x200_vuelos(URL_COMPLETA2, ID_AFIL){
URL_COMPLETA = URL_COMPLETA2 + "http://viajes.muchoviaje.com/viajes/publicidad/zanox.aspx?URL="
document.writeln('<form name="formVuelo" onsubmit="return checkDate()" action="'+URL_COMPLETA+'http://reservas.muchoviaje.com/vuelos/consulta.asp&zanid='+ID_AFIL+'" method="post" target=_blank>');
document.writeln('<table style="height:200 px; width:200 px" cellpadding=0 cellspacing=0 border=0>');
document.writeln('	<tr>');
document.writeln('		<td align=center valign=top><img src="http://www.muchoviaje.com/zanox/images/buscador/v2_2.gif" width=200 height=15><br>');
document.writeln('			<table background="http://www.muchoviaje.com/zanox/images/buscador/v2_1.gif" style="width:200px; height:168px" cellpadding=0 cellspacing=0 border=0>	');
document.writeln('				<tr>');
document.writeln('					<td colspan=2></td>');
document.writeln('				</tr>');
document.writeln('				<tr>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=15 height=25><input name="Origen" style="font-size:9; font-family:arial; width:80; background-color:#cccccc"></td>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=8 height=25><input name="Destino" style="font-size:9; font-family:arial; width:80; background-color:#cccccc"></td>');
document.writeln('				</tr>');
document.writeln('				<tr>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=15 height=20><input style="font-size:9; font-family:arial; width:60; background-color:#cccccc" name="Fecha_ida" value="dd/mm/aaaa"></td>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=9 height=20><select name="HoraSalida" style="font-size:9; font-family:arial; background-color:#cccccc">');
document.writeln('						                        <option value="8" selected>08:00</option>');
document.writeln('						                        <option value="9">09:00</option>');
document.writeln('						                        <option value="10">10:00</option>');
document.writeln('						                        <option value="11">11:00</option>');
document.writeln('						                        <option value="12">12:00</option>');
document.writeln('						                        <option value="13">13:00</option>');
document.writeln('						                        <option value="14">14:00</option>');
document.writeln('						                        <option value="15">15:00</option>');
document.writeln('						                        <option value="16">16:00</option>');
document.writeln('						                        <option value="17">17:00</option>');
document.writeln('						                        <option value="18">18:00</option>');
document.writeln('						                        <option value="19">19:00</option>');
document.writeln('						                        <option value="20">20:00</option>');
document.writeln('						                        <option value="21">21:00</option>');
document.writeln('						                        <option value="22">22:00</option>');
document.writeln('						                        <option value="23">23:00</option>');
document.writeln('						                        <option value="24">00:00</option>');
document.writeln('						                        <option value="1">01:00</option>');
document.writeln('						                        <option value="2">02:00</option>');
document.writeln('						                        <option value="3">03:00</option>');
document.writeln('						                        <option value="4">04:00</option>');
document.writeln('						                        <option value="5">05:00</option>');
document.writeln('						                        <option value="6">06:00</option>');
document.writeln('						                        <option value="7">07:00</option>');
document.writeln('				                      </select></td>');
document.writeln('				</tr>');
document.writeln('				<tr>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=15 height=18><input style="font-size:9; font-family:arial; width:60; background-color:#cccccc" name="Fecha_reg" value="dd/mm/aaaa"></td>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=9 height=18><select name="HoraRegreso" style="font-size:9; font-family:arial; background-color:#cccccc">');
document.writeln('						                        <option value="8" selected>08:00</option>');
document.writeln('						                        <option value="9">09:00</option>');
document.writeln('						                        <option value="10">10:00</option>');
document.writeln('						                        <option value="11">11:00</option>');
document.writeln('						                        <option value="12">12:00</option>');
document.writeln('						                        <option value="13">13:00</option>');
document.writeln('						                        <option value="14">14:00</option>');
document.writeln('						                        <option value="15">15:00</option>');
document.writeln('						                        <option value="16">16:00</option>');
document.writeln('						                        <option value="17">17:00</option>');
document.writeln('						                        <option value="18">18:00</option>');
document.writeln('						                        <option value="19">19:00</option>');
document.writeln('						                        <option value="20">20:00</option>');
document.writeln('						                        <option value="21">21:00</option>');
document.writeln('						                        <option value="22">22:00</option>');
document.writeln('						                        <option value="23">23:00</option>');
document.writeln('						                        <option value="24">00:00</option>');
document.writeln('						                        <option value="1">01:00</option>');
document.writeln('						                        <option value="2">02:00</option>');
document.writeln('						                        <option value="3">03:00</option>');
document.writeln('						                        <option value="4">04:00</option>');
document.writeln('						                        <option value="5">05:00</option>');
document.writeln('						                        <option value="6">06:00</option>');
document.writeln('						                        <option value="7">07:00</option>');
document.writeln('						                      </select></td>');
document.writeln('				</tr>');
document.writeln('				<tr>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=15 height=23><select name="Adultos" style="font-size:9; font-family:arial; background-color:#cccccc">');
document.writeln('										          <option value="1" selected>1</option>');
document.writeln('										          <option value="2">2</option>');
document.writeln('										          <option value="3">3</option>');
document.writeln('										          <option value="4">4</option>');
document.writeln('										          <option value="5">5</option>');
document.writeln('										          <option value="6">6</option>');
document.writeln('										          <option value="7">7</option>');
document.writeln('										          <option value="8">8</option>');
document.writeln('										          <option value="9">9</option>');
document.writeln('										        </select></td>');
document.writeln('					<td><img src="http://www.muchoviaje.com/images/comun/blank.gif" width=9 height=23><select id="TipoBillete" name="TipoBillete" style="font-size:9; font-family:arial; background-color:#cccccc">');
document.writeln('										        <option value="I">Ida</option>');
document.writeln('										        <option selected value="V">Ida-Vuelta</option>');
document.writeln('										      </select>');
document.writeln('										      <input type="hidden" name="vengo" value="index">');
document.writeln('										      <input type="hidden" name="compania1">');
document.writeln('										      <input type="hidden" name="compania2">');
document.writeln('										      <input type="hidden" name="compania3">');
document.writeln('										      <input type="hidden" name="clase" value="Y">');
document.writeln('										      <input type="hidden" name="Moneda" value="E">');
document.writeln('										      <input type="hidden" name="Ninos" value="0">');
document.writeln('										      <input type="hidden" name ="cualtext">');
document.writeln('										      <input type="hidden" name="Bebes" value="0">');
document.writeln('										      <input type="hidden" name="vuelodirecto" value="S">');
document.writeln('										      <input type="hidden" name="restriccion" value="N">');
document.writeln('										      <input type="hidden" name="tipobusqueda" value="precio">');
document.writeln('										      <input type="hidden" name=fechahoy value="10/24/2001">');
document.writeln('										      <input type="hidden" name="portalexterno" value="MCS">');
document.writeln('										</td>');
document.writeln('				</tr>');
document.writeln('				<tr>');
document.writeln('					<td colspan=2></td>');
document.writeln('				</tr>');
document.writeln('			</table>');
document.writeln('		</td>');
document.writeln('	</tr>');
document.writeln('	<tr bgcolor=FFFFFF>');
document.writeln('		<td valign=top><input type="image" src="http://www.muchoviaje.com/zanox/images/buscador/v2_3.gif" align="right" border="0" width="85" height="15" id=image1 name=image1 vspace=0>');
document.writeln('								&nbsp;<IMG SRC="http://www.muchoviaje.com/zanox/images/buscador/v2_4.gif" vspace=1></td>');
document.writeln('	</tr>');
document.writeln('</table>');
document.writeln('</form>');
}
