
function ventanaNueva(theURL,winName,w,h,l,t,resize,scroll,stat,tool,locat,direct,menu,history) {

features = 'width=' + w + ',height=' + h + ',left=' + l + ',top=' + t + ',resizable=' + resize + ',scrollbars=' + scroll + ',status=' + stat + ',toolbar=' + tool + ',location=' + locat + ',directories=' + direct + ',menubar=' + menu + ',copyhistory=' + history + ',screenX=' + l + ',screenY=' + t

window.open(theURL,winName, features)
				

}

function expandCollapse(ElementId)
{
	var theElement = document.getElementById(ElementId);
	theElement.style.display = (theElement.style.display == 'none') ? 'block' : 'none';
}


function trim(x) {
   
   while (x.substring(0,1) == ' ') x = x.substring(1);
   while (x.substring(x.length-1,x.length) == ' ') x = x.substring(0,x.length-1);
   return x;
}

function validarCorreo(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {
    return (false);
  }
}

function validarEmail(valor) {
	valor=valor.replace(';',',');
	var correo;

  while (1){
    var num = valor.indexOf(",");
    if(num>0){
      correo = valor.substring(0,num);
      correo =trim(correo);
      if (!validarCorreo(correo)) return false;
      var longi = valor.length;
      valor=valor.substring(num+1,longi);
    }else {
      correo = valor;
      correo =trim(correo);
      if (!validarCorreo(correo)) return false;
      break;
    }
  
  }  
  return true;
}


function isDate (formField) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.

	var aD = formField.value.split("/");
	
	day = aD[0];
	month = aD[1];
	year = aD[2];
	var fecha_actual = new Date();
	var anno_actual = fecha_actual.getYear();
	
	
    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) &&
         (year <= anno_actual))
        return true;
    else
        return false
}

function y2k(number) { 
	return (number < 1000) ? number + 1900 : number; 
}


function isAlpha(Campo) {

	var CaracteresPermitidos = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ñÑáéíóúÁÉÍÓÚüÜ";
	for(var i=0; i<Campo.length; i++){
		var varia = Campo.substring(i,i+1);
		if (CaracteresPermitidos.indexOf(varia) == -1){
			return false;}
	}
	return true;

}


function isAlphaNumeric(Campo) {

	var CaracteresPermitidos = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ñÑáéíóúÁÉÍÓÚüÜ0123456789";
	for(var i=0; i<Campo.length; i++){
		var varia = Campo.substring(i,i+1);
		if (CaracteresPermitidos.indexOf(varia) == -1){
			return false;}
	}
	return true;
	
}

function isNumeric(Campo)
{
	
	var CaracteresPermitidos = "0123456789";
	for(var i=0; i<Campo.length; i++){
		var varia = Campo.substring(i,i+1);
		if (CaracteresPermitidos.indexOf(varia) == -1){
			return false;}
	}
	return true;
	
}
