// JavaScript Document
function ask(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// fechas en ingles
function fechask() { //v3.0
			calendar = new Date();
			
			 day = calendar.getDay();
			
			 month = calendar.getMonth();
			
			 date = calendar.getDate();
			
			 year = calendar.getYear();
			
			 if (year < 1000)
			
			 year+=1900
			
			 cent = parseInt(year/100);
			
			 g = year % 19;
			
			 k = parseInt((cent - 17)/25);
			
			 i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
			
			 i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
			
			 j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
			
			 l = i - j;
			
			 emonth = 3 + parseInt((l + 40)/44);
			
			 edate = l + 28 - 31*parseInt((emonth/4));
			
			 emonth--;
			
			 var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
			
			 var monthname = 
			
			 new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );
			
			
			 document.write("<strong>" + dayname[day] + ", ");
			
			 document.write(monthname[month] + " ");
			
			 if (date< 10) document.write("0" + date + ", ");
			
					 else document.write(date + ", ");
			
			 document.write(year );
			
			 // Easter
			
			 if ((month == emonth) && (date == edate)) document.write("Easter Sunday (Western)   ");
			
			 // January
			
			 if ((month == 0) && (date == 1)) document.write("New Year's Day");
			
			 if ((month == 0) && (date == 15)) document.write("Adults Day (Japan)");
			
			 if ((month == 0) && (date == 27)) document.write("Wolfgang Amadeus Mozart born (1756)");
			
			 if ((month == 0) && (day == 1) && (date > 14) && (date< 22)) document.write("Martin Luther King's Birthday");
			
			 // February
			
			 if ((month == 1) && (date == 2)) document.write("Groundhog Day");
			
			 if ((month == 1) && (date == 8)) document.write("Jules Verne born (1828)");
			
			 if ((month == 1) && (date == 11)) document.write("National Foundation Day (Japan)");
			
			 if ((month == 1) && (date== 12)) document.write("Lincoln's Birthday");
			
			 if((month == 1) && (date == 14)) document.write("St. Valentine's Day");
			
			 if ((month == 1) && (date == 15)) document.write("Galileo Galilei born (1564)");
			
			 if ((month == 1) && (date == 22)) document.write("Washington's Birthday");
			
			 if ((month == 1) && (date == 29)) document.write("Leap Day");
			
			 // March
			
			 if ((month == 2) && (date == 3)) document.write("Girl's Day (Japan)");
			
			 if ((month == 2) && (date == 17)) document.write("St. Patrick's Day");
			
			 if ((month == 2) && (date == 21)) document.write("J.S. Bach born (1685)");
			
			 // April
			
			 if ((month == 3) && (date == 1)) document.write("April Fools' Day");
			
			 if ((month == 3) && (date == 8)) document.write("Buddha born");
			
			 if ((month == 3) && (date == 15) && (day != 0)) document.write("Income Tax Day (USA),   ");
			
			 if ((month == 3) && (date == 16) && (day == 1)) document.write("Income Tax Day (USA) ");
			
			 if ((month == 3) && (date == 15)) document.write("Leonardo da Vinci born (1452)");
			
			 if ((month == 3) && (date == 22)) document.write("Earth Day");
			
			 if ((month == 3) && (date == 29)) document.write("Emperor's Birthday (Japan)");
			
			 if ((month == 3) && (day == 0) && (date > 0) && (date< 8)) document.write("Daylight Savings Time Begins");
			
			 // May
			
			 if ((month == 4) && (date == 1)) document.write("May Day,   Boy's Day (Japan)");
			
			 if ((month == 4) && (date == 2)) document.write("Constitution Day (Japan)");
			
			 if ((month == 4) && (date == 5)) document.write("Cinco de Mayo (Mexico),   Children's Day (Japan)");
			
			 if ((month == 4) && (date == 14)) document.write("Independence Day (Paraguay)");
			
			 if ((month == 4) && (day == 0) && (date > 7) && (date< 16)) document.write("Mother's Day");
			
			 if ((month == 4) && (day == 1) && (date > 24)) document.write("Memorial Day");
			
			 // June
			
			 if ((month == 5) && (date == 5)) document.write("Constitution Day (Denmark)");
			
			 if ((month == 5) && (date == 6)) document.write("D-Day (USA)");
			
			 if ((month == 5) && (date == 7)) document.write("FlagDay (Peru)");
			
			 if ((month == 5) && (date == 11)) document.write("Kamehameha (Hawaii)");
			
			 if ((month == 5) && (date == 14)) document.write("FlagDay (USA)");
			
			 if ((month == 5) && (date == 21)) document.write("Summer Solstice");
			
			 if ((month == 5) && (date == 24)) document.write("Inty Raymi Festival (Peru)");
			
			 if ((month == 5) && (date == 30)) document.write("Independence Day (Zaire)");
			
			 if ((month == 5) && (day == 0) && (date > 15) && (date< 24)) document.write("Father's Day");
			
			 // July
			
			 if ((month == 6) && (date == 1)) document.write("Independence Day (Canada)");
			
			 if ((month == 6) && (date == 4)) document.write("Independence Day (USA)");
			
			 if ((month == 6) && (date == 14)) document.write("Bastille Day (France)");
			
			 if ((month == 6) && (date == 28)) document.write("Independence Day (Peru)");
			
			 // August
			
			 if ((month == 7) && (date == 1)) document.write("Confederation Day (Switzerland)");
			
 
			
			 if ((month == 7) && (date == 10)) document.write("Independence Day (Ecuador)");
			
			 if ((month == 7) && (date == 15)) document.write("Independence Day (India)");
			
				 // September
			
			 if ((month == 8) && (date == 7)) document.write("Independence Day (Brazil)");
			
			 if ((month == 8) && (date == 15)) document.write("Respect for the Aged Day (Japan)");
			
			 if ((month == 8) && (date == 16)) document.write("Independence Day (Mexico)");
			
			 if ((month == 8) && (day== 1)&& (date > 0) && (date< 8)) document.write("Labor Day (USA)");
			
			 // October
			
			 if ((month == 9) && (date == 1)) document.write("German Reunufication (1990)");
			
			 if ((month == 9) && (date == 10)) document.write("Health-Sports Day (Japan)");
			
			 if ((month == 9) && (day == 1) && (date > 7) && (date< 16)) document.write("Columbus Day (USA)");
			
			 if ((month == 9) && (day == 0) && (date > 24) && (date< 31)) document.write("Daylight Savings Time Ends");
			
			 if ((month == 9) && (day == 0) && (date == 31)) document.write("Daylight Savings Time Ends<BR>");
			
			 if ((month == 9) && (date == 24)) document.write("United Nations Day");
			
			 if ((month == 9) && (date == 31)) document.write("Halloween");
			
			 // November
			
			 if ((month == 10) && (date == 1)) document.write("All Saints Day");
			
			 if ((month == 10) && (date == 2)) document.write("All Souls Day");
			
			 if ((month == 10) && (date == 3)) document.write("Culture Day (Japan)");
			
			 if ((month == 10) && (date == 11)) document.write("Veteran's Day (USA)");
			
			 if ((month == 10) && (date ==20)) document.write("Revolution Day (Mexico)");
			
			 if ((month == 10) && (date == 23)) document.write("Labor Thanksgiving Day (Japan)");
			
			 if ((month == 10) && (day == 4) && (date > 23) && (date< 30)) document.write("Thanksgiving (USA)");
			
			 if ((month == 10) && (date == 30) && (day == 4)) document.write("Thanksgiving (USA)");
			
			 // December
			
			 if ((month == 11) && (date == 10)) document.write("Human Rights Day");
			
			 if ((month == 11) && (date == 19)) document.write("Natalia's day");
			
			 if ((month == 11) && (date == 21)) document.write("Winter Solstice");
			
			 if ((month == 11) && (date == 24)) document.write("Christmas Eve");
			
			 if ((month == 11) && (date == 25)) document.write("Christmas");
			
			 if ((month == 11) && (date == 26)) document.write("Boxing Day");
			
			 if ((month == 11) && (date == 31)) document.write("New Year's Eve");
			 document.write("</strong>");

}
// final fechas

// cuidado con el ajax
function miajax()
{
    try 
	{
        objetus = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch ( e) 
	{
        try 
		{
            objetus= new ActiveXObject ("Microsoft.XMLHTTP");
        }
		catch (E)
		{
            objetus = false;
        }
    }
    if (! objetus && typeof XMLHttpRequest!= 'undefined') 
	{
        objetus = new XMLHttpRequest();
    }
    return objetus
}

function muestramenu(archivo, target)
{

    nuevoAjax = miajax(); //crear objeto
    valoresEnvio = "accion=mostrar";
///
	direccion = archivo+"?" //URL
    nuevoAjax.open("GET",direccion+"&"+valoresEnvio,true); //abrir procesador
    nuevoAjax.onreadystatechange=function()
	{ //funcion controlador
        if (nuevoAjax.readyState==1) //control de estados del proceso
        {
			//procesos que relizara mientras dura la carga
			document.getElementById(target).innerHTML = "<center><img src=\"http://www.perutrip.net/php/hoteles/images/bigrotation2.gif\"></center>";
        }
		else
		{
			if(nuevoAjax.readyState==4)
			{
             	if(nuevoAjax.status==200)
            	{
                    //procesos que se realizaran con los datos obtenidos  
					/*target="cargando"                        
					document.getElementById(target).innerHTML=nuevoAjax.responseText;*/
					document.getElementById(target).innerHTML = nuevoAjax.responseText;

	             }
			}
		}
	}
    nuevoAjax.send(null); //envo nulo de variables*/
	
}

function conexionAjax (filedestino, valoresEnvio, divdestino, tipoalerta, next)
{
	///  Lo unico que necesito es la direccion del archivo php y los valores de envio
	///  Y bueno tambien el div de destino y si existe el de estado
	if (tipoalerta == null)
	{
		tipoalerta = 0	
	}
	else
	{
		tipoalerta = tipoalerta	
	}
	
	nuevoAjax = miajax(); //crear objeto

    nuevoAjax.open("GET",filedestino+"&"+valoresEnvio,true); //abrir procesador
    nuevoAjax.onreadystatechange=function()
	{ //funcion controlador
        if (nuevoAjax.readyState==1) //control de estados del proceso
        {
			//procesos que relizara mientras dura la carga
			if (tipoalerta == 0)
			{
				escribirDiv(divdestino, "<center>Cargando ...</center>");
			}
        }
		else
		{
			if(nuevoAjax.readyState==4)
			{
             	if(nuevoAjax.status==200)
            	{
                    //procesos que se realizaran con los datos obtenidos
					/*target="cargando"
					document.getElementById(target).innerHTML=nuevoAjax.responseText;*/
					if (tipoalerta == 0)
					{
						escribirDiv(divdestino, nuevoAjax.responseText);
					}
					else
					{
						if (tipoalerta == 1)
						{
							window.alert (nuevoAjax.responseText);
						}
					}
				
					if (next != null)
					{
						eval (next);
					}	
	             }
			}
		}
	}
    nuevoAjax.send(null); //envo nulo de variables*/
}


/* Objatos Macromedia para validación....*/


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una direccion email correcta.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un numero.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; }
  } if (errors) alert('El siguiente error a ocurrido:\n'+errors);
  document.MM_returnValue = (errors == '');
}
