function ventana(nombre,name,propiedades)

 {

  t=window.open(nombre,name,propiedades);

  t.focus();

 }

function ComparaFechas(anio1,mes1,dia1, anio2, mes2, dia2) {
var date1;
var date2;

if (!chkdate(anio1,mes1,dia1)) {
	alert("Error: La Fecha Inicial es incorrecta");
	return false;
}
if (!chkdate(anio2,mes2,dia2)) {
	alert("Error: La Fecha Final es incorrecta");
	return false;
}
date1 = new Date(anio1,mes1,dia1);
date2 = new Date(anio2,mes2,dia2);
if (date1.getTime() > date2.getTime()) { // fecha 1 > fecha 2
	return false;
}
else {return true;}
}

function getDays(month, year) {
	// create array to hold number of days in each month
	var ar = new Array(12)
	ar[0] = 31 // January
	ar[1] = (LeapYear(year)) ? 29 : 28 // February
	ar[2] = 31 // March
	ar[3] = 30 // April
	ar[4] = 31 // May
	ar[5] = 30 // June
	ar[6] = 31 // July
	ar[7] = 31 // August
	ar[8] = 30 // September
	ar[9] = 31 // October
	ar[10] = 30 // November
	ar[11] = 31 // December

	// return number of days in the specified month (parameter)
	return ar[month]
}


function actualizar_combo(date, month, year){

	var dia_antiguo=(date.selectedIndex+1);
	
	date.options[30]=null;
	date.options[29]=null;
	date.options[28]=null;

	for (i=1; getDays(month.selectedIndex, year.options[year.selectedIndex].value) >= i; i++) {
		j = i;
		if (i < 10)
			j = "0" + j;
		var option = new Option(j, j);
		date.options[i-1]=option;
		if (i == dia_antiguo) {
			date.options[i-1].selected=true;
		}
	}
}


function chkdate(intYear,intMonth,intday) {
var err = 0;

if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
	if (intday < 1) {
		err = 8;
		return false;
	}
	if (LeapYear(intYear) == true) {
		if (intday > 29) {
			err = 9;
			return false;
		}
	}
	else {
		if (intday > 28) {
			err = 10;
			return false;
		}
	}
}
return true;
}

function LeapYear(intYear) {
if (intYear % 100 == 0) {
	if (intYear % 400 == 0) { return true; }
}else {
	if ((intYear % 4) == 0) { return true; }
}
return false;
}

function inicializar_combos(hoy, date, month, year, minano, maxano) {
	var auxano = hoy.getFullYear();
	var auxmes = hoy.getMonth();
	var auxdia = hoy.getDate();
	var i;
	var j;

	hoy = null;
	for (i=1; getDays(auxmes, auxano) >= i; i++) {
		j = i;
		if (j < 10)
			j = "0" + j;
		var option = new Option(j, j);
		date.options[i-1]=option;
		if (i == auxdia) {
			date.options[i-1].selected=true;
		}
	}
	month.selectedIndex=auxmes;
	for (j=minano; maxano >= j; j++) {
		var option2 = new Option(j, j);
		year.options[j-minano]=option2;
		if (j == auxano) {
			year.options[j-minano].selected=true;
		}
	}
}
function mOvr(src,imgOver) {

 if (!src.contains(event.fromElement)) {

	 src.style.cursor = 'hand';

	 src.background = imgOver;

	}

 }

 function mOut(src,imgIn) {

	if (!src.contains(event.toElement)) {

	 src.style.cursor = 'default';

	 src.background = imgIn;

	}

 }
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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 ser una dirección Email válida.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' debe ser numérico.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) 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('Los siguientes errores han ocurrido:\n'+errors);
  document.MM_returnValue = (errors == '');
}